I have a surface shader that has a main texture, and an alpha mask. (not just opacity value, but independent alpha mask that can be moved seperatly)
How can I get this to not interact with lights and be unlit?
Shader "Custom/CanvasWithAlphaMask" {
Properties {
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Main Color", Color) = (0,0,0,0)
_Stencil("Stencil Texture (RGB)", 2D) = "white" {}
}
Subshader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="False"
"RenderType"="Transparent"
}
Lighting Off //doesn't do anything
CGPROGRAM
#pragma surface surf Lambert alpha
struct Input {
float2 uv_MainTex;
};
half4 _Color;
sampler2D _MainTex;
sampler2D _Stencil;
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a - tex2D(_Stencil, IN.uv_MainTex).a ;
}
ENDCG
}
}
Putting Lighting Off before CGPROGRAM didn’t work , I thought it might be that simple.
Alternatively, if its easier, is there a way to use non-surface shader to achieve the same effect?
Just a thought, if lighting is applied in the vertex/fragment functions and the default functions apply lighting, it would explain why you are still getting lighting applied. Writing basic custom vertex/fragment functions would solve the problem if this is the case.
– The-IT664Ok thanks, I will look into translating the surface shader part to a vertex/fragment setup
– dchen05In your subshader add the following: Lighting Off This will disable lighting without having to manually write a vertex and fragment shader. Hope this helps!
– OP_tossThanks @OP_toss, but that doesn't work for some reason. I read a similar question around here that had that as the answer, but no dice.
– dchen05