struct PS_INPUT { float4 posScr: POSITION; float2 texCoord: TEXCOORD0; float nFace: TEXCOORD1; }; struct PS_OUTPUT { float4 color: COLOR0; }; /////////////////////////////////////////////////////////////////////////////// sampler tex0: register(s0); /////////////////////////////////////////////////////////////////////////////// // Pixelshader // Profile: 2x0 const int CUBEMAP_SIZE = 128; const int REDUCED_CUBEMAP_SIZE = 4; PS_OUTPUT main(PS_INPUT input) { //const int RATE = CUBEMAP_SIZE / REDUCED_CUBEMAP_SIZE; const int RATE = 32; PS_OUTPUT output; float3 dir; float4 color = float4(0,0,0,0); for (int i = 0; i < RATE; i++) for (int j = 0; j < RATE; j++) { float2 pos; pos.x = input.texCoord.x + (2*i + 1)/(float)CUBEMAP_SIZE; pos.y = input.texCoord.y - (2*j + 1)/(float)CUBEMAP_SIZE;// y=-u // "scrambling" if (input.nFace == 0) dir = float3(1, pos.y, -pos.x); if (input.nFace == 1) dir = float3(-1, pos.y, pos.x); if (input.nFace == 2) dir = float3(pos.x, 1, -pos.y); if (input.nFace == 3) dir = float3(pos.x, -1, pos.y); if (input.nFace == 4) dir = float3(pos.x, pos.y, 1); if (input.nFace == 5) dir = float3(-pos.x, pos.y,-1); color += texCUBElod( tex0, float4(dir,0)); } output.color = color / (RATE * RATE); return output; } ///////////////////////////////////////////////////////////////////////////////