Created
August 10, 2016 13:13
-
-
Save glitchersgames/47fd609f4d315e93e63adcf5d0193d41 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 "Projector/Circle" { | |
Properties { | |
_Color ("Main Color", Color) = (1,1,1,1) | |
_ShadowTex ("Cookie", 2D) = "" {} | |
} | |
Subshader { | |
Tags {"Queue"="Transparent"} | |
Pass { | |
ZWrite Off | |
ColorMask RGB | |
Blend One One | |
Offset -1, -1 | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#pragma multi_compile_fog | |
#include "UnityCG.cginc" | |
struct v2f { | |
float4 uvShadow : TEXCOORD0; | |
UNITY_FOG_COORDS(2) | |
float4 pos : SV_POSITION; | |
}; | |
float4x4 _Projector; | |
float4x4 _ProjectorClip; | |
v2f vert (float4 vertex : POSITION) | |
{ | |
v2f o; | |
o.pos = mul (UNITY_MATRIX_MVP, vertex); | |
o.uvShadow = mul (_Projector, vertex); | |
UNITY_TRANSFER_FOG(o,o.pos); | |
return o; | |
} | |
fixed4 _Color; | |
sampler2D _ShadowTex; | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
float2 polar = (i.uvShadow.xy * 2) - 1.0; | |
float d = length( polar ); | |
if( d > 1 ) | |
{ | |
discard; | |
} | |
fixed4 texS = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(half4( d, 0, i.uvShadow.zw ))); | |
texS.rgb *= _Color.rgb; | |
texS.a = 1.0-texS.a; | |
UNITY_APPLY_FOG_COLOR(i.fogCoord, texS, fixed4(0,0,0,0)); | |
return texS; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment