Implementing a water shader for 2D games
The glass shader that we introduced in the previous recipe is static; its distortion never changes. It takes just a few changes to convert it into an animated material, making it perfect for 2D games that feature water. This recipe uses a similar technique to the one shown in Chapter 6, Using Vertex Functions, in the Animating vertices in a Shader Graph recipe:

Figure 7.12 – The result of the following recipe
Getting ready
This recipe is based on the vertex and fragment shaders described in the Using grab passes to draw behind objects recipe, as it will rely heavily on the use of grab passes. Let’s get started:
- Create a new Shader Graph. You can start by copying the one that we used in the previous recipe (Using grab passes to draw behind objects) as a base by selecting it and hitting Ctrl + D to duplicate it.
- Once duplicated, change its name to
2DWaterShader. - Create a material that will...