Built-in Shader Guide
Reference Manual > Built-in Shader Guide

Built-in Shader Guide

If you're looking for the best information for using Unity's built-in shaders, you've come to the right place. Unity includes more than 30 built-in shaders, and of course you can write many more on your own! This guide will explain each family of the built-in shaders, and go into detail for each specific shader. With this guide, you'll be able to make the most out of Unity's shaders, to achieve the effect you're aiming for.

Using Shaders

Shaders in Unity are used through Materials, which essentially combine shader code with parameters like textures. An in-depth explanation of the Shader/Material relationship can be read here. The rest of this section will explain how to adjust Material properties through the Inspector.

Material Inspector

Material properties will appear in the Inspector when either the Material itself or a GameObject that uses the Material is selected. The Material Inspector looks like this:

Each Material will look a little different in the Inspector, depending on the specific shader it is using. The shader iself determines what kind of properties will be available to adjust in the Inspector. Fundamentally, all shaders will expose common controls: Color Selectors, Sliders, Texture selectors, and Placement controls.

Remember that a shader is implemented through a Material. So while the shader defines the properties that will be shown in the Inspector, each Material actually contains the adjusted data from sliders, colors, and textures. The most important thing to remember about this is that a single shader can be used in multiple Materials, but a single Material cannot use multiple shaders.

Color Selectors

Some shaders will apply a color to the whole or parts of a GameObject. A good example of this is the Specular shader, which takes a Main Color and a Specular Color. The Main Color will be applied to all areas of the Object, while the Specular Color controls the color of the specular highlight. Any Color Selector property in a Material can be adjusted by clicking on the colored box to the right of the property name.

When the color box is clicked, the Color Selector appears. It looks like this:

To change the property's color, simply adjust the brightness slider on the right, and choose a hue & saturation from the wheel. You can also use any of the other color selecting methods if you prefer.

The Opacity slider in color selector controls transparency of the color. This can be used to control opacity of Transparent shaders, or for some special effects like glow.

Sliders

Some shader properties have a numeric value that can be changed. This value can also be expressed as "minimum" to "maximum". For these types of properties, a slider is presented.

On a property slider, the left-most point is Minimum, and the right-most point is Maximum. By dragging the slider left and right, you can see the real-time effect on the object in your Scene or Game Views, and find a good point that is right for the effect you're trying to achieve.

A good example of the slider is for the Shininess property of any Specular shader.

Textures & Bumpmaps

Texture assets are used as shader properties as well. If you want to use a texture to wrap around your mesh object, you will drag the texture file itself to the Base property. It will be applied to the object, adhering to any UV maps you have created for the mesh. For more information on using textures, please view the Textures page of the User Manual.

This is what a Texture shader property looks like when it is empty.

This is what a shader's Texture property looks like when it has a file texture applied.

Any Bumpmapped shader will also use a Bumpmap property which accepts a texture in the form of a Normal map. Unity can convert any heightmap texture to a Normal map when it is imported. For more information on how to do this, please view the Bumpmap FAQ page of the User manual.

Placement

You have the ability to scale or scroll any texture in a shader. To do this you will adjust the Placement properties of that asset.

When you click the Placement button, the Offset and Tiling properties will appear. You can adjust these properties in the Inspector or via a script.

A texture scaled to 2

A texture offset by 0.25

Individual Shaders