Ignore:
Timestamp:
02/05/07 17:43:39 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media/materials
Files:
4 added
7 edited

Legend:

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

    r2054 r2095  
    1111} 
    1212 
    13 #define MAX_LIN_ITERATIONCOUNT 30  //80 
    14 #define MIN_LIN_ITERATIONCOUNT 20  //60 
     13#define MAX_LIN_ITERATIONCOUNT 50  //80 
     14#define MIN_LIN_ITERATIONCOUNT 15  //60 
    1515#define SECANT_ITERATIONCOUNT 1 
    16 #define MAX_RAY_DEPTH 2 
     16#define MAX_RAY_DEPTH 4 
    1717 
    1818void linearSearch(  float3 x, float3 R, float3 N, samplerCUBE mp, 
     
    219219          V = normalize(V); 
    220220          
    221          float F = sFresnel + pow(1 - dot(N, -V), 5) * (1 - sFresnel);    
    222          
    223          float3 l; 
    224          float4 Irefl; 
     221         float F; 
    225222         int depth = 0; 
    226          
    227          while(depth < MAX_RAY_DEPTH) 
    228          { 
    229             float3 R;   
    230            R = normalize(reflect( V, N));          
    231                  
    232            float3 Nl; 
    233            float4 Il; 
    234            l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, Il, Nl); 
    235            if(Il.a == 0) 
    236            { 
    237                    depth += 1;            
    238            } 
    239            else 
    240            { 
    241                    I = Il; 
    242                    depth = MAX_RAY_DEPTH; 
    243            } 
    244            x = l;           
    245            N = Nl; 
    246            V = R;    
    247             
    248         } 
    249         if(I.a == 0) 
    250            I = readCubeMap(CubeMap, l); 
    251         Irefl = I; 
    252          
    253         { 
    254         float4 Irefr; 
    255         N = normalize(IN.wNormal.xyz); 
    256         x = IN.wPos.xyz - lastCenter; 
    257         V  = (IN.wPos.xyz - cameraPos); 
    258         depth = 0; 
     223        F = sFresnel + pow(1 - dot(N, -V), 5) * (1 - sFresnel);   
    259224         
    260225        while(depth < MAX_RAY_DEPTH) 
    261226        { 
    262227          float3 R;   
    263            
    264           float ri = refIndex; 
    265           
     228                  
     229          float ri = refIndex;    
    266230          if(dot(V,N) > 0) 
    267231          { 
     
    270234          } 
    271235          R = refract( V, N, ri); 
    272           if(dot(R,R) == 0) R = reflect( V, N);  
    273                                          
     236          if(dot(R,R) == 0) R = reflect( V, N); 
     237                                                 
     238          float3 Nl; 
     239          float4 Il; 
     240          float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, Il, Nl); 
     241          if(Il.a == 0) 
     242          { 
     243                  //I = readCubeMap(CubeMap, l); 
     244                   depth += 1;            
     245          } 
     246          else 
     247          { 
     248                   I = Il; 
     249                   depth = MAX_RAY_DEPTH; 
     250          } 
     251          x = l;            
     252          N = normalize(Nl); 
     253          V = R;                    
     254        }   
     255             
     256        I *= (1.0 - F);  
     257     
     258        return I; 
     259} 
     260 
     261float4 MultipleRefractionPhotonMap_PS(Shaded_OUT IN, 
     262                                                                        uniform samplerCUBE DistanceMap  : register(s0), 
     263                                                                        uniform samplerCUBE NormDistMap1 : register(s1), 
     264                                                                        uniform samplerCUBE NormDistMap2 : register(s2), 
     265                                                                        uniform samplerCUBE CubeMap      : register(s3), //NOT USED 
     266                                                                        uniform float3 cameraPos, 
     267                                                                        uniform float3 lastCenter, 
     268                                                                        uniform float refIndex) : COLOR0 
     269{ 
     270         float4 I = 0;           
     271         float3 N = normalize(IN.wNormal.xyz); 
     272         float3 x = IN.wPos.xyz - lastCenter; 
     273         float3 V  = (IN.wPos.xyz - cameraPos); 
     274         V = normalize(V); 
     275          
     276        int depth = 0; 
     277        float3 l; 
     278         
     279        while(depth < MAX_RAY_DEPTH) 
     280        { 
     281          float3 R;   
     282                  
     283          float ri = refIndex;    
     284          if(dot(V,N) > 0) 
     285          { 
     286                ri = 1.0 / ri; 
     287                N = -N;      
     288          } 
     289          R = refract( V, N, ri); 
     290          if(dot(R,R) == 0) R = reflect( V, N); 
     291                                                 
    274292          float3 Nl; 
    275293          float4 Il; 
     
    277295          if(Il.a == 0) 
    278296          { 
    279                    depth += 1;            
     297                  depth += 1;             
    280298          } 
    281299          else 
    282300          { 
    283                    I = Il; 
    284                    depth = MAX_RAY_DEPTH; 
     301                  I = Il; 
     302                  depth = MAX_RAY_DEPTH; 
    285303          } 
    286304          x = l;            
    287305          N = normalize(Nl); 
    288306          V = R;                    
    289         } 
    290          
     307        }   
    291308        if(I.a == 0) 
    292            I = readCubeMap(CubeMap, l); 
    293         Irefr = I; 
    294              
    295         I = Irefl * F + (1.0 - F) * Irefr;       
    296     } 
    297         return I; 
    298 } 
    299  
    300 float4 MultipleRefractionPhotonMap_PS(Shaded_OUT IN, 
    301                                                                         uniform samplerCUBE DistanceMap : register(s0), 
    302                                                                         uniform samplerCUBE NormDistMap1 : register(s1), 
    303                                                                         uniform samplerCUBE NormDistMap2 : register(s2), 
    304                                                                         uniform float3 cameraPos, 
    305                                                                         uniform float3 lastCenter, 
    306                                                                         uniform float refIndex) : COLOR0 
    307 { 
    308         float4 I = float4(0,0,0,0); 
    309                   
    310         float3 N = normalize(IN.wNormal.xyz); 
    311         float3 x = IN.wPos.xyz - lastCenter; 
    312         float3 V  = (IN.wPos.xyz - cameraPos); 
    313         V = normalize(V); 
    314         float3 l; 
    315         int depth = 0; 
    316                  
    317         while(depth < MAX_RAY_DEPTH) 
    318         { 
    319           float3 R;   
    320            
    321           float ri = refIndex; 
    322           
    323           if(dot(V,N) > 0) 
    324           { 
    325                 ri = 1.0 / ri; 
    326                 N = -N;      
    327           } 
    328           R = refract( V, N, ri); 
    329           if(dot(R,R) == 0) R = reflect( V, N);  
    330                                          
    331           float3 Nl; 
    332           float4 Il; 
    333           l = Hit(x, R, N, NormDistMap1, NormDistMap2, DistanceMap, DistanceMap, Il, Nl); 
    334           if(Il.a == 0) 
    335           { 
    336                    depth += 1;            
    337           } 
    338           else 
    339           { 
    340                    I = Il; 
    341                    depth = MAX_RAY_DEPTH; 
    342           } 
    343           x = l;            
    344           N = normalize(Nl); 
    345           V = R;                    
    346         } 
    347          
    348         return float4(l,1); 
    349 } 
     309                I = 0; 
     310        else 
     311                I = float4(l,1); 
     312         
     313        return I; 
     314} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/multibounce/GTPMultipleReflection_MinMax.hlsl

    r2054 r2095  
    1111} 
    1212 
    13 #define MAX_LIN_ITERATIONCOUNT 30  //80 
    14 #define MIN_LIN_ITERATIONCOUNT 25  //60 
     13#define MAX_LIN_ITERATIONCOUNT 80  //80 
     14#define MIN_LIN_ITERATIONCOUNT 60  //60 
    1515#define SECANT_ITERATIONCOUNT 1 
    16 #define MAX_RAY_DEPTH 2 
     16#define MAX_RAY_DEPTH 4 
     17 
     18//#define METHOD1 
    1719 
    1820void linearSearch(  float3 x, float3 R, float3 N, samplerCUBE mp, 
     
    2426                    out float ppp) 
    2527{ 
     28 float3 Ra = abs(R), xa = abs(x); 
     29 float xm =  max(max(xa.x,xa.y),xa.z); 
     30 float Rm = max(max(Ra.x,Ra.y),Ra.z); 
     31 float a = xm / Rm; 
    2632  
    2733 int shootL = 0, shootP = 0;           
     
    2935  
    3036 float min = minMax.x; 
    31  float max = minMax.y; 
    32   
    33  float minT = 0; 
    34  float maxT = 0; 
     37 float maximum = minMax.y; 
     38  
     39 float minD = 0; 
     40 float maxD = 0; 
    3541 { 
    3642        float a = dot(R,R); 
    3743        float b = 2 * dot(R, x); 
    3844        float c = dot(x,x) - min * min;  
    39         float c2 = dot(x,x) - max * max;  
     45        float c2 = dot(x,x) - maximum * maximum;  
    4046         
    4147        float dis = b*b - 4*a*c; 
     
    5157        { 
    5258         numvalids++; 
    53          if(t1 > maxT)maxT = t1; 
    54          if(t1 < minT || minT == 0)minT = t1; 
     59         if(t1 > maxD)maxD = t1; 
     60         if(t1 < minD || minD == 0)minD = t1; 
    5561        } 
    5662        if(t2 > 0) 
    5763        { 
    5864         numvalids++; 
    59          if(t2 > maxT)maxT = t2; 
    60          if(t2 < minT || minT == 0)minT = t2; 
     65         if(t2 > maxD)maxD = t2; 
     66         if(t2 < minD || minD == 0)minD = t2; 
    6167        } 
    6268        if(t3 > 0) 
    6369        { 
    6470         numvalids++; 
    65          if(t3 > maxT)maxT = t3; 
    66          if(t3 < minT || minT == 0)minT = t3; 
     71         if(t3 > maxD)maxD = t3; 
     72         if(t3 < minD || minD == 0)minD = t3; 
    6773        } 
    6874        if(t4 > 0) 
    6975        { 
    7076         numvalids++; 
    71          if(t4 > maxT)maxT = t4; 
    72          if(t4 < minT || minT == 0)minT = t4; 
     77         if(t4 > maxD)maxD = t4; 
     78         if(t4 < minD || minD == 0)minD = t4; 
    7379        } 
    7480         
    7581        if(numvalids % 2 == 1) 
    76          minT = 0.01; 
     82         minD = 0.01; 
    7783        if(numvalids == 0) 
    78          minT = maxT + 1.0;      
     84         minD = maxD + 1.0;      
    7985 } 
    8086  
     87#ifdef METHOD1 
    8188 int iterationNeeded = MAX_LIN_ITERATIONCOUNT;// + (dot(normalize(x), R) + 1.0) / 2.0 * (MAX_LIN_ITERATIONCOUNT - MIN_LIN_ITERATIONCOUNT); 
    8289 float pa; 
    83  float dt = (maxT - minT) / (float) iterationNeeded ; 
    84  dp = minT; 
     90 float dD = (maxD - minD) / (float) iterationNeeded ; 
     91 dp = minD;  
     92  
    8593 //Linear iteration 
    86  while(dp <= maxT && !found) 
     94 while(dp <= maxD && !found) 
    8795 { 
     96          
     97#else 
     98 float dt =  length(x / xm - R / Rm) * MAX_LIN_ITERATIONCOUNT; 
     99 dt = max(dt, MIN_LIN_ITERATIONCOUNT); 
     100 dt = 1.0 / dt; 
     101  
     102 float minT = max(minD / (a + minD) - dt, dt); 
     103 float maxT = maxD / (a + maxD) + dt; 
     104  
     105 float t = minT;//dt; 
     106 float pa; 
     107  
     108 while(t <= maxT && !found) 
     109 { 
     110         dp = a * t / (1 - t); 
     111#endif 
     112 
    88113   p = x + R * dp; 
    89114   pa = readDistanceCubeMap(mp, p); 
     
    107132   else 
    108133     shootL = 0; 
    109        
    110    dp += dt;   
     134  
     135 #ifdef METHOD1      
     136   dp += dD;  
     137 #else  
     138   t += dt; 
     139 #endif 
    111140 } 
    112141 
     
    214243                                                        uniform float4 min1, 
    215244                                                        uniform float4 min2, 
    216                                                         uniform float4 max, 
     245                                                        uniform float4 Max, 
    217246                                                        uniform float4 max1, 
    218247                                                        uniform float4 max2) : COLOR0 
     
    220249        float2 miniMaxi1; 
    221250    miniMaxi1.x = min.a; 
    222     miniMaxi1.y = max.a; 
     251    miniMaxi1.y = Max.a; 
    223252    
    224253    float2 miniMaxi2; 
     
    258287           x = l;           
    259288           N = Nl; 
    260            V = R;    
    261             
     289           V = R;           
    262290        } 
    263291        if(I.a == 0) 
    264            I = readCubeMap(CubeMap, l); 
     292          I = readCubeMap(CubeMap, l); 
    265293         
    266294        return I; 
     
    275303                                                        uniform float3 lastCenter, 
    276304                                                        uniform float refIndex, 
    277                                                         //uniform float sFresnel, //0.04  
     305                                                        uniform float sFresnel, //0.04  
    278306                                                        uniform float4 min, 
    279307                                                        uniform float4 min1, 
    280308                                                        uniform float4 min2, 
    281                                                         uniform float4 max, 
     309                                                        uniform float4 Max, 
    282310                                                        uniform float4 max1, 
    283311                                                        uniform float4 max2) : COLOR0 
     
    285313        float2 miniMaxi1; 
    286314    miniMaxi1.x = min.a; 
    287     miniMaxi1.y = max.a; 
     315    miniMaxi1.y = Max.a; 
    288316    
    289317    float2 miniMaxi2; 
     
    295323    miniMaxi3.y = max2.a; 
    296324 
    297          float4 I = float4(0,0,0,0); 
     325        float4 I = float4(0,0,0,0); 
    298326                         
    299327         float3 N = normalize(IN.wNormal.xyz); 
    300328         float3 x = IN.wPos.xyz - lastCenter; 
    301329         float3 V  = (IN.wPos.xyz - cameraPos); 
     330          V = normalize(V); 
    302331          
    303          float sFresnel = 0.04; 
    304          float F = sFresnel + pow(1 - dot(N, -V), 5) * (1 - sFresnel); 
    305           
    306          V = normalize(V); 
    307          float3 l; 
    308          float4 Irefl; 
     332         float F; 
    309333         int depth = 0; 
    310          
    311          while(depth < MAX_RAY_DEPTH) 
    312          { 
    313             float3 R;   
    314            R = normalize(reflect( V, N));          
    315                  
    316            float3 Nl; 
    317            float4 Il; 
    318            l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, miniMaxi1, miniMaxi2, miniMaxi3, Il, Nl); 
    319            if(Il.a == 0) 
    320            { 
    321                    depth += 1;            
    322            } 
    323            else 
    324            { 
    325                    I = Il; 
    326                    depth = MAX_RAY_DEPTH; 
    327            } 
    328            x = l;           
    329            N = Nl; 
    330            V = R;    
    331             
    332         } 
    333         if(I.a == 0) 
    334            I = readCubeMap(CubeMap, l); 
    335         Irefl = I; 
    336          
    337         { 
    338         float4 Irefr; 
    339         N = normalize(IN.wNormal.xyz); 
    340         x = IN.wPos.xyz - lastCenter; 
    341         V  = (IN.wPos.xyz - cameraPos); 
    342         V = normalize(V); 
    343         depth = 0; 
     334        F = sFresnel + pow(1 - dot(N, -V), 5) * (1 - sFresnel);   
    344335         
    345336        while(depth < MAX_RAY_DEPTH) 
    346337        { 
    347338          float3 R;   
    348            
    349           float ri = refIndex; 
    350           
     339                  
     340          float ri = refIndex;    
    351341          if(dot(V,N) > 0) 
    352342          { 
     
    355345          } 
    356346          R = refract( V, N, ri); 
    357           if(dot(R,R) == 0) R = reflect( V, N);  
    358                                          
     347          if(dot(R,R) == 0) R = reflect( V, N); 
     348                                                 
    359349          float3 Nl; 
    360350          float4 Il; 
    361           l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, miniMaxi1, miniMaxi2, miniMaxi3, Il, Nl); 
     351          float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, miniMaxi1, miniMaxi2, miniMaxi3, Il, Nl); 
    362352          if(Il.a == 0) 
    363353          { 
     354                  //I = readCubeMap(CubeMap, l); 
    364355                   depth += 1;            
    365356          } 
     
    372363          N = normalize(Nl); 
    373364          V = R;                    
    374         } 
    375          
    376         if(I.a == 0) 
    377            I = readCubeMap(CubeMap, l); 
    378         Irefr = I; 
     365        }   
    379366             
    380         I = Irefl * F + (1.0 - F) * Irefr; 
    381     } 
    382         return I; 
     367        I *= (1.0 - F);  
     368     
     369        return I; 
    383370} 
    384371 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/multibounce/multipleReflectionMinMax/GTPMultipleReflectionMinMax.material

    r2054 r2095  
    3535                                get_minmax true 
    3636                                min_var_name min 
    37                                 max_var_name max                                 
     37                                max_var_name Max                                 
    3838                        } 
    3939                        RenderTechnique ColorCubeMap 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl

    r2054 r2095  
    220220                //float maxdist = 10; 
    221221                //intensity = max(maxdist - avrdist, 0.0) / maxdist; 
    222                 intensity = 60.0 / (avrdist * avrdist * 3.14); 
     222                intensity = 5 / (avrdist * avrdist * 3.14); 
    223223                //intensity = valids / 4.0;//avrdist; 
    224224                 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl

    r2054 r2095  
    129129} 
    130130 
    131 /* 
     131 
    132132float4 distShadowPS(VS_OUT_SHADOW IN, 
    133133                                        uniform float4x4 lightViewProj, 
     
    174174         
    175175        return shadow + (1 - shadow) * light; 
    176 }*/ 
    177  
     176} 
     177/* 
    178178float4 distShadowPS(VS_OUT_SHADOW IN, 
    179179                                        uniform float4x4 lightViewProj, 
     
    212212        return shadow + (1 - shadow) * light; 
    213213} 
    214  
     214*/ 
    215215/* 
    216216float4 depthShadowPS(VS_OUT_SHADOW IN, 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/colorcube.material

    r2054 r2095  
    55                pass 
    66                { 
    7                         //lighting off 
     7                        lighting off 
    88                        IllumTechniques 
    99                        { 
     
    1313                                        max_caster_count        10                                       
    1414                                }                                
    15                                 RenderTechnique DepthShadowReciever 
    16                                 { 
    17                                    max_light_count 1 
    18                                    vertex_program_name GameTools/ShadowMap/ShadowDistVS 
    19                                    fragment_program_name GameTools/ShadowMap/ShadowDistPS 
    20                                    set_light_view true 
    21                                    set_light_farplane true 
    22                                 } 
     15                                //RenderTechnique DepthShadowReciever 
     16                                //{ 
     17                                //   max_light_count 1 
     18                                //   vertex_program_name GameTools/ShadowMap/ShadowDistVS 
     19                                //   fragment_program_name GameTools/ShadowMap/ShadowDistPS 
     20                                //   set_light_view true 
     21                                //   set_light_farplane true 
     22                                //} 
    2323                        } 
    2424 
    2525                        texture_unit 
    2626                        { 
    27                                 texture roomc.PNG 
    28                                 tex_coord_set 0 
    29                                 colour_op modulate 
     27                                texture roomcdark.PNG 
     28                                //texture object_SE_0_PHOTONMAP 
     29                                //tex_coord_set 0 
     30                                //colour_op modulate 
    3031                        } 
    3132                } 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/difflab.material

    r2054 r2095  
    191191                                        set_light_view true 
    192192                                        set_light_farplane true 
    193                                 } 
    194                                 RenderTechnique CausticReciever 
    195                                 { 
    196                                         max_caster_count        3 
    197                                 }        
     193                                }                                
    198194                        } 
    199195                         
Note: See TracChangeset for help on using the changeset viewer.