source: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl @ 1257

Revision 1257, 928 bytes checked in by szirmay, 18 years ago (diff)
Line 
1#define samplesU 5
2#define samplesV 5
3
4struct VS_INPUT {           
5    float4 Position : POSITION;
6};
7
8struct VS_OUTPUT {         
9    float4 hPosition : POSITION;
10    float2 Position  : TEXCOORD0;
11};
12
13VS_OUTPUT BlurVS(VS_INPUT IN) {
14        VS_OUTPUT OUT;
15    OUT.hPosition = IN.Position;
16    OUT.Position =(IN.Position.xy + 1.0) / 2.0;
17    OUT.Position.y = 1.0 - OUT.Position.y;
18    return OUT;
19}
20
21float4 BlurPS(VS_OUTPUT IN,
22                        uniform sampler2D Texture : register(s0),
23                        uniform float width,
24                        uniform float height ) : COLOR
25
26
27  float2 pixel = float2(1.0 / width, 1.0 / height);
28  float2 uv = IN.Position + pixel * 0.5;
29
30  float4 sum = float4(0,0,0,0);
31
32        for(int i = 0; i < samplesU; i++)
33         for(int j = 0; j < samplesU; j++)
34                sum += tex2D(Texture, uv + float2(i - samplesU * 0.5,j - samplesV * 0.5) * pixel);
35
36  sum /= samplesU * samplesV;
37
38  return sum;
39  return tex2D(Texture, uv);
40}
Note: See TracBrowser for help on using the repository browser.