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.
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.
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.
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!
icqqq | 2018-09-22 04:13
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.