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 5, Physically-Based Rendering. We already know how to make our glasses semi-transparent to show the objects behind it perfectly and that works for a number of applications. However, most glasses are not perfect. For instance, if you look through a stain glass window you may notice distortions or deformations when you look through them. This recipe will teach you how to achieve that effect. The idea behind this effect is to use a Vertex and Fragment Shader with a GrabPass, and then sample the grab texture with a little change to its ...

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.