Question by
CodeVector · Jun 20, 2020 at 10:41 PM ·
shaderruntime
Toggle shader Pass at runtime
Hi everyone. I am new in shader scripting and i made my first today. It's like an xray shader. My problem is the following : I want to use a toggle named _Xray (stored in Properties) in the first pass but i cant at outside of an CGPROGRAM. There is my shader script :
Properties
{
_Visible ("Visible Color", Color) = (1,1,1,1)
_Unvisible ("Unvisible Color", Color) = (1,1,0,1)
[Toggle(ENABLE_XRAY)] _Xray ("Xray", Float) = 1
}
SubShader
{
Tags {"Queue" = "Geometry+1" "IgnoreProjector" = "True"}
// I talk about this pass.
Pass
{
ZTest Greater
ZWrite Off
Color [_Unvisible]
}
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float4 color : COLOR;
};
uniform float3 _Visible;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = _Visible;
}
ENDCG
}
I want the first pass to be called only if ENABLE_XRAY is true. And this toggle can change at runtime. If anyone can help me... Thanks in advance and sorry for my bad english !
Comment