Book Image

Unity 5.x Shaders and Effects Cookbook

By : Alan Zucconi
Book Image

Unity 5.x Shaders and Effects Cookbook

By: Alan Zucconi

Overview of this book

Since their introduction to Unity, Shaders have been notoriously difficult to understand and implement in games: complex mathematics have always stood in the way of creating your own Shaders and attaining that level of realism you crave. With Shaders, you can transform your game into a highly polished, refined product with Unity’s post-processing effects. Unity Shaders and Effects Cookbook is the first of its kind to bring you the secrets of creating Shaders for Unity3D—guiding you through the process of understanding vectors, how lighting is constructed with them, and also how textures are used to create complex effects without the heavy math. We’ll start with essential lighting and finishing up by creating stunning screen Effects just like those in high quality 3D and mobile games. You’ll discover techniques including normal mapping, image-based lighting, and how to animate your models inside a Shader. We’ll explore the secrets behind some of the most powerful techniques, such as physically based rendering! With Unity Shaders and Effects Cookbook, what seems like a dark art today will be second nature by tomorrow.
Table of Contents (16 chapters)
Unity 5.x Shaders and Effects Cookbook
Credits
About the Authors
www.PacktPub.com
Preface
Index

Using grab pass


In the Adding transparency to PBR recipe of Chapter 4, Creating Test Cases and Writing Scenarios for Behavior Driven Development in Symfony, we have seen how a material can be made transparent. Even if a transparent material can draw over a scene, it cannot change what has been drawn underneath it. This means that those Transparent Shaders cannot create distortions such as the ones typically seen in glass or water. In order to simulate them, we need to introduce another technique called grab pass. This allows us to access what has been drawn on screen so far so that a shader can use it (or alter it) with no restrictions. To learn how to use grab passes, we will create a material that grabs what's rendered behind it and draws it again on the screen. It's a shader that, paradoxically, uses several operations to show no changes at all.

Getting ready

This recipe requires the following operations:

  1. Create a shader that we will initialize later.

  2. Create a material to host the shader...