码迷,mamicode.com
首页 > 其他好文 > 详细

Radial Blur

时间:2014-12-01 18:59:22      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   color   os   sp   for   strong   

Radial Blur

  bubuko.com,布布扣

  核心代码如下:

 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/

Radial Blur

标签:style   blog   http   ar   color   os   sp   for   strong   

原文地址:http://www.cnblogs.com/tekkaman/p/4135665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!