1
2 Shader
"Hidden/MotionBlurClear"
3 {
4
5 Properties { }
6
7 SubShader {
8 Pass {
9     
//ZTest LEqual
10     ZTest Always
// lame depth test
11     ZWrite Off
// lame depth test
12
13     CGPROGRAM
14
15     #pragma vertex vert
16     #pragma fragment frag
17
18     #include
"UnityCG.cginc"
19
20     
struct vs_input {
21         float4 vertex : POSITION;
22     };
23
24     
struct ps_input {
25         float4 pos : SV_POSITION;
26         float4 screen : TEXCOORD0;
27     };
28
29     sampler2D_float _CameraDepthTexture;
30
31     ps_input vert (vs_input v)
32     {
33         ps_input o;
34         o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
35         o.screen = ComputeScreenPos(o.pos);
36         COMPUTE_EYEDEPTH(o.screen.z);
37         
return o;
38     }
39
40     float4 frag (ps_input i) : SV_Target
41     {
42         
// superlame: manual depth test needed as we can't bind depth, FIXME for 4.x
43         
// alternatively implement SM > 3 version where we write out custom depth
44
45         
float d = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screen));
46         d = LinearEyeDepth(d);
47         
48         clip(d - i.screen.z +
1e-2f);
49         
return float4(0, 0, 0, 0);
50     }
51
52     ENDCG
53
54     }
55 }
56
57 Fallback Off
58 }


Gõ tìm kiếm nhanh...