[2368] | 1 | #define samplesU 3
|
---|
| 2 | #define samplesV 3
|
---|
[1257] | 3 |
|
---|
| 4 | struct VS_INPUT {
|
---|
| 5 | float4 Position : POSITION;
|
---|
| 6 | };
|
---|
| 7 |
|
---|
| 8 | struct VS_OUTPUT {
|
---|
| 9 | float4 hPosition : POSITION;
|
---|
| 10 | float2 Position : TEXCOORD0;
|
---|
| 11 | };
|
---|
| 12 |
|
---|
| 13 | VS_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 |
|
---|
| 21 | float4 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);
|
---|
[1691] | 40 | }
|
---|
| 41 |
|
---|
[2024] | 42 | float4 CopyPS(VS_OUTPUT IN,
|
---|
| 43 | uniform sampler2D Texture : register(s0),
|
---|
| 44 | uniform float alpha,
|
---|
| 45 | uniform float width,
|
---|
| 46 | uniform float height ) : COLOR
|
---|
| 47 | {
|
---|
| 48 | float2 pixel = float2(1.0 / width, 1.0 / height);
|
---|
| 49 | float2 uv = IN.Position + pixel * 0.5;
|
---|
| 50 |
|
---|
| 51 | float4 Color = tex2D(Texture, uv);
|
---|
| 52 | Color.a = alpha;
|
---|
[2029] | 53 | // Color = float4(0,0,0,1);
|
---|
[2024] | 54 | return Color;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
[1691] | 57 | VS_OUTPUT BlurCubeFaceVS(VS_INPUT IN) {
|
---|
| 58 | VS_OUTPUT OUT;
|
---|
| 59 | OUT.hPosition = IN.Position;
|
---|
| 60 | OUT.Position = OUT.hPosition;
|
---|
| 61 | return OUT;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | float4 BlurCubeFacePS(VS_OUTPUT IN,
|
---|
| 65 | uniform samplerCUBE Texture : register(s0),
|
---|
| 66 | uniform float width,
|
---|
| 67 | uniform float height,
|
---|
| 68 | uniform float face ) : COLOR
|
---|
[2368] | 69 | {
|
---|
| 70 | /*
|
---|
[1691] | 71 | float2 pixel = float2(2.0 / width, 2.0 / height);
|
---|
| 72 | float2 uv = IN.Position + pixel * 0.5;
|
---|
| 73 |
|
---|
| 74 | float4 sum = float4(0,0,0,0);
|
---|
| 75 |
|
---|
| 76 | for(int i = 0; i < samplesU; i++)
|
---|
| 77 | for(int j = 0; j < samplesV; j++)
|
---|
| 78 | {
|
---|
| 79 | float3 dir;
|
---|
| 80 | float2 pos = uv + float2(i - samplesU * 0.5,j - samplesV * 0.5) * pixel;
|
---|
| 81 | if (face == 0) dir = float3(1, pos.y, -pos.x);
|
---|
| 82 | if (face == 1) dir = float3(-1, pos.y, pos.x);
|
---|
| 83 | if (face == 2) dir = float3(pos.x, 1, -pos.y);
|
---|
| 84 | if (face == 3) dir = float3(pos.x, -1, pos.y);
|
---|
| 85 | if (face == 4) dir = float3(pos.x, pos.y, 1);
|
---|
| 86 | if (face == 5) dir = float3(-pos.x, pos.y,-1);
|
---|
| 87 |
|
---|
| 88 | sum += texCUBE(Texture, dir);
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[2368] | 91 | */
|
---|
| 92 | float pixel = 2.0 / width;
|
---|
| 93 | float2 uv = IN.Position;
|
---|
| 94 | float3 u;
|
---|
| 95 | float3 v;
|
---|
| 96 | float3 pos;
|
---|
| 97 | if (face == 0){u = float3(0,0,-1); v = float3(0,1,0); pos = float3(1,uv.y,-uv.x);}
|
---|
| 98 | if (face == 1){u = float3(0,0,1); v = float3(0,1,0); pos = float3(-1,uv.y,uv.x);}
|
---|
| 99 | if (face == 2){u = float3(1,0,0); v = float3(0,0,-1); pos = float3(uv.x,1,-uv.y);}
|
---|
| 100 | if (face == 3){u = float3(1,0,0); v = float3(0,0,1); pos = float3(uv.x,-1,uv.y);}
|
---|
| 101 | if (face == 4){u = float3(1,0,0); v = float3(0,1,0); pos = float3(uv.x,uv.y,1);}
|
---|
| 102 | if (face == 5){u = float3(-1,0,0); v = float3(0,1,0); pos = float3(-uv.x,uv.y,-1);}
|
---|
| 103 | u *= pixel;
|
---|
| 104 | v *= pixel;
|
---|
| 105 | float4 sum = float4(0,0,0,0);
|
---|
| 106 | sum += texCUBE(Texture, pos);
|
---|
| 107 | sum += texCUBE(Texture, pos + u);
|
---|
| 108 | sum += texCUBE(Texture, pos + v);
|
---|
| 109 | sum += texCUBE(Texture, pos + u + v);
|
---|
| 110 | sum /= 4.0;
|
---|
[1691] | 111 |
|
---|
| 112 | return sum;
|
---|
| 113 | //return texCUBE(Texture, float3(uv, 1)) + face * 0.0000001;
|
---|
[1257] | 114 | } |
---|