Changeset 1929


Ignore:
Timestamp:
01/02/07 06:23:48 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media/materials
Files:
4 edited

Legend:

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

    r1735 r1929  
    140140                         
    141141        }                                                                                                                                                        
    142          
     142        /* 
    143143        for (float x = 1; x < M; x++)                    
    144144         for (float y = 1; y < M; y++)                                                                                   
     
    239239                 
    240240                I += 0.5 * Le * GetContibution( L, L1, L2, L3, L4, pos, N, DistanceEnvMapSampler);                               
    241          }       
     241         }      */ 
    242242         float kd = 0.5;                                                                                                                                                 
    243243        return kd * I; 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapot.hlsl

    r1885 r1929  
    333333  
    334334 float4 Color = float4(0, 0, 0, 0); 
    335  Color = float4(1.0/length(IN.cPos), length(IN.cPos),0,0); 
     335 Color = float4(1.0/length(IN.cPos), length(IN.cPos),0,1); 
     336 //return 1; 
    336337 return Color; 
    337338} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl

    r1897 r1929  
    1313} 
    1414 
    15 #define MAX_LIN_ITERATIONCOUNT 80  //80 
    16 #define MIN_LIN_ITERATIONCOUNT 60  //60 
     15#define MAX_LIN_ITERATIONCOUNT 20  //80 
     16#define MIN_LIN_ITERATIONCOUNT 30  //60 
    1717#define SECANT_ITERATIONCOUNT 2 
    1818#define MAX_RAY_DEPTH 2 
     
    7070 
    7171void linearSearch(  float3 x, float3 R, float3 N, samplerCUBE mp, 
    72                                         float min,                                       
     72                                        float2 minMax,                                   
    7373                    out float3 p, 
    7474                    out float dl, 
     
    7777                    out float ppp) 
    7878{ 
    79  float3 Ra = abs(R), xa = abs(x); 
    80  float xm =  max(max(xa.x,xa.y),xa.z); 
    81  float Rm = max(max(Ra.x,Ra.y),Ra.z); 
    82  float a = xm / Rm; 
    8379  
    8480 int shootL = 0, shootP = 0;           
    8581 bool found = false;  
    8682  
    87  float dt =  length(x / xm - R / Rm) * MAX_LIN_ITERATIONCOUNT; 
    88  dt = max(dt, MIN_LIN_ITERATIONCOUNT); 
    89  dt = 1.0 / dt; 
    90    
    91  float t = 0.01; 
    92  if(min > length(x)) 
     83 float min = minMax.x; 
     84 float max = minMax.y; 
     85  
     86 float minT = 0; 
     87 float maxT = 0;         
    9388 { 
    94   
    95         float a = 1; 
     89        float a = dot(R,R); 
    9690        float b = 2 * dot(R, x); 
    9791        float c = dot(x,x) - min * min;  
     92        float c2 = dot(x,x) - max * max;  
    9893         
    9994        float dis = b*b - 4*a*c; 
     95        float dis2 = b*b - 4*a*c2; 
     96         
    10097        float t1 = (-b + sqrt(dis))/ 2.0 * a; 
    10198        float t2 = (-b - sqrt(dis))/ 2.0 * a; 
    102          
    103         if(t1 > 0 && (t2 < 0 || t1 < t2)) 
    104          t =  1.0;//t1 / ( a + t1); 
    105         else if(t2 > 0) 
    106          t =  1.0;//t2 / ( a + t2); 
    107          //t = 0.011; 
    108   } 
     99    float t3 = (-b + sqrt(dis2))/ 2.0 * a; 
     100        float t4 = (-b - sqrt(dis2))/ 2.0 * a; 
     101         
     102        int numvalids = 0; 
     103        if(t1 > 0) 
     104        { 
     105         numvalids++; 
     106         if(t1 > maxT)maxT = t1; 
     107         if(t1 < minT || minT == 0)minT = t1; 
     108        } 
     109        if(t2 > 0) 
     110        { 
     111         numvalids++; 
     112         if(t2 > maxT)maxT = t2; 
     113         if(t2 < minT || minT == 0)minT = t2; 
     114        } 
     115        if(t3 > 0) 
     116        { 
     117         numvalids++; 
     118         if(t3 > maxT)maxT = t3; 
     119         if(t3 < minT || minT == 0)minT = t3; 
     120        } 
     121        if(t4 > 0) 
     122        { 
     123         numvalids++; 
     124         if(t4 > maxT)maxT = t4; 
     125         if(t4 < minT || minT == 0)minT = t4; 
     126        } 
     127         
     128        if(numvalids % 2 == 1) 
     129         minT = 0.01; 
     130        if(numvalids == 0) 
     131         minT = maxT + 1.0;      
     132 } 
    109133  
    110134 float pa; 
    111   
     135 float dt = (maxT - minT) / MAX_LIN_ITERATIONCOUNT; 
     136 float t = minT; 
    112137 //Linear iteration 
    113  while(t <= 1.0 && !found) 
     138 while(t <= maxT && !found) 
    114139 { 
    115    dp = a * t / (1 - t); 
    116    p = x + R * dp; 
     140   dp = t; 
     141   p = x + R * t; 
    117142   pa = readDistanceCubeMap(mp, p); 
    118143       
     
    175200           samplerCUBE mp3Color, 
    176201           samplerCUBE mp3Dist, 
    177            float min, 
    178            float min1, 
    179                    float min2,              
     202           float2 minMax, 
     203           float2 minMax1, 
     204                   float2 minMax2,                  
    180205           out float4 Il, out float3 Nl) 
    181206{ 
    182207 float dl1 = 0, dp1, llp1, ppp1; 
    183208 float3 p1; 
    184  linearSearch(x, R, N, mp1, min1, p1, dl1, dp1, llp1, ppp1); 
     209 linearSearch(x, R, N, mp1, minMax1, p1, dl1, dp1, llp1, ppp1); 
    185210 float dl2 = 0, dp2, llp2, ppp2; 
    186211 float3 p2; 
    187  linearSearch(x, R, N, mp2, min2, p2, dl2, dp2, llp2, ppp2); 
     212 linearSearch(x, R, N, mp2, minMax2, p2, dl2, dp2, llp2, ppp2); 
    188213  
    189214 bool valid1 = dot(p1,p1) != 0; 
     
    195220 if(!valid1 && ! valid2) 
    196221 { 
    197     linearSearch(x, R, N, mp3Dist, min, p, dl, dp, llp, ppp); 
    198     Il.a = 1;  
    199     secantSearch(x, R, mp3Dist, dl, dp, llp, ppp, p); 
    200     Il.rgb =  Nl.rgb = readCubeMap(mp3Color, p).rgb;   
     222    linearSearch(x, R, N, mp3Dist, minMax, p, dl, dp, llp, ppp); 
     223    if(dot(p,p) != 0) 
     224    { 
     225     Il.a = 1;     
     226     secantSearch(x, R, mp3Dist, dl, dp, llp, ppp, p); 
     227     Il.rgb =  Nl.rgb = readCubeMap(mp3Color, p).rgb;   
     228    } 
     229    else 
     230     Il = float4(0,0,0,1); 
    201231 } 
    202232 else 
     
    255285                                                        uniform float3 lastCenter, 
    256286                                                        uniform float refIndex, 
    257                                                         float min, 
    258                                                         float min1, 
    259                                                         float min2 
     287                                                        float2 minMax, 
     288                                                        float2 minMax1, 
     289                                                        float2 minMax2 
    260290                                                        ) 
    261291{ 
     
    270300 
    271301float3 R;           
    272 //if(refIndex > 100.0) 
    273     R = normalize(reflect( V, N)); 
    274 //else 
    275 //{ 
    276 //      refIndex = 1.0 / refIndex; 
    277 //    R = normalize(refract( V, N, refIndex)); 
    278 //} 
     302 
     303R = normalize(reflect( V, N)); 
    279304                         
    280305 float3 Nl; 
    281306 float4 Il; 
    282  float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min, min1, min2, Il, Nl); 
     307 float3 l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, minMax, minMax1, minMax2, Il, Nl); 
    283308 if(Il.a == 0) 
    284309  Il = readCubeMap(CubeMap, l); 
     
    297322                                                        uniform float3 lastCenter, 
    298323                                                        uniform float refIndex, 
    299                                                         float min, 
    300                                                         float min1, 
    301                                                         float min2) 
     324                                                        float2 minMax, 
     325                                                        float2 minMax1, 
     326                                                        float2 minMax2) 
    302327{ 
    303328         float4 I = float4(0,0,0,0); 
     
    323348           float3 Nl; 
    324349           float4 Il; 
    325            l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min, min1, min2, Il, Nl); 
     350           l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, minMax, minMax1, minMax2, Il, Nl); 
    326351           if(Il.a == 0) 
    327352           { 
     
    368393                   float3 Nl; 
    369394                   float4 Il; 
    370                    l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, min, min1, min2, Il, Nl); 
     395                   l = Hit(x, R, N, NormDistMap1, NormDistMap2, CubeMap, DistanceMap, minMax, minMax1, minMax2, Il, Nl); 
    371396                   if(Il.a == 0) 
    372397                   { 
     
    401426                                                        uniform float SingleBounce, 
    402427                                                        uniform float refIndex, 
    403                                                         uniform float4 min, 
    404                                                         uniform float4 min1, 
    405                                                         uniform float4 min2 
     428                                                        uniform float4 minmax, 
     429                                                        uniform float4 minmax1, 
     430                                                        uniform float4 minmax2 
    406431                                                        ):COLOR 
    407432{ 
    408    // min1.x = 1.0 / min1.x; 
    409    // min2.x = 1.0 / min2.x; 
     433   float2 miniMaxi1; 
     434   miniMaxi1.x = 1.0 / minmax.x / sqrt(2.0); 
     435   miniMaxi1.y = minmax.y; 
     436    
     437   float2 miniMaxi2; 
     438   miniMaxi2.x = 1.0 / minmax1.x / sqrt(2.0); 
     439   miniMaxi2.y = minmax1.y; 
     440    
     441   float2 miniMaxi3; 
     442   miniMaxi3.x = 1.0 / minmax2.x / sqrt(2.0); 
     443   miniMaxi3.y = minmax2.y; 
     444 
    410445        float4 Color = 1.0; 
    411446        if(SingleBounce == 1) 
    412          Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, min.w, min1.w, min2.w); 
     447         Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, miniMaxi1, miniMaxi2, miniMaxi3); 
    413448        else 
    414          Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, min.w, min1.w, min2.w); 
     449         Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex, miniMaxi1, miniMaxi2, miniMaxi3); 
    415450          
    416451        return Color; 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material

    r1897 r1929  
    133133    scene_blend max 
    134134    depth_test off 
     135    polygon_mode points 
    135136     
    136137        vertex_program_ref DefaultVS 
     
    157158    scene_blend max 
    158159    depth_test off 
    159      
     160    polygon_mode points 
     161         
    160162        vertex_program_ref DefaultVS 
    161163    {        
     
    204206                                resolution 1024 
    205207                                update_interval         0 
    206                                 get_minmax true 
    207                                 min_var_name min 
    208208                                distance_calc false 
    209209                                face_angle_calc false 
     
    215215                                layer 1 
    216216                                texture_unit_id 2 
    217                                 get_minmax true 
    218                                 min_var_name min1 
    219217                                update_interval         0 
    220218                                distance_calc false 
     
    230228                                layer 2 
    231229                                texture_unit_id 3 
    232                                 get_minmax true 
    233                                 min_var_name min2 
    234230                                update_interval         0 
    235231                                distance_calc false 
     
    239235                                render_self true 
    240236                                self_material NormalDistanceCW 
    241                         }                
     237                        } 
     238                        RenderTechnique ColorCubeMap 
     239                        { 
     240                                resolution 1 
     241                                layer 3                          
     242                                attach_to_texture_unit false 
     243                                get_minmax true 
     244                                max_var_name minmax 
     245                                update_interval         0 
     246                                distance_calc false 
     247                                face_angle_calc false 
     248                                update_all_face true 
     249                                render_env true 
     250                                render_self false 
     251                                env_material DistanceMinMaxCW 
     252                        } 
     253                        RenderTechnique ColorCubeMap 
     254                        { 
     255                                resolution 1 
     256                                layer 4 
     257                                attach_to_texture_unit false 
     258                                get_minmax true 
     259                                max_var_name minmax1 
     260                                update_interval         0 
     261                                distance_calc false 
     262                                face_angle_calc false 
     263                                update_all_face true 
     264                                render_env false 
     265                                render_self true 
     266                                self_material DistanceMinMaxCCW 
     267                        } 
     268                        RenderTechnique ColorCubeMap 
     269                        { 
     270                                resolution 1 
     271                                layer 5 
     272                                attach_to_texture_unit false 
     273                                get_minmax true 
     274                                max_var_name minmax2 
     275                                update_interval         0 
     276                                distance_calc false 
     277                                face_angle_calc false 
     278                                update_all_face true 
     279                                render_env false 
     280                                render_self true 
     281                                self_material DistanceMinMaxCW 
     282                        }                        
    242283                 } 
    243284                 vertex_program_ref DefaultVS 
     
    274315                { 
    275316                        filtering none 
    276                 } 
    277                  
     317                }                
    278318                //Cube map of reflective object's normals and distances CW 
    279319                texture_unit 
Note: See TracChangeset for help on using the changeset viewer.