Here are the Unity files for a cool approach to generate visual environmental interactions, like water ripples and mud/snow trails. It uses a top-down camera to draw a bunch of particles to a global render texture, which is then referenced in any shader that wants to implement any of these effects.
I'm drawing blue water ripples (so the water shader just uses the B channel) and green mud trails (so the ground shader uses the G channel). The shaders then use that to generate a normal texture. I've added tesselation and displacement to the water, but it looks fine with just a normal map if you want to save on that.
I'm really excited about this technique, I've only just started playing with it and it's just scratching the surface of what this approach can do. I want to use it to make 'Breath of the Wild' style grass that you can push out of the way, flatten as you walk over it, and cut arbitrarily. It would also be good for cheap blob shadows, foot prints, rain drops interaction, you name it. Manually placing down quads with custom animated textures is a cool way to add stuff like waterfall splashes, shoreline ripples, whirlpools etc.
Other things to explore would include drawing velocity in the particle shaders. Or instead of using particles, draw depth comparisons for more subtle interactions between the ground and objects that come close. I also think it might be cool to use a separate water ripple calculation shader pass instead of using particles, so that the ripples can bounce off other surfaces.
You could also render the depth fade of the water/ground geometry intersection and use that to add automatic shoreline ripples to the water. I can't wait to play more with it!
Let me know if you have any ideas on how this can be extended or improved.
FILE INFO: The scene should work out of the box if you import it, but it's a good idea to manually set a Ground layer on the ground collider and on the individual EnvironmentInteractionColliders. These OnTriggerStay updates are used to test when the entity is touching the ground, although you could use your own isGrounded checks or raycasts if you prefer.
Puck Loves Games
2018-12-12 11:34:03 +0000 UTC