NokiMo
pucklovesgames
pucklovesgames

patreon


Environment Interaction via RenderTexture FILES

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.

Environment Interaction via RenderTexture FILES

Comments

This is fantastic. Thank you so much for sharing this. Its perfect for a project im currently working on. Great Work.

Thanks! Okay, I've uploaded those custom functions InteractiveEnvironmentUVs.asset NormalCreateB.asset NormalCreateG.asset The missing prefab is probably a light projector that I ended up not using anyway, so it's okay that it's missing (I think!). I was playing with piping the water ripples in to the projector to create a light caustics effect underwater. It looked pretty cool, but I think it would probably be better just to do that in the ground shader itself perhaps.

Puck Loves Games

Awesome post!, Really interested at looking into this. Are you able to post the custom functions (NormalCreateG and InteractiveEnvironmentUVs) inside the shader so I can go through it without it breaking? They are missing in the package. There is also a prefab missing in the scene file :)


Related Creators