Search Unity

Is it possible to have 2 gameObjects with the same shader, but different shader options

Discussion in 'Shaders' started by claudiorodriguescampos, Feb 16, 2019.

  1. claudiorodriguescampos

    claudiorodriguescampos

    Joined:
    Jun 23, 2017
    Posts:
    98
    I use a special shader that can color some texture parts.
    I use this shader to change the color from one object from green to red, but I want to use this same shader to change another game object that is duplicated from the first game object from green to blue.

    The problem is when I change the shader options, both game objects have their color changed. Is it possible to use the same shader but with different options for each game object?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Sure. That's what materials are.

    Technically you have two objects with one material. You can make a copy of the material asset and use that, which will use the same shader with different properties.
     
  3. claudiorodriguescampos

    claudiorodriguescampos

    Joined:
    Jun 23, 2017
    Posts:
    98
    I understand now, I duplicate the material and set the shader with different properties. Now I have 2 gameObjects with different colors.
    Thank @bgolus.