1 // Upgrade NOTE: replaced '_Projector' with 'unity_Projector'
2 // Upgrade NOTE: replaced '_ProjectorClip' with 'unity_ProjectorClip'
3
4 Shader "Projector/Light" {
5 Properties {
6 _Color ("Main Color", Color) = (1,1,1,1)
7 _ShadowTex ("Cookie", 2D) = "" {}
8 _FalloffTex ("FallOff", 2D) = "" {}
9 }
10
11 Subshader {
12 Tags {"Queue"="Transparent"}
13 Pass {
14 ZWrite Off
15 ColorMask RGB
16 Blend DstColor One
17 Offset -1, -1
18
19 CGPROGRAM
20 #pragma vertex vert
21 #pragma fragment frag
22 #pragma multi_compile_fog
23 #include "UnityCG.cginc"
24
25 struct v2f {
26 float4 uvShadow : TEXCOORD0;
27 float4 uvFalloff : TEXCOORD1;
28 UNITY_FOG_COORDS(2)
29 float4 pos : SV_POSITION;
30 };
31
32 float4x4 unity_Projector;
33 float4x4 unity_ProjectorClip;
34
35 v2f vert (float4 vertex : POSITION)
36 {
37 v2f o;
38 o.pos = mul (UNITY_MATRIX_MVP, vertex);
39 o.uvShadow = mul (unity_Projector, vertex);
40 o.uvFalloff = mul (unity_ProjectorClip, vertex);
41 UNITY_TRANSFER_FOG(o,o.pos);
42 return o;
43 }
44
45 fixed4 _Color;
46 sampler2D _ShadowTex;
47 sampler2D _FalloffTex;
48
49 fixed4 frag (v2f i) : SV_Target
50 {
51 fixed4 texS = tex2Dproj (_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
52 texS.rgb *= _Color.rgb;
53 texS.a = 1.0-texS.a;
54
55 fixed4 texF = tex2Dproj (_FalloffTex, UNITY_PROJ_COORD(i.uvFalloff));
56 fixed4 res = texS * texF.a;
57
58 UNITY_APPLY_FOG_COLOR(i.fogCoord, res, fixed4(0,0,0,0));
59 return res;
60 }
61 ENDCG
62 }
63 }
64 }