Sand Shader Unity URP For Mobile by TheodorKnab - 1

MobileShaders & Effects

Mobile friendly Unity sand/snow shader using the Universal Render Pipeline

Unity 2020.1.2f1MIT LicenseUpdated 61 days agoCreated on August 22nd, 2020
Go to source

Sand Shader - in Unity URP for Mobile Phones

Demo tested on a OnePlus 3T, runs at 55 - 60 FPS

Sand Demo

Demo Scene

In the demo scene (Assets/Scenes/Main.unity) you can spawn stones or a rake via the buttons.

  • Left click / touch: drag object
  • Long left click / touch: pick up object

Effect Setup

This effect uses multiple shaders and materials, as multipass shaders are to my understanding currently not available in Unity SRPs. Those multiple materials/shaders need to be controlled by a script. (Done in Assets/Scripts/Sand/DrawDepth.cs)

How it works:

  • A depth texture is created from the underside of all movable objects and stored in a render texture.
Sand Demo
  • From this texture a difference texture is created, with the (stored) depth texture of the previous frame.
  • This difference texture gets blured.

  • The blured difference texture now gets subtracted from the existing sand depth texture.
  • The depth texture from the beginning gets added to the sand depth texture.

This texture is saved as the new sand depth texture.

  • The texture gets blured again. This texture is then used by the actual sand shader.

  • The actual sand shader uses the depth map to modify the normals of the material. No actual displacement of the geometry happens.

License

License

Show all projects by TheodorKnab