Last active
August 20, 2024 10:33
-
-
Save keijiro/22cba09c369e27734011 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Hi i collected useful material property drawers here:
https://gist.github.com/smkplus/2a5899bf415e2b6bf6a59726bb1ae2ec