# Vegetation movement with wind

Anyone has any idea on how do to something like this in Urho?

Hey there!

Both Lumak and Eugene have excellent examples here:

Lumak seems to be manipulating the vertices directly: https://github.com/Lumak/Urho3D-Geom-Replication/blob/master/Source/Samples/62_GeomReplicator/StaticScene.cpp#L265

Wouldnâ€™t that be more efficient as a vertex shader?

Youâ€™re probably right and youâ€™d be better off using Eugeneâ€™s procedural vegetation for your needs. My repo, as the title implies, focuses on geom replication as to avoid creating each grass per node, but can be used for trees, rocks, boxes, w/e you need. This came about after watching someoneâ€™s youtube vid of implementing thousands of grass nodes which ranâ€¦ canâ€™t remember, maybe 15 fps.

But why? I mean, iâ€™m not looking for procedural generation. Iâ€™m creating my vegetation assets by hand and i just want to add the wind effect to them.

Itâ€™ll be sweet if you can write a shader for the wind effect. Iâ€™m looking forward to it

Unfortunately, my shader-writing skills go as far as UE4â€™s material editor allows me.

You may try to rewrite my shader or you may generate these vertex data in addition to your geometry.

Iâ€™m also planning to add wind in my game too (in a later moment).
I would use the vertex colors to map the displacement weight for the wind, as it seems to happen in here: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch16.html

@Eugene can you please tell me which additional vertex data you used?

Huh, let me recallâ€¦

Wind system was partially stolen from Unity.
The wind consists of the following parts:

1. Main wind controls tree bending caused by wind.
`main_wind = main_magnitude + oscillation_magnitude * wave_function(time * oscillation_frequency)`
2. Turbulence controls branches waving up-down.
3. Foliage waving is somehow computedâ€¦

Then, vertex parameters:

1. Base magnitude controls the influence of main wind. Magnitude is zero at the ground.
2. Turbulence magnitude and frequency control the influence of turbulence wind. Magnitude is zero at the trunk.
3. Foliage oscillation magnitude and frequency control the intensity of leaves trembling. Magnitude is zero at the branch.
4. True normal of geometry used to wave leaves. If you donâ€™t use normal hacks for better foliage shading, you may just use normals instead.
1 Like

If you just need basic wind effect on your vegetation, thereâ€™s already one example available that comes with the default materials and options in shader (Vegetation.glsl/hlsl), which should be enough, unless youâ€™re looking for something else or better.

1 Like

Iâ€™m using CryEngineâ€™s technique for painting wind effect strength on vertexes: http://docs.cryengine.com/display/SDKDOC2/Detail+Bending

Iâ€™ m going to try to modify the mushroom to read that info when applying wind. Thanks for the tip.

2 Likes

Hi @darkirk