Archive 17/01/2023.

Vegetation movement with wind

darkirk

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

Victor

Hey there!

Both Lumak and Eugene have excellent examples here:

I hope those are helpful :slight_smile:

darkirk

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?

Lumak

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.

darkirk

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.

Lumak

It’ll be sweet if you can write a shader for the wind effect. I’m looking forward to it :slight_smile:

darkirk

Unfortunately, my shader-writing skills go as far as UE4’s material editor allows me. :frowning:

Eugene

I used procedural generation because wind shader requires additional vertex information.
You may try to rewrite my shader or you may generate these vertex data in addition to your geometry.

Alex-Doc

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?

Eugene

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.
rasteron

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.

darkirk

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.

sampad1370

Hi @darkirk
Are you solve your problem?
I interested to know what result!
thanks you.

darkirk

Nope. I’m still learning about shaders and how to read vertex data such as colors painted in Blender. If i have some real progress, i’ll post here.

sampad1370

Thank you @darkirk
I hope you get fast and good progress in those topic…
best regards.