+1 vote

As in game Breath of the Wild or Horizon Zero Dawn,
you can see the grass will have reaction when player pass through them

How can I make the similiar effect in Godot?


in Engine by (241 points)

4 Answers

+1 vote
Best answer

Take a look at this. The last part of the page shows a way to simulate object-grass interaction. It basically shows that you can simulate great displacement with shaders. Just like how you would with wind(as the other answer has shown).
Pass the position of the interacting object into shader (in world space), calculate the vector from that position to the grass vertex (also in world space), and finally displace the vertex along that vector.

by (3,857 points)
selected by

How can I pass the position of the interacting object to the grass shader?
Should I pass it for all grass in each frame?
Or in other way?

Thank you!

Just pass the global position of the interacting object to your grass's shader every frame. Or else when the body moves, it won't be consistent with the grass.

+1 vote

You have to apply collision to grass and change it's rotation (based on direction) when player collides (step, roll etc.). That's something you could expect from AAA games, I don't think that Godot is capable of processing that amount of calculation without massive performance drop. You could optimize it by enabling collision at run-time when player is near grass, so CPU won't have to calculate grass that is on the other side of map.

by (378 points)
+1 vote

First, take a look at this shader asset:

Godot Simple Wind Shader 2D - Video Demo
Godot Simple Wind Shader 2D - Source

Just to give an idea, I think you can achieve what you want by modifying/creating some of the shader's uniform variables to rotate/bend/scale the grass from player's script, though I don't know how to implement it.

by (1,342 points)
0 votes

this video is helpful

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.