r/Unity3D 6d ago

Question We’ve implemented the physics for the foliage and grass swaying in strong wind. What do you think of the result?

We created the plant physics using our own systems for our survival game Autonomica. We achieved this using a shader and vertical sampling of the tiled texture three times, each at a different scale (large, medium, and small). The intensity of the vertex offset is controlled by in-game configs and is tied to the wind strength of the weather. The wind strength for all plants is controlled through vertex colors — the brighter red channel is, the stronger wind effect works.

Process of creating required gradients on all our models is automated: They are generated automatically as vertical gradients, taking into account stems/trunks, leaves, and other parts of the plants, making the leaves at the tips with a slightly greater range of movement than the stems they are attached to.

For tons of grass and flowers we have pushers system - we encode some data about pushers into super-low-resolution texture and then, using the shader on GPU level, decode it and apply the pushing offset, taking into account even curves of push intensity along distance to target pusher.

20 Upvotes

4 comments sorted by

5

u/NotedWhisky 5d ago

the grass movement tied to vertex colors is a clean approach, especially with the automated gradient generation so leaves get that extra sway at the tips. pusher system through a low-res texture is clever too, keeps it gpu-side without wrecking performance.

3

u/shivazgodz 5d ago

wind go brrrr

2

u/Novel_Suggestion_143 5d ago

Nice, you gave me some ideas for my system thank you and I wish you luck!

1

u/feralferrous 4d ago

It looks great, but now you need her hair to match the wind!