Utility Functions
Let Zephyr handle the heavy lifting so you can focus on your world
Layered Sine Wave
One of the biggest issues with using a sine wave for wind is that when the wind speed changes, all of your materials will shake or snap to their new position. This is because of the way that sine waves are calculated in shaders - think about it like a long street with a house every 500 feet. Now imagine that you increase that distance by 1 foot. If you are looking at the first house, you might not notice any change but if you are 10 miles down the road, the house will shift noticeably.
To get around this problem, Zephyr uses a unique solution we call a layered sine wave, this wave is actually five individual sine waves stacked at powers of two of each other (the second sine wave is twice the speed of the first, the third is twice the speed of the second, etc.) that are interpolated based on the wind speed. This results in buttery smooth speed changes that are barely noticeable.
Layered Noise
Follows the same principles as the layered sine wave, but works in 2D as a Perlin noise.
Rotate About Axis
Simple HLSL reconstruction of the rotate about axis function. Lets you rotate a point in space around an arbitrary axis.
Normalize Position
When wind is applied linearly, some stretching is inevitable. The normalize position function ensures that every vertex stays the proper distance away from the center regardless of the transformation that you apply.
Last updated