I have this code:
Shader "Custom/KeywordColorChanger"
{
Properties
{
[Toggle] _Test ("test", Float) = 0
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma shader_feature_local _Test
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col;
col = fixed4(0, 1, 0, 1);
#if _Test
// If the _COLOR_KEYWORD_RED is enabled, use red.
col = fixed4(1, 0, 0, 1);
#endif
return col;
}
ENDCG
}
}
}
and the idea of how this will work is that I can turn _Test on/off from the material inspector.
but the way it is behaving is just that it is always green no matter the toggle value, as in the $if block just isn’t there?
Is there something I misunderstood about shader variants/keywords?