3
\$\begingroup\$

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?

\$\endgroup\$
3
  • \$\begingroup\$ i have a question, does it only displaces the bullet on teh x-axis curve but teh y-axis as well? \$\endgroup\$
    – whale
    Commented Mar 1, 2020 at 23:43
  • \$\begingroup\$ Have you thought about maybe using a gerstner function to simulate more gust like behaviour. The gerstner wave in this case would be used to calculate force, rather than displacement. Seeing you already have the amount of force worked out for the actual vegetation. The Gerstner formula is used for wave simulation, and it might be interesting experiment here. \$\endgroup\$
    – ErnieDingo
    Commented Mar 2, 2020 at 1:35
  • \$\begingroup\$ Thanks for that, while im not working on this right now im slowly porting all my code to c++. If you want to make an answer ill accept it. \$\endgroup\$ Commented May 13, 2020 at 23:32

0

You must log in to answer this question.

Browse other questions tagged .