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