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

Adding properties to a Surface Shader

Properties of a Shader are very important to the Shader pipeline, as they are the method you use to let the artist or user of the Shader assign textures, and tweak your Shader values. Properties allow you to expose GUI elements in a Material's Inspector tab without you having to use a separate editor, which provides visual ways to tweak a Shader.

With your Shader opened in MonoDevelop, look at the block of lines 3 through 6. This is called the Properties block. Currently, it will have one property in it called _MainTex. If you look at your Material that has this Shader applied to it, you will notice that there is one texture GUI element in the Inspector tab. These lines of code, in our Shader, is creating ...

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