Get an 20% OFF using the RELEASE code on your book purchase. For a limited time.

Introduction to the shader programming language

3.0.3. ShaderLab Properties

This post is also available in…

These properties correspond to a list of parameters that can be manipulated from the Unity inspector. There are eight different properties both in value ​​and usefulness. We use these properties concerning the shader that we want to create or modify, either dynamically or in execution time. The syntax for declaring a property is as follows:

PropertyName ("display name", type) = defaultValue.

PropertyName” refers to the name of the property (e.g. _MainTex), “display name” corresponds to the name of the property that will be displayed in the Unity inspector (e.g. Texture), “type” indicates the property type (e.g. Color, Vector, 2D, etc.) and finally, as its name implies, “defaultValue” is the default value assigned to the property (e.g. if the property is a “Color” we can set it as white as follows (1, 1, 1, 1)).

(Fig. 021)

If we look at the properties of our USB_simple_color shader we will notice that there is a texture property that has been declared inside of the field, we can corroborate this in the following line of code.

    _MainTex (“Texture”, 2D) = “white” {}

One factor to consider is that when we declare a property, it remains “open” within the field of properties, therefore we must avoid the semi-colon (;) at the end of the code line, otherwise the GPU will not be able to read the program.

Follow us to stay informed about all the latest news, updates, and more.

Join the group to share your experiences with other developers.

Subscribe to our channel and keep learning game dev!


Jettelly Team

We are a team of indie developers with more than 9 years of experience in video games. As an independent studio, we have developed Nom Noms in which we published with Hyperbeard in 2019. We are currently developing The Unity Shader Bible.

Follow us on our social networks.