Created
April 11, 2018 18:57
-
-
Save cfazilleau/3a44f3f3af19e491e0b3cabcc65054b4 to your computer and use it in GitHub Desktop.
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 "Custom/SeeThrough" | |
{ | |
Properties | |
{ | |
[HideInInspector] | |
_MainTex ("Sprite Texture", 2D) = "white" {} | |
_GhostColor ("See-through Color", Color) = (0.2, 0.2, 0.2, 1) | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue"="Transparent" | |
"PreviewType"="Plane" | |
} | |
Cull Off | |
Blend One OneMinusSrcAlpha | |
CGINCLUDE | |
#include "UnityCG.cginc" | |
sampler2D _MainTex; | |
fixed4 _GhostColor; | |
struct appdata_t | |
{ | |
float4 vertex : POSITION; | |
float4 color : COLOR; | |
float2 texcoord : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float4 vertex : SV_POSITION; | |
fixed4 color : COLOR; | |
float2 texcoord : TEXCOORD0; | |
}; | |
#pragma vertex vert | |
v2f vert(appdata_t IN) | |
{ | |
v2f OUT; | |
OUT.vertex = UnityObjectToClipPos(IN.vertex); | |
OUT.texcoord = IN.texcoord; | |
OUT.color = IN.color; | |
return OUT; | |
} | |
ENDCG | |
Pass | |
{ | |
CGPROGRAM | |
#pragma fragment frag | |
fixed4 frag(v2f IN) : SV_Target | |
{ | |
fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color; | |
c.rgb *= c.a; | |
return c; | |
} | |
ENDCG | |
} | |
ZTest Greater | |
ZWrite Off | |
Pass | |
{ | |
CGPROGRAM | |
#pragma fragment frag | |
fixed4 frag(v2f IN) : SV_Target | |
{ | |
fixed4 color = tex2D(_MainTex, IN.texcoord); | |
return _GhostColor * _GhostColor.a * color.a; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment