Shaders and materials

Materials and shaders determine how your 3D objects look, so it is important to know what they do, and how they can be optimized.

A shader is a small program that tells the GPU how to draw an object on the screen. A shader tells the GPU every calculation that must happen to the object. A shader can only be used when it is attached to a material.

For writing shaders, there are two common scripting languages: High-Level Shading Language (HLSL) and OpenGL Shading language (GLSL).

A material is something that can be applied to an object, or mesh, to define the visual look of that object. A material is used to set the specific value of parameters that are made available from a shader. Examples of these parameters include colors, textures, and number values.

The following screenshot shows an HLSL shader applied to a material in Unity:


Unity also provides shader graphs, which let you build your shaders visually instead of hand-writing code. The following screenshot shows how you can build a shader graph by creating and connecting nodes in a graph network, then apply that shader graph to a material:

Previous Next