Skip to content

Instantly share code, notes, and snippets.

@yuna0x0
Forked from keijiro/ToggleTest.shader
Created May 4, 2022 07:37
Show Gist options
  • Save yuna0x0/3b4bf42d9ef7eef22e1623bd98eac1c3 to your computer and use it in GitHub Desktop.
Save yuna0x0/3b4bf42d9ef7eef22e1623bd98eac1c3 to your computer and use it in GitHub Desktop.
Shows how to use the Toggle material property drawer in a shader. See the reference manual for further details: http://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html
Shader "ToggleTest"
{
Properties
{
[Toggle(FILL_WITH_RED)]
_FillWithRed ("Fill With Red", Float) = 0
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma shader_feature FILL_WITH_RED
#include "UnityCG.cginc"
float4 vert(appdata_base v) : POSITION
{
return mul(UNITY_MATRIX_MVP, v.vertex);
}
half4 frag(float4 position : POSITION) : SV_Target
{
#ifdef FILL_WITH_RED
return float4(1, 0, 0, 1);
#else
return (float4)1;
#endif
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment