float viewport_inv_width; float viewport_inv_height; sampler Texture0; const float4 samples[5] = { 0.0, 0.0, 0, 11/3.0, 0.0, 1.0, 0, -2.0/3.0, 0.0, -1.0, 0, -2.0/3.0, -1.0, 0.0, 0, -2.0/3.0, 1.0, 0.0, 0, -2.0/3.0 }; float4 ps_main(float2 texCoord: TEXCOORD0) : COLOR { float4 col = float4(0,0,0,0); // Sample and output the averaged colors for(int i=0;i<5;i++) col += samples[i].w*tex2D(Texture0,texCoord+ float2(samples[i].x*viewport_inv_width, samples[i].y*viewport_inv_height)); return col; }
Box filter blur
通过取某像素点周围的4个像素来进行混合