【Radial Blur】
核心代码如下:
1 v2f vert (appdata_img v) 2 { 3 v2f o; 4 o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 5 o.uv = v.texcoord.xy; 6 return o; 7 } 8 9 float4 frag (v2f i) : COLOR 10 { 11 float2 texCoord = i.uv; 12 float2 dir = 0.5 – texCoord; 13 float dist = length(dir); 14 dir /= dist; 15 float4 color = tex2D(_MainTex, texCoord); 16 float4 sum = color; 17 18 float samples[10] = float[](-0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08); 19 20 for (int i = 0; i < 10; ++i) 21 { 22 sum += tex2D(_MainTex, texCoord + dir*samples[i]*fSampleDist); 23 } 24 25 sum /= 11.0; 26 float t = saturate(dist * fSampleStrength); 27 return lerp(color, sum, t); 28 }
参考:
1、http://www.gamerendering.com/2008/12/20/radial-blur-filter/
时间: 2024-10-09 04:06:57