How to do it...

With the scene prepared, we can now begin the process of experimenting with some of the built-in helper functions included with the UnityCG.cginc file. Double-click on the shader that was created for this scene in order to open it in your IDE of choice and insert the code given in the following steps:

  1. Add the following code to the Properties block of the new shader file. We will need a single texture and slide for our example shader:
Properties 
{ 
    _MainTex ("Base (RGB)", 2D) = "white" {} 
    _DesatValue ("Desaturate", Range(0,1)) = 0.5 
} 

We then need to make sure that we create the data connection between our Properties and CGPROGRAM blocks.

  1. Use the following code, placed after the CGPROGRAM declaration and #pragma directives, ...

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.