Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Shaders vs Materials

Discussion in 'Editor & General Support' started by MoistDumpling14, Feb 13, 2019.

  1. MoistDumpling14

    MoistDumpling14

    Joined:
    Sep 8, 2018
    Posts:
    139
    Hey everyone, I wanted some easy clarification on what the difference between a shader and a material is. I believe from what I have read on the documentation, a material is the actual pixels on an object and a shader is a small script that determines how those pixels react to the light. Are shaders just automatically run in Unity whenever you drag a material on an object?
     
  2. Materials have the settings called "shader", so if you choose a material, you choose a shader. You can find it right on the top, under the name of the material.

    Inspector-MaterialSimple.png

    Material is a bunch of parameters (colors, numbers, images and maps /which are also images/) together. Shader is the piece of code which applies these parameters on the thing you render on a way which is usually predetermined.
     
    samarth-robo and MoistDumpling14 like this.
  3. MoistDumpling14

    MoistDumpling14

    Joined:
    Sep 8, 2018
    Posts:
    139
    Cool, so I noticed there are some other options you can choose for shaders in the properties window. What do those mean, does it just render the material differently?
     
  4. RTXRishu

    RTXRishu

    Joined:
    Feb 24, 2019
    Posts:
    6
    @MoistDumpling14, your definition is actually pretty close.

    The material isn't what determines how the mesh's surface will look like; the shader is what does it.

    A material is just something that holds a shader, like an encapsulator. The shader's public variables are shown as parameters on the material.

    To apply a shader to a mesh, you must put it in a material and apply that material to the mesh, is all.