# Simulating wind (vertex bending)

Right now I'm using the Crytek vegetation bending technique, vertex colors control how much force is applied to the branches, leafs and trunks. I have it working and it looks nice but I'm just using random wind so it's all over the place.

Here is the code I use for the wind on the CPU, this gets passed of the vertex shader where the bending happens:

    // Change wind every second, and smoothly interpolate to the new strength/direction.
Dim timeEllapsed As Single = CType(gametime.ElapsedGameTime.TotalSeconds, Single)
_Time += timeEllapsed
timeSinceLastThing -= timeEllapsed
If timeSinceLastThing < 0F Then
lastWindSpeed = newWindSpeed
Dim x As Single = CType(random.NextDouble(), Single)
x = CType(Math.Pow(x, 3), Single)
Dim y As Single = CType(random.NextDouble(), Single)
y = CType(Math.Pow(y, 3), Single)
newWindSpeed = New Vector2(x * 2.0F - 1.0F, y * 2.0F - 1.0F)
newWindSpeed *= 0.9F
timeSinceLastThing += 1.0F
End If
currentWindSpeed = Vector2.SmoothStep(newWindSpeed, lastWindSpeed, timeSinceLastThing)


It's nice and flowy so that's not an issue, it just doesn't really gust and stuff the same way wind does. I'm just wondering if anyone knows of a better way of making nice swaying wind? Or will I just have to tweak it till I find what I'm after?