I’ve been working on something similar off-and-on, but I don’t really care about its actual physical simulation, just that it feels like it’s a simulation. I keep track of:
- Wind heading (which is the rotation around the Z axis grabbed from an X/Y vector – I don’t care much about Z wind modulation and can fake it if I end up needing to). I keep this in two forms:
- Initial wind heading which is any value between 0-2pi.
- Min/Max heading waver values which are user-defined; this will ensure that the initial heading is constant while the wavering is within a controlled range.
- Wind speed.
- Wind intensity.
(There are also dynamic stuff like gusting, changing weather, cloudiness, etc.). Also, I keep a WindDirectionalSourceComponent in my world simulation as that updates SpeedTree assets. So I keep that in sync.
So, what I do is just:
- Generate a noise table (GitHub - Auburn/FastNoiseLite: Fast Portable Noise Library - C# C++ C Java(Script) HLSL) – which I can’t remember if it varies over time or is a look-up table (either way, it works well).
- Store a sample position and a sample step amount.
- Grab an x, y, z sampled noise value using (X,Y,Z), (Z,X,Y), and (Y,Z,X) – it’s a 3D noise volume, so you could really sample it however you want, but this was quickest for me to deal with early on in this process. And then I calculate the values in some way, shape, or form based on those noise values (ensure that you’re generating a noise table with a nice flow; or use a constant one too, I suppose; mine is random every session).
- I then store the following in a material parameter collection for use in materials:
- Wind Intensity (modifies how strongly affected an object is by the wind).
- Wind Speed (the general speed)
- Set a Rotator with (0, 0, Heading) – heading being Roll in this case – so I can set my WindDirectionalSource direction. Then I convert the rotator to a quaternion using FRotator::ToAxisAndAngle. Axis gives me the wind directional vector (handy for materials), the angle is just to save me calculating the angle from the vector X/Y in-game. Toss those four values into a linear color and pass it to the material parameter collection.
This is working out for me pretty well so far, anyway.