source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/precompiled/app/OgreIllumModule_Resources/materials/GTPBasic/GTPBasicFSQuad.hlsl @ 3255

Revision 3255, 2.8 KB checked in by szirmay, 16 years ago (diff)
Line 
1#define samplesU 7
2#define samplesV 7
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 FSQuadVS(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}
41
42float4 BlurPS_4x4(VS_OUTPUT IN,
43                        uniform sampler2D Texture : register(s0),
44                        uniform float width,
45                        uniform float height ) : COLOR
46
47
48  float2 pixel = float2(1.0 / width, 1.0 / height);
49  float2 uv = IN.Position + pixel * 0.5;
50
51  float du = 2.0 / width;
52  float dv = 2.0 / height;
53
54  float4 sum = float4(0,0,0,0);
55
56  sum += tex2D(Texture,uv);
57  sum += tex2D(Texture,uv + float2(du,0));
58  sum += tex2D(Texture,uv + float2(du,dv));
59  sum += tex2D(Texture,uv + float2(0,dv));
60  return sum / 4.0;
61}
62
63
64float4 CopyPS(VS_OUTPUT IN,
65                        uniform sampler2D Texture : register(s0),
66                        uniform float alpha,
67                        uniform float width,
68                        uniform float height ) : COLOR
69
70  float2 pixel = float2(1.0 / width, 1.0 / height);
71  float2 uv = IN.Position + pixel * 0.5;
72
73  float4 Color = tex2D(Texture, uv);
74  Color.a = alpha;
75 return Color;
76}
77
78VS_OUTPUT BlurCubeFaceVS(VS_INPUT IN) {
79        VS_OUTPUT OUT;
80    OUT.hPosition = IN.Position;   
81    OUT.Position = OUT.hPosition;
82    return OUT;
83}
84
85float4 BlurCubeFacePS(VS_OUTPUT IN,
86                        uniform samplerCUBE Texture : register(s0),
87                        uniform float width,
88                        uniform float height,
89                        uniform float face ) : COLOR
90
91
92  float2 pixel = float2(2.0 / width, 2.0 / height);
93  float2 uv = IN.Position + pixel * 0.5;
94
95  float4 sum = float4(0,0,0,0);
96
97        for(int i = 0; i < samplesU; i++)
98         for(int j = 0; j < samplesV; j++)
99         {
100                float3 dir;
101                float2 pos = uv + float2(i - samplesU * 0.5,j - samplesV * 0.5) * pixel;
102                if (face == 0) dir = float3(1, pos.y, -pos.x);
103                if (face == 1) dir = float3(-1, pos.y, pos.x);
104                if (face == 2) dir = float3(pos.x, 1, -pos.y);
105                if (face == 3) dir = float3(pos.x, -1, pos.y);
106                if (face == 4) dir = float3(pos.x, pos.y, 1);
107                if (face == 5) dir = float3(-pos.x, pos.y,-1);
108               
109                sum += texCUBE(Texture, dir);
110         }
111               
112
113  sum /= samplesU * samplesV;
114
115  return sum;
116  //return texCUBE(Texture, float3(uv, 1)) + face * 0.0000001;
117}
Note: See TracBrowser for help on using the repository browser.