Ignore:
Timestamp:
12/07/06 20:27:30 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media/materials
Files:
2 edited

Legend:

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

    r1862 r1863  
    1313} 
    1414 
    15 #define MAX_LIN_ITERATIONCOUNT 80 
    16 #define MIN_LIN_ITERATIONCOUNT 30 
     15#define MAX_LIN_ITERATIONCOUNT 40  //80 
     16#define MIN_LIN_ITERATIONCOUNT 20  //60 
    1717#define SECANT_ITERATIONCOUNT 2 
    18 #define MAX_RAY_DEPTH 4 
    19  
     18#define MAX_RAY_DEPTH 5 
     19 
     20/* 
    2021void linearSearch(  float3 x, float3 R, float3 N, samplerCUBE mp, 
    2122                    out float3 p, 
     
    6162   t += dt;   
    6263 } 
    63   
     64 
    6465 if(!overshoot) 
    6566  p = float3(0,0,0); 
    66 /* else if(t == 2 * dt) 
     67} 
     68*/ 
     69 
     70 
     71void linearSearch(  float3 x, float3 R, float3 N, samplerCUBE mp, 
     72                    out float3 p, 
     73                    out float dl, 
     74                    out float dp, 
     75                    out float llp, 
     76                    out float ppp) 
     77{ 
     78 float3 Ra = abs(R), xa = abs(x); 
     79 float xm =  max(max(xa.x,xa.y),xa.z); 
     80 float Rm = max(max(Ra.x,Ra.y),Ra.z); 
     81 float a = xm / Rm; 
     82  
     83 int shootL = 0, shootP = 0;           
     84 bool found = false;  
     85  
     86 float dt =  length(x / xm - R / Rm) * MAX_LIN_ITERATIONCOUNT; 
     87 dt = max(dt, MIN_LIN_ITERATIONCOUNT); 
     88 dt = 1.0 / dt; 
     89     
     90 float t = 0.01;//dt; 
     91 float pa; 
     92  
     93 //Linear iteration 
     94 while(t <= 1.0 && !found) 
    6795 { 
    68          float3 hitp = pa * normalize(p); 
    69     if(dot(normalize(hitp - x), N) < 0.1f) 
    70            p = float3(0,0,0); 
    71  }*/ 
    72 } 
     96   dp = a * t / (1 - t); 
     97   p = x + R * dp; 
     98   pa = readDistanceCubeMap(mp, p); 
     99       
     100   if(pa > 0) 
     101   { 
     102    ppp = length(p) / pa; 
     103    if(ppp < 1) 
     104      shootP = -1; 
     105    else  
     106      shootP = 1;       
     107    if(shootL * shootP == -1) 
     108      found = true; 
     109    else 
     110    { 
     111      shootL = shootP; 
     112      dl = dp; 
     113      llp = ppp; 
     114    } 
     115   } 
     116   else 
     117     shootL = 0; 
     118       
     119   t += dt;   
     120 } 
     121 
     122 if(!found) 
     123  p = float3(0,0,0); 
     124} 
     125 
    73126 
    74127void secantSearch(float3 x, float3 R, samplerCUBE mp,  
     
    220273         float4 I = float4(0,0,0,0); 
    221274                         
    222          float3 N = normalize(IN.mNormal);// * refIndex; 
    223          float3 newTexCoord;     
     275         float3 N = normalize(IN.mNormal); 
    224276         float3 x = IN.wPos - lastCenter; 
    225277         float3 V  = (IN.wPos - cameraPos); 
     
    231283         while(depth < MAX_RAY_DEPTH) 
    232284         { 
    233            float3 R; 
    234           // float refIndex = length(N); 
    235           // refIndex = 1.0 / refIndex; 
    236           // N = normalize(N); 
    237             
    238            //if(refIndex > 100.0) 
    239             R = normalize(reflect( V, N)); 
    240           // else 
    241           //  R = normalize(refract( V, N, refIndex)); 
     285           float3 R;   
     286           //  R = normalize(reflect( V, N));      
     287           
     288          float ri = refIndex; 
     289           
     290          if(dot(V,N) > 0) 
     291          { 
     292            ri = 1.0 / ri; 
     293            N = -N;          
     294          } 
     295          R = refract( V, N, ri); 
     296          if(dot(R,R) == 0) R = reflect( V, -N);  
    242297                                 
    243298           float3 Nl; 
     
    246301           if(Il.a == 0) 
    247302           { 
    248                    depth += 1; 
    249                   // I = float4(0.2,0.2,0.2,1.0); 
     303                   depth += 1;            
    250304           } 
    251305           else 
     
    256310           x = l;           
    257311           N = normalize(Nl); 
    258            V = R; 
    259             
    260           //if(refIndex <= 100.0) 
    261             if(dot(N, V) > 0) N = -N; 
     312           V = R;                   
    262313        } 
     314        /* 
     315        N = normalize(IN.mNormal); 
     316        x = IN.wPos - lastCenter; 
     317        V  = (IN.wPos - cameraPos); 
     318        depth = 0; 
     319        while(depth < MAX_RAY_DEPTH) 
     320         { 
     321           float3 R;   
     322           R = normalize(reflect( V, N));          
     323                 
     324           float3 Nl; 
     325           float4 Il; 
     326           l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, Il, Nl); 
     327           if(Il.a == 0) 
     328           { 
     329                   depth += 1;            
     330           } 
     331           else 
     332           { 
     333                   I = Il * 0.2 + I * 0.8; 
     334                   depth = MAX_RAY_DEPTH; 
     335           } 
     336           x = l;           
     337           N = Nl; 
     338           V = R;    
     339        }*/ 
    263340         
    264341        //if(I.a == 0) 
     
    282359         Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex); 
    283360        else 
    284          Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap2,NormDistMap2,lastCenter,refIndex); 
     361         Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex); 
    285362          
    286363        return Color; 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material

    r1862 r1863  
    196196                        param_named F0 float3 0.95 0.95 0.95 
    197197                        param_named SingleBounce float 0.0 
    198                         param_named refIndex float 200                   
     198                        param_named refIndex float 0.909                         
    199199                }  
    200200                 
Note: See TracChangeset for help on using the changeset viewer.