How to do it...

To use a grab pass, you need to follow these steps:

  1. Remove the Properties section, and the Input section; this shader will not use any of them.
  2. In the SubShader section, remove everything, and add the following to ensure the object is treated as being Transparent:
Tags{ "Queue" = "Transparent" }
  1. Then, below that, add a grab pass:
GrabPass{ }
  1. After the GrabPass, we will need to add this extra pass:
Pass {  CGPROGRAM  #pragma vertex vert  #pragma fragment frag  #include "UnityCG.cginc"  sampler2D _GrabTexture;  struct vertInput   {    float4 vertex : POSITION;  };  struct vertOutput   {    float4 vertex : POSITION;    float4 uvgrab : TEXCOORD1;  };  // Vertex function  vertOutput vert(vertInput v)   {    vertOutput o; o.vertex = mul(UNITY_MATRIX_MVP, ...

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.