How it works...

This recipe not only introduces grab passes, but also Vertex and Fragment Shaders; for this reason, we have to analyze the shader in detail.

So far, all the code has always been placed directly in the SubShader section. This is because our previous shaders required only a single pass. This time, two passes are required. The first one is the GrabPass{}, which is defined simply by GrabPass{}. The rest of the code is placed in the second pass, which is contained in a Pass block.

The second pass is not structurally different from the shader shown in the first recipe of this chapter; we use the vertex function, vert, to get the position of the vertex, and then we give it a color in the Fragment function frag. The difference is ...

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.