Shader "Smkgames/Sprite" { Properties { [Header(Main Color)] [Toggle] _UseColor("Enabled?", Float) = 1 _Color("Main Color", Color) = (1,1,1,1) [Space(5)]
[Header(Base(RGB))]
[Toggle] _UseMainTex("Enabled?", Float) = 1
_MainTex("Base (RGB)", 2D) = "white" {}
//[NoScaleOffset] _MainTex("Base (RGB)", 2D) = "white" {}
[Space(5)]
[Header(Blend State)]
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend", Float) = 1 //"One"
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DestBlend", Float) = 0 //"Zero"
[Space(5)]
[Header(Other)]
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4 //"LessEqual"
[Enum(Off,0,On,1)] _ZWrite("ZWrite", Float) = 1.0 //"On"
[Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorWriteMask("ColorWriteMask", Float) = 15 //"All"
}
SubShader
{
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
LOD 100
Blend[_SrcBlend][_DstBlend]
ZTest[_ZTest]
ZWrite[_ZWrite]
Cull[_Cull]
ColorMask[_ColorWriteMask]
Pass {
CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma fragmentoption ARB_precision_hint_fastest #include "UnityCG.cginc"
struct appdata_t { float4 vertex : POSITION; float4 color : COLOR; float2 texcoord : TEXCOORD0; };
struct v2f { half2 texcoord : TEXCOORD0; float4 vertex : SV_POSITION; fixed4 color : COLOR; };
sampler2D _MainTex; fixed4 _Color; float _Speed; float _UseColor; float _UseMainTex;
v2f vert(appdata_t IN) { v2f OUT; OUT.vertex = UnityObjectToClipPos(IN.vertex); OUT.texcoord = IN.texcoord; OUT.color = IN.color; return OUT; }
float4 frag (v2f i) : COLOR {
float2 uv = i.texcoord.xy; float4 tex = lerp(float4(1,1,1,1),tex2D(_MainTex, uv)*i.color,_UseMainTex);
return lerp(tex,tex*_Color,_UseColor); } ENDCG } } Fallback "Sprites/Default" }
//Culling //https://gist.github.com/TJHeuvel/c4f8d218a0d774682560a8f348a90dff#comments
//Blending Description
// // Normal // Blend SrcAlpha OneMinusSrcAlpha // // // Soft Additive // Blend OneMinusDstColor One // // // Multiply Blend DstColor Zero // // // 2x Multiply // Blend DstColor SrcColor // // // Darken // BlendOp Min // Blend One One // When using Min operation, these factors are ignored // // // Lighten // BlendOp Max // Blend One One // When using Max operation, these factors are ignored // // // Screen // Blend OneMinusDstColor One // Or // Blend One OneMinusSrcColor // // // Linear Dodge // Blend One One
hey I just want to say this is exactly what I needed and I love you for putting that helpful graphic together