How to make standard shader to grayscale?

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: Unity-Built-in-Shaders/DefaultResourcesExtra/Standard.shader at master · TwoTailsGames/Unity-Built-in-Shaders · GitHub

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

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:

float4 col = tex2D(_MainTex, IN.uv_MainTex);
col.rgb = (0.299 *col.r) + (0.587 * col.g) + (0.114 * col.b); //Rough human eye adjusted grayscale computation
o.Albedo = col.rgb;
1 Like

Thank you.