Ignore:
Timestamp:
11/09/06 17:04:55 (18 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Diffuse.hlsl

    r1683 r1735  
    33float4 readCubeMap(samplerCUBE cm, float3 coord)                 
    44{ 
    5         float4 color = texCUBE( cm, float3(coord.xy, -coord.z) ); 
     5        float4 color = texCUBElod( cm, float4(coord.xy, -coord.z, 1) ); 
    66        color.a = 1; 
    77        return color; 
     
    1010float readDistanceCubeMap(samplerCUBE dcm, float3 coord)                 
    1111{ 
    12         float dist = texCUBE(dcm, float3(coord.xy, - coord.z)).r; 
     12        float dist = texCUBElod(dcm, float4(coord.xy, - coord.z, 1)).r; 
    1313        if(dist == 0) dist = 1000000; ///sky 
    1414        return dist; 
    1515} 
    1616 
    17 // This function is called several times. 
    18 float3 Hit( float3 x, float3 R, samplerCUBE mp ) 
    19 { 
    20         float rl = readDistanceCubeMap( mp, R);                         // |r| 
    21          
    22         float ppp = length( x ) /  readDistanceCubeMap( mp, x);                 // |p|/|p’| 
    23         float dun = 0, pun = ppp, dov = 0, pov = 0; 
    24         float dl = rl * ( 1 - ppp );                                                    // eq. 2 
    25         float3 l = x + R * dl;                                                                  // ray equation 
    26  
    27         // iteration 
    28         for( int i = 0; i < 2; i++ )    // 2 !!!!!!!!!!!!!!!!!!!!!!! 
    29         { 
    30                 float llp = length( l ) / readDistanceCubeMap( mp, l);          // |l|/|l’| 
    31                 if ( llp < 0.999f )                                                                     // undershooting 
    32                 { 
    33                         dun = dl; pun = llp;                                                    // last undershooting 
    34                         dl += ( dov == 0 ) ? rl * ( 1 - llp ) :                 // eq. 2 
    35                                 ( dl - dov ) * ( 1 - llp ) / ( llp - pov );     // eq. 3 
    36                 } else if ( llp > 1.001f )                                                      // overshooting 
    37                 { 
    38                         dov = dl; pov = llp;                                                    // last overshooting 
    39                         dl += ( dl -dun ) * ( 1 - llp ) / ( llp - pun );// eq. 3 
    40                 } 
    41                 l = x + R * dl;                                                                         // ray equation 
    42         } 
    43         return l;                                                                                               // computed hit point 
    44 } 
    4517 
    4618///////////////////// 
Note: See TracChangeset for help on using the changeset viewer.