O'Reilly logo

Unity 5.x Shaders and Effects Cookbook by Kenneth Lammers, Alan Zucconi

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 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:

  1. To begin, let's remove the following lines of code, as we deleted the property called _MainTex in the Creating a basic Standard Shader recipe of this chapter:
    _MainTex ("Albedo (RGB)", 2D) = ...

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