1
2 Shader
"Hidden/Dof/Bokeh34" {
3 Properties {
4     _MainTex (
"Base (RGB)", 2D) = "white" {}
5     _Source (
"Base (RGB)", 2D) = "black" {}
6 }
7
8 SubShader {
9     CGINCLUDE
10
11     #include
"UnityCG.cginc"
12     
13     sampler2D _MainTex;
14     sampler2D _Source;
15     
16     uniform half4 _ArScale;
17     uniform half _Intensity;
18     uniform half4 _Source_TexelSize;
19     
20     
struct v2f {
21         half4 pos : SV_POSITION;
22         half2 uv2 : TEXCOORD0;
23         half4 source : TEXCOORD1;
24     };
25     
26     #define COC bokeh.a
27     
28     v2f vert (appdata_full v)
29     {
30         v2f o;
31         
32         o.pos = v.vertex;
33                 
34         o.uv2.xy = v.texcoord.xy;
// * 2.0; <- needed when using Triangles.js and not Quads.js
35         
36         #
if UNITY_UV_STARTS_AT_TOP
37             float4 bokeh = tex2Dlod (_Source, half4 (v.texcoord1.xy * half2(
1,-1) + half2(0,1), 0, 0));
38         #
else
39             float4 bokeh = tex2Dlod (_Source, half4 (v.texcoord1.xy,
0, 0));
40         #endif
41         
42         o.source = bokeh;
43
44         o.pos.xy += (v.texcoord.xy *
2.0 - 1.0) * _ArScale.xy * COC;// + _ArScale.zw * coc;
45         o.source.rgb *= _Intensity;
46                                 
47         
return o;
48     }
49     
50     
51     half4 frag (v2f i) : SV_Target
52     {
53         half4 color = tex2D (_MainTex, i.uv2.xy);
54         color.rgb *= i.source.rgb;
55         color.a *= Luminance(i.source.rgb*
0.25);
56         
return color;
57     }
58     
59     ENDCG
60
61     Pass {
62         Blend OneMinusDstColor One
63         ZTest Always Cull Off ZWrite Off
64
65         CGPROGRAM
66         
67         #pragma target
3.0
68         #pragma vertex vert
69         #pragma fragment frag
70         
71         ENDCG
72     }
73
74 }
75
76 Fallback off
77
78 }


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