source: GTP/trunk/App/Demos/Illum/Shark3D/version164x12u/IllumDemo/bin/res/levelutil/shader/prog/d3d9_hlsl/gtp_reduce_cubemap_d3d9_hlsl_ps3x0.s3d_shadercode_run @ 2196

Revision 2196, 1.4 KB checked in by szirmay, 17 years ago (diff)
Line 
1
2struct PS_INPUT
3{
4    float4 posScr: POSITION;
5    float2 texCoord: TEXCOORD0;
6    float nFace: TEXCOORD1;
7};
8
9
10struct PS_OUTPUT
11{
12    float4  color: COLOR0;
13};
14
15///////////////////////////////////////////////////////////////////////////////
16
17sampler tex0: register(s0);
18
19///////////////////////////////////////////////////////////////////////////////
20// Pixelshader
21// Profile: 2x0
22const int CUBEMAP_SIZE = 128;
23const int REDUCED_CUBEMAP_SIZE = 4;
24
25PS_OUTPUT main(PS_INPUT input)
26{
27//const int RATE = CUBEMAP_SIZE / REDUCED_CUBEMAP_SIZE;
28const int RATE = 32;
29
30PS_OUTPUT output;
31float3 dir;
32 
33float4 color = float4(0,0,0,0);
34
35   for (int i = 0; i < RATE; i++)
36     for (int j = 0; j < RATE; j++)
37   {
38float2 pos;
39pos.x = input.texCoord.x + (2*i + 1)/(float)CUBEMAP_SIZE;
40pos.y = input.texCoord.y - (2*j + 1)/(float)CUBEMAP_SIZE;// y=-u
41
42 // "scrambling"
43if (input.nFace == 0) dir = float3(1, pos.y, -pos.x);
44if (input.nFace == 1) dir = float3(-1, pos.y, pos.x);
45if (input.nFace == 2) dir = float3(pos.x, 1, -pos.y);
46if (input.nFace == 3) dir = float3(pos.x, -1, pos.y);
47if (input.nFace == 4) dir = float3(pos.x, pos.y, 1);
48if (input.nFace == 5) dir = float3(-pos.x, pos.y,-1);
49
50color += texCUBElod( tex0, float4(dir,0));
51    }
52
53 output.color = color / (RATE * RATE);
54 return output;
55}
56
57///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.