O'Reilly logo

Unity Shaders and Effects Cookbook by Kenny Lammers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using properties in a Surface Shader

Now that we have created some properties, let's actually hook them up to the Shader so 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 a couple things up 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:

  1. To begin, let's remove the following lines of code, as we deleted the property called MainTex in the Creating a basic Surface Shader recipe of this chapter:
    sampler2D _MainTex; half4 c = tex2D (_MainTex, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required