What is a Shader?

From Shader Forge Wiki
Jump to: navigation, search

A shader is a piece of code, a set of instructions, that your graphics card is processing in real-time, when you're running your game. Shaders usually read a lot of data, such as the positioning of your lights, the textures you provide, and more.

It's important to note the difference between shaders, materials, and textures, so here's a little guide for how it works in Unity:

  • Shaders are used by Materials, to know which properties to expose, as well as what and how to render it on the GPU.
  • Materials are pre-configured setups of a shader, which are applied to the objects in your game.
  • Textures are 2D images, commonly used as properties in Materials

So in short - objects have textures and settings assigned to their material, which look and properties are defined by its shader


To change the shader of a material in Unity, select your material, and you should see a drop-down button at the top of the inspector. Click that, and you'll get a list of all the available shaders in your project. Shader Forge will put shaders in the Shader Forge/ category by default.

Multiple objects can use the same materials, and multiple materials can use the same shader. Objects that react similarly to light, should share the same shader, but may not share the same material. For instance, if you have a shader to render a set of rubber balls, you may want to use different textures or colors, but you'll want the same type of shading on all of them.

However, if you have a metal ball, that one will most likely need a cubemap, which may be something you want in another shader, as the rubber balls are most likely too diffuse to justify the usage of a cubemap.