Ignore:
Timestamp:
04/24/07 14:10:34 (17 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.hlsl

    r2054 r2337  
    66float4 readCubeMap(samplerCUBE cm, float3 coord)                 
    77{ 
    8         float4 color = texCUBElod( cm, float4(coord.xy, -coord.z, 1) ); 
     8        float4 color = texCUBElod( cm, float4(coord.xy, -coord.z, 0) ); 
    99        color.a = 1; 
    1010        return color; 
     
    1313float readDistanceCubeMap(samplerCUBE dcm, float3 coord)                 
    1414{ 
    15         float dist = texCUBElod(dcm, float4(coord.xy, - coord.z, 1)).r; 
     15        float dist = texCUBElod(dcm, float4(coord.xy, - coord.z, 0)).r; 
    1616        if(dist == 0) dist = 1000000; ///sky 
    1717        return dist; 
     
    2626 float4 MPos : TEXCOORD0; 
    2727}; 
    28  
     28/* 
    2929float4 ReduceCubeMap_PS(MPos_OUT IN, 
    3030                                                uniform int nFace, 
     
    5454        return color / (RATE * RATE);            
    5555} 
    56  
     56*/ 
     57 
     58float4 ReduceCubeMap_PS(MPos_OUT IN, 
     59                                                uniform int nFace, 
     60                                                uniform samplerCUBE EnvironmentMapSampler : register(s0) ) : COLOR 
     61 
     62   float4 color = 0; 
     63   float3 dir; 
     64   
     65   for (int i = 0; i < RATE/2; i+=1) 
     66     for (int j = 0; j < RATE/2; j+=1) 
     67    { 
     68                float2 pos; 
     69                pos.x = IN.MPos.x + (4*i + 2)/(float)CUBEMAP_SIZE; 
     70                pos.y = IN.MPos.y - (4*j + 2)/(float)CUBEMAP_SIZE;      // y=-u 
     71 
     72                // "scrambling" 
     73                if (nFace == 0) dir = float3(1, pos.y, -pos.x); 
     74                if (nFace == 1) dir = float3(-1, pos.y, pos.x); 
     75                if (nFace == 2) dir = float3(pos.x, 1, -pos.y); 
     76                if (nFace == 3) dir = float3(pos.x, -1, pos.y); 
     77                if (nFace == 4) dir = float3(pos.x, pos.y, 1); 
     78                if (nFace == 5) dir = float3(-pos.x, pos.y,-1); 
     79 
     80                color += texCUBE( EnvironmentMapSampler, dir); 
     81    } 
     82  
     83        return color / (RATE * RATE / 4.0);              
     84} 
    5785 
    5886//////////////// 
Note: See TracChangeset for help on using the changeset viewer.