Ignore:
Timestamp:
12/06/06 16:05:53 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media/materials
Files:
3 edited

Legend:

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

    r1859 r1860  
    312312} 
    313313 
    314 float4 NormalDistancePS( VertOut IN):COLOR 
     314float4 NormalDistancePS( VertOut IN, uniform float refIndex):COLOR 
    315315{ 
    316316  
    317317 float4 Color = float4(0, 0, 0, 0); 
    318318 //return Color; 
    319  Color = float4(normalize(IN.mNormal), length(IN.cPos)); 
     319 Color = float4(normalize(IN.mNormal) * refIndex, length(IN.cPos)); 
    320320 return Color; 
    321321} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/MetalTeapotNew.hlsl

    r1859 r1860  
    1616#define MIN_LIN_ITERATIONCOUNT 6 
    1717#define SECANT_ITERATIONCOUNT 1 
    18 #define MAX_RAY_DEPTH 2 
     18#define MAX_RAY_DEPTH 5 
    1919 
    2020void linearSearch(  float3 x, float3 R, float3 N, samplerCUBE mp, 
     
    3030 float a = xm / Rm; 
    3131            
    32  bool undershoot = true, overshoot = false;  
     32 bool undershoot = false, overshoot = false;  
    3333  
    3434 float dt =  length(x / xm - R / Rm) * MAX_LIN_ITERATIONCOUNT; 
     
    3636 dt = 1.0 / dt; 
    3737     
    38  float t = dt; 
     38 float t = 0.01;//dt; 
    3939 float pa; 
    4040 bool first = true; 
     
    6464 if(!overshoot) 
    6565  p = float3(0,0,0); 
    66  else if(t == 2 * dt) 
     66/* else if(t == 2 * dt) 
    6767 { 
    6868         float3 hitp = pa * normalize(p); 
    6969    if(dot(normalize(hitp - x), N) < 0.1f) 
    7070           p = float3(0,0,0); 
    71  } 
     71 }*/ 
    7272} 
    7373 
     
    178178                                                        uniform samplerCUBE NormDistMap1 : register(s2), 
    179179                                                        uniform samplerCUBE NormDistMap2 : register(s3), 
    180                                                         uniform float3 lastCenter) 
     180                                                        uniform float3 lastCenter, 
     181                                                        uniform float refIndex) 
    181182{ 
    182183 float4 Color = float4(1,1,1,1); 
     
    188189  
    189190 V = normalize(V); 
    190  float3 R = normalize(reflect( V, N)); 
    191  //float3 R = normalize(refract( V, N, 0.8)); 
     191 
     192float3 R;           
     193if(refIndex > 100.0) 
     194    R = normalize(reflect( V, N)); 
     195else 
     196{ 
     197        refIndex = 1.0 / refIndex; 
     198    R = normalize(refract( V, N, refIndex)); 
     199} 
    192200                         
    193201 float3 Nl; 
     
    207215                                                        uniform samplerCUBE NormDistMap1 : register(s2), 
    208216                                                        uniform samplerCUBE NormDistMap2 : register(s3), 
    209                                                         uniform float3 lastCenter) 
     217                                                        uniform float3 lastCenter, 
     218                                                        uniform float refIndex) 
    210219{ 
    211220         float4 I = float4(0,0,0,0); 
    212221                         
    213          float3 N = normalize(IN.mNormal); 
     222         float3 N = normalize(IN.mNormal) * refIndex; 
    214223         float3 newTexCoord;     
    215224         float3 x = IN.wPos - lastCenter; 
     
    222231         while(depth < MAX_RAY_DEPTH) 
    223232         { 
    224            float3 R = normalize(reflect( V, N)); 
    225           // float3 R = normalize(refract( V, N, 0.8)); 
     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)); 
    226242                                 
    227243           float3 Nl; 
     
    241257           N = normalize(Nl); 
    242258           V = R; 
    243           // if(dot(N, V) > 0) N = -N; 
     259            
     260          if(refIndex <= 100.0) 
     261            if(dot(N, V) > 0) N = -N; 
    244262        } 
    245263         
    246         /*if(I.a == 0) 
    247        I = readCubeMap(CubeMap, l);*/ 
     264//      if(I.a == 0) 
     265 //      I = readCubeMap(CubeMap, l); 
    248266   
    249267        return I; 
     
    257275                                                        uniform samplerCUBE NormDistMap2 : register(s3), 
    258276                                                        uniform float3 lastCenter, 
    259                                                         uniform float SingleBounce):COLOR 
     277                                                        uniform float SingleBounce, 
     278                                                        uniform float refIndex):COLOR 
    260279{ 
    261280        float4 Color = 1.0; 
    262281        if(SingleBounce == 1) 
    263          Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter); 
     282         Color = SingleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex); 
    264283        else 
    265          Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter); 
     284         Color = MultipleReflectionPS(IN,cameraPos, CubeMap, DistanceMap, NormDistMap1,NormDistMap2,lastCenter,refIndex); 
    266285          
    267286        return Color; 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/MetalTeapot.material

    r1859 r1860  
    8989    fragment_program_ref NormalDistancePS 
    9090    {  
    91                                  
     91                param_named refIndex float 1.6           
    9292        }  
    9393  } 
     
    111111    fragment_program_ref NormalDistancePS 
    112112    {  
    113                                  
     113                param_named refIndex float 1.6           
    114114        }  
    115115  } 
     
    134134      pass  
    135135      {  
     136        //cull_hardware none 
    136137                IllumTechniques 
    137138                { 
     
    194195                        //param_named k float3 4.16 2.57 2.32 
    195196                        param_named F0 float3 0.95 0.95 0.95 
    196                         param_named SingleBounce float 0.0                       
     197                        param_named SingleBounce float 0.0 
     198                        param_named refIndex float 1.6                   
    197199                }  
    198200                 
Note: See TracChangeset for help on using the changeset viewer.