【Radial Blur】
核心代码如下:
v2f vert (appdata_img v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord.xy;
return o;
} float4 frag (v2f i) : COLOR
{
float2 texCoord = i.uv;
float2 dir = 0.5 – texCoord;
float dist = length(dir);
dir /= dist;
float4 color = tex2D(_MainTex, texCoord);
float4 sum = color; float samples[] = float[](-0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08); for (int i = ; i < ; ++i)
{
sum += tex2D(_MainTex, texCoord + dir*samples[i]*fSampleDist);
} sum /= 11.0;
float t = saturate(dist * fSampleStrength);
return lerp(color, sum, t);
}
参考:
1、http://www.gamerendering.com/2008/12/20/radial-blur-filter/