How to do it...

With our scene, shader, and material created and ready to go, we can begin to write the code for our shader. Launch the shader by double-clicking on it in the Project tab in the Unity editor. Perform the following steps:

  1. As we are creating a very simple shader, we will not need to include any properties in our Properties block. We will still include a Global Color Tint, just to stay consistent with the other shaders in this book. Enter the following code in the Properties block of your shader:
Properties{  _MainTint("Global Color Tint", Color) = (1,1,1,1)}
  1. This next step tells Unity that we will be including a vertex function in our shader:
CGPROGRAM#pragma surface surf Lambert vertex:vert
  1. As usual, if we have included ...

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.