1 Shader "Hidden/FisheyeShader" {
2     Properties {
3         _MainTex (
"Base (RGB)", 2D) = "" {}
4     }
5     
6     
// Shader code pasted into all further CGPROGRAM blocks
7     CGINCLUDE
8     
9     #include
"UnityCG.cginc"
10     
11     
struct v2f {
12         float4 pos : SV_POSITION;
13         float2 uv : TEXCOORD0;
14     };
15     
16     sampler2D _MainTex;
17     
18     float2 intensity;
19     
20     v2f vert( appdata_img v )
21     {
22         v2f o;
23         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
24         o.uv = v.texcoord.xy;
25         
return o;
26     }
27     
28     half4 frag(v2f i) : SV_Target
29     {
30         half2 coords = i.uv;
31         coords = (coords -
0.5) * 2.0;
32         
33         half2 realCoordOffs;
34         realCoordOffs.x = (
1-coords.y * coords.y) * intensity.y * (coords.x);
35         realCoordOffs.y = (
1-coords.x * coords.x) * intensity.x * (coords.y);
36         
37         half4 color = tex2D (_MainTex, i.uv - realCoordOffs);
38         
39         
return color;
40     }
41
42     ENDCG
43     
44 Subshader {
45  Pass {
46       ZTest Always Cull Off ZWrite Off
47
48       CGPROGRAM
49       #pragma vertex vert
50       #pragma fragment frag
51       ENDCG
52   }
53   
54 }
55
56 Fallback off
57     
58 }
// shader


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