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