Implementing a Glass Shader
Glass is a very complicated material; it should not be a surprise that other chapters have already created shaders to simulate it in the Adding transparency to PBR recipe of Chapter 4, Creating Test Cases and Writing Scenarios for Behavior Driven Development in Symfony. However, there is an effect that transparency cannot reproduce deformations. Most glasses are not perfect, hence they create distortions when we look through them. This recipe will teach you how to do this. The idea behind this effect is to use a Vertex and Fragment Shader with a grab pass, and then sample the grab texture with a little change to its UV data to create a distortion. You can see the effect in the following image, using the glass-stained textures from the Unity Standard Assets:

Getting ready
The setup for this recipe is similar to the one presented in the previous chapter:
Create new Vertex and Fragment Shaders. You can start by copying the one used in the previous recipe, Using grab...