this time i'm breaking down my water shader!
#gamedev #indiedev #shaders #madewithunity
there are lots of good stylized water tutorials out there, like this one by @minionsart : so i'm just going focus on what's different
![](https://pbs.twimg.com/media/DdGa4-PU8AAhIXn.jpg)
![](https://pbs.twimg.com/media/DdGcFIqVMAAqw4o.jpg)
![](https://pbs.twimg.com/media/DdGcjgzVwAA7nEZ.jpg)
![](https://pbs.twimg.com/media/DdGc5L4V0AEKoJn.jpg)
the shader takes two scrolling normal maps and blends them together in a way that better preserves detail than just learping or adding them.
the reflection is code is just copied from unity's standard shader
![](https://pbs.twimg.com/media/DdGdCyMUQAAJGRm.jpg)
![](https://pbs.twimg.com/media/DdGdG4fVQAAH8vv.jpg)
![](https://pbs.twimg.com/media/DdGdK79UwAAJUrk.jpg)
we can get a texture with everything that has already been drawn to the screen using a grab pass: docs.unity3d.com/Manual/SL-Grab…
now we can sample from this texture using distorded uvs based on our normals
![](https://pbs.twimg.com/media/DdGdjqjU8AEGpFf.jpg)
![](https://pbs.twimg.com/media/DdGd0-WU8AAz88d.jpg)
![](https://pbs.twimg.com/media/DdGeAP7VAAAbBdy.jpg)
more detail in there, but basically these are sine waves that are pinched towards the peaks so you get some nice undulation on the surface
here i just have particles write the ripple height into the blue channel and then use that heightmap to deform the verts and normals of the water