- Timestamp:
- 01/24/07 21:44:30 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl
r1929 r2054 1 1 float REDUCED_CUBEMAP_SIZE; 2 int CUBEMAP_SIZE = 128; 3 int RATE = 32; 2 4 3 5 float4 readCubeMap(samplerCUBE cm, float3 coord) … … 13 15 if(dist == 0) dist = 1000000; ///sky 14 16 return dist; 17 } 18 19 20 ///// 21 /// Reduce cube map shader 22 ///// 23 struct MPos_OUT 24 { 25 float4 VPos : POSITION; 26 float4 MPos : TEXCOORD0; 27 }; 28 29 float4 ReduceCubeMap_PS(MPos_OUT IN, 30 uniform int nFace, 31 uniform samplerCUBE EnvironmentMapSampler : register(s0) ) : COLOR 32 { 33 RATE = 32; 34 CUBEMAP_SIZE = 128; 35 float4 color = 0; 36 float3 dir; 37 38 for (int i = 0; i < RATE; i++) 39 for (int j = 0; j < RATE; j++) 40 { 41 float2 pos; 42 pos.x = IN.mPos.x + (2*i + 1)/(float)CUBEMAP_SIZE; 43 pos.y = IN.mPos.y - (2*j + 1)/(float)CUBEMAP_SIZE; // y=-u 44 45 // "scrambling" 46 if (nFace == 0) dir = float3(1, pos.y, -pos.x); 47 if (nFace == 1) dir = float3(-1, pos.y, pos.x); 48 if (nFace == 2) dir = float3(pos.x, 1, -pos.y); 49 if (nFace == 3) dir = float3(pos.x, -1, pos.y); 50 if (nFace == 4) dir = float3(pos.x, pos.y, 1); 51 if (nFace == 5) dir = float3(-pos.x, pos.y,-1); 52 53 color += texCUBE( EnvironmentMapSampler, dir); 54 } 55 56 return color / (RATE*RATE); 15 57 } 16 58
Note: See TracChangeset
for help on using the changeset viewer.