Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

How to make standard shader to grayscale?

Discussion in 'Shaders' started by Deleted User, Oct 26, 2019.

  1. Deleted User

    Deleted User


    Hello everyone,

    I have the standard shader code of Unity. I want to make only one object in the scene grayscale while keeping its metallic, normal map etc.

    Here's the code I found:

    I think I need to multiply their RGB somewhere to make it grayscale but I couldn't find where I should put the code due to my knowledge of shaders
  2. Invertex


    Nov 7, 2013
    Do you want the reflections on the object to be grayscale as well? Or only its albedo?

    Also, that isn't the code you want to copy if you just want a modified standard shader, what you want to do is create a "Surface shader" and write to the outputs you want to use.

    In the code you linked, you can see the all the ShaderLab inputs you can possibly use from the Standard shading model.

    For making just the material albedo gray once you've got a working Surface shader, you can do this simply like so:

    Code (CSharp):
    1. float4 col = tex2D(_MainTex, IN.uv_MainTex);
    2. col.rgb = (0.299 *col.r) + (0.587 * col.g) + (0.114 * col.b); //Rough human eye adjusted grayscale computation
    3. o.Albedo = col.rgb;
    Daahrien likes this.
  3. Deleted User

    Deleted User


    Thank you.