1 Shader "Hidden/Vignetting" {
2     Properties {
3         _MainTex (
"Base", 2D) = "white" {}
4         _VignetteTex (
"Vignette", 2D) = "white" {}
5     }
6     
7     CGINCLUDE
8     
9     #include
"UnityCG.cginc"
10     
11     
struct v2f {
12         float4 pos : SV_POSITION;
13         float2 uv : TEXCOORD0;
14         float2 uv2 : TEXCOORD1;
15     };
16     
17     sampler2D _MainTex;
18     sampler2D _VignetteTex;
19     
20     half _Intensity;
21     half _Blur;
22
23     float4 _MainTex_TexelSize;
24         
25     v2f vert( appdata_img v ) {
26         v2f o;
27         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
28         o.uv = v.texcoord.xy;
29         o.uv2 = v.texcoord.xy;
30
31         #
if UNITY_UV_STARTS_AT_TOP
32         
if (_MainTex_TexelSize.y < 0)
33              o.uv2.y =
1.0 - o.uv2.y;
34         #endif
35
36         
return o;
37     }
38     
39     half4 frag(v2f i) : SV_Target {
40         half2 coords = i.uv;
41         half2 uv = i.uv;
42         
43         coords = (coords -
0.5) * 2.0;
44         half coordDot = dot (coords,coords);
45         half4 color = tex2D (_MainTex, uv);
46
47         
float mask = 1.0 - coordDot * _Intensity * 0.1;
48         
49         half4 colorBlur = tex2D (_VignetteTex, i.uv2);
50         color = lerp (color, colorBlur, saturate (_Blur * coordDot));
51         
52         
return color * mask;
53     }
54
55     ENDCG
56     
57 Subshader {
58  Pass {
59       ZTest Always Cull Off ZWrite Off
60
61       CGPROGRAM
62       #pragma vertex vert
63       #pragma fragment frag
64       ENDCG
65   }
66 }
67
68 Fallback off
69 }


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