Using properties in a Surface Shader
Now that we have created some properties, let's actually hook them up to the shader so that we can use them as tweaks to our shader and make the material process much more interactive. We can use the Properties
values from the material's Inspector
tab because we have attached a variable name to the property itself, but in the shader code, you have to set up a couple of things before you can start calling the value by its variable name.
How to do it...
The following steps show you how to use the properties in a Surface Shader:
- Continuing from the previous example, let's create another shader with the name
ParameterExample
. Just like before, remove the_MainTex
property in the same manner as was done in the Adding properties to a shader recipe of this chapter:
// Inside the Properties block _MainTex ("Albedo (RGB)", 2D) = "white" {} // Below the CGPROGRAM line sampler2D _MainTex; // Inside of the surf function fixed4 c = tex2D (_MainTex, IN.uv_MainTex)...