Hi everyone, I have a simple grayscale shader, which does not receive shadows. I've tried a few solutions I found with no success. Does someone know how my shader can take into account shadows? Here it is : Code (CSharp): Shader "Custom/GreyScale" { Properties{ _MainTex("Texture", 2D) = "white" { } _Factor("Factor", Range(0, 1.0)) = 0.6 } SubShader{ Tags { "RenderType" = "Opaque" } LOD 150 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _MainTex; float _Factor; struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; }; float4 _MainTex_ST; v2f vert(appdata_base v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); return o; } half4 frag(v2f i) : COLOR { half4 texcol = tex2D(_MainTex, i.uv); texcol.rgb = dot(texcol.rgb, float3(0.3, 0.59, 0.11)) * _Factor; return texcol; } ENDCG } } Fallback "Diffuse" } Thanks
Hi, Did you check the manual? (Vertex and fragment shader examples) https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html There's a section called "Receiving shadows". It's almost a step by step guide on how to add basic shadows to a vert/frag shader. If you get stuck you can ask for more help.