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/MetalTeapot.hlsl

    r1730 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,0) ); 
    66        return color; 
    77} 
     
    99float readDistanceCubeMap(samplerCUBE dcm, float3 coord)                 
    1010{ 
    11         float dist = texCUBE(dcm, float3(coord.xy, - coord.z)).a; 
     11        float dist = texCUBElod(dcm, float4(coord.xy, - coord.z,0)).a; 
    1212        return dist; 
    1313} 
     
    1515 
    1616 
    17 #define LIN_ITERATIONCOUNT 2 
     17#define LIN_ITERATIONCOUNT 20 
    1818#define SECANT_ITERATIONCOUNT 2 
    1919 
     
    2424        float3 Ra = abs(R); 
    2525        float3 xa = abs(x); 
    26         float a = max(max(xa.x,xa.y),xa.z) /  
    27                           max(max(Ra.x,Ra.y),Ra.z); 
    28          
    29         bool overshoot = false, undershoot = false; 
     26         
     27    float xm =  max(max(xa.x,xa.y),xa.z); 
     28    float Rm = max(max(Ra.x,Ra.y),Ra.z); 
     29     
     30    float a = xm / Rm; 
     31     
     32   
     33    float dt =  length(x / xm - R / Rm) * 256.0 / 2.0; 
     34    dt = max(dt, 4); 
     35    dt = 1.0 / dt; 
     36     
     37         
     38        bool overshoot = false, undershoot = true; 
    3039        float dp, dl = 0, ppp, llp; 
    3140        float lR = readDistanceCubeMap(mp, R); 
    3241        //float3 p = R; 
    3342        float3 p = 0; 
    34                  
    35         float dt = 1.0 / LIN_ITERATIONCOUNT; 
     43         
     44         
     45        //float dt = 1.0 / LIN_ITERATIONCOUNT; 
    3646         
    3747        //linear iteration       
    38         float t = 0; 
     48         
     49        float t = 0.9999999999999; 
     50        dp = a * t / (1 - t); 
     51        p = x + R * dp; 
     52        float dist = readDistanceCubeMap(mp, p); 
     53        ppp = length(p) / dist; 
     54         
     55        t = 0;   
     56                 
    3957        while(t < 1.0 && !overshoot) 
    4058        { 
     
    6381        } 
    6482         
    65         if(t >= 1 && undershoot) 
    66         { 
    67                 t = 0.9999999999999; 
    68                 dp = a * t / (1 - t); 
    69                 p = x + R * dp; 
    70                 float dist = readDistanceCubeMap(mp, p); 
    71                 ppp = length(p) / dist; 
    72                 overshoot = true; 
    73         } 
     83        if(t >= 1.0 && undershoot && dist) 
     84                overshoot = true;        
    7485         
    7586        if(overshoot) 
     
    102113                         
    103114/* 
    104 float3 Hit( float3 x, float3 R, samplerCUBE mp ) 
     115float Hit( float3 x, float3 R, samplerCUBE mp, out float3 newDir ) 
    105116{ 
    106117        //return R  + 0.00000000001 * x; 
     
    128139                l = x + R * dl;                                                                         // ray equation 
    129140        } 
    130         return l;                                                                                               // computed hit point 
     141        newDir = l;                                                                                             // computed hit point 
     142         
     143        return dl; 
    131144} 
    132145*/ 
Note: See TracChangeset for help on using the changeset viewer.