Changeset 2471


Ignore:
Timestamp:
07/02/07 04:04:08 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media
Files:
7 edited

Legend:

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

    r2337 r2471  
    443443        return kd * I; 
    444444} 
     445 
     446float4 Glossy_Disc2Point_PS(Shaded_OUT IN, 
     447                                                        uniform float3 lastCenter, 
     448                                                        uniform float3 cameraPos, 
     449                                                        uniform samplerCUBE SmallEnvMapSampler : register(s0), 
     450                                                        uniform samplerCUBE DistanceEnvMapSampler : register(s1) 
     451                   ) : COLOR0 
     452{ 
     453        float M = REDUCED_CUBEMAP_SIZE; 
     454         
     455    float3 N = IN.wNormal.xyz; 
     456    N = normalize( N ); 
     457    float3 V = normalize(IN.wPos.xyz - cameraPos);  
     458    float3 pos = IN.wPos.xyz - lastCenter;                                                                                                                                               
     459    float3 R = reflect( V, N );                                                                  
     460 
     461    float rr = max( max(abs(R.x), abs(R.y)), abs(R.z) );        // select the largest component 
     462    R /= rr;    // scale the largest component to value +/-1 
     463 
     464    float3 offset1 = float3(1,0,0); 
     465    float3 offset2 = float3(0,1,0); 
     466    if (abs(R.x) > abs(R.y) && abs(R.x) > abs(R.z))  
     467                offset1 = float3(0,0,1);         
     468    if (abs(R.y) > abs(R.x) && abs(R.y) > abs(R.z)) 
     469                offset2 = float3(0,0,1); 
     470 
     471 
     472    float4 I = 0;                                                                        
     473    float3 L;                                            
     474    float width = 2.0 / M; 
     475             
     476        L = R; 
     477        I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 
     478         
     479        L = R + offset1 * width; 
     480        I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 
     481         
     482        L = R - offset1 * width; 
     483        I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 
     484                 
     485        L = R + offset2 * width; 
     486        I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 
     487                 
     488        L = R - offset2 * width; 
     489        I += Disc2Point_Contr( L * 0.75, pos, N, V, SmallEnvMapSampler, DistanceEnvMapSampler); 
     490                 
     491         
     492   float kd = 1.0; 
     493//return readCubeMap(SmallEnvMapSampler, pos) + lastCenter.x*0.0000000001; 
     494   return kd * I * 2 * M; 
     495} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.material

    r2445 r2471  
    138138material GTP/Diffuse/Disc2Point 
    139139{  
     140   technique 
     141   {  
     142      pass 
     143      {  
     144                 
     145                IllumTechniques 
     146                { 
     147                         
     148                        RenderTechnique DistanceCubeMap 
     149                        { 
     150                                update_interval         0 
     151                                update_all_face         true 
     152                                distance_calc           false 
     153                                face_angle_calc         false 
     154                                resolution                      128                                              
     155                        } 
     156                        RenderTechnique ReducedColorCubeMap 
     157                        { 
     158                                update_interval         1 
     159                                reduced_resolution 4 
     160                                resolution 128 
     161                                distance_calc false 
     162                                face_angle_calc false 
     163                                update_all_face         true 
     164                        } 
     165                }       
     166 
     167                vertex_program_ref GTP/Basic/Shaded_VS 
     168                {        
     169                        param_named_auto WorldViewProj worldviewproj_matrix  
     170                param_named_auto WorldInv      inverse_world_matrix   
     171                param_named_auto World         world_matrix 
     172         
     173                }  
     174                fragment_program_ref GTP/Diffuse/Disc2Point_PS 
     175                {  
     176                    param_named_auto cameraPos camera_position 
     177                        param_named lastCenter float3 0 0 0 
     178                }                
     179                //Cube map for reflections and refractions       
     180                texture_unit 
     181                { 
     182                         
     183                } 
     184                //Cube map of distances 
     185                texture_unit 
     186                 { 
     187                   
     188                 } 
     189         } 
     190   } 
     191} 
     192 
     193material GTP/Glossy/Disc2Point 
     194{  
    140195   technique  
    141196   {  
     
    148203                        RenderTechnique DistanceCubeMap 
    149204                        { 
    150                                 update_interval         1 
    151                                 update_all_face         false 
    152                                 distance_calc           false 
    153                                 face_angle_calc         false 
    154                                 resolution                      128                                              
    155                         } 
    156                         RenderTechnique ReducedColorCubeMap 
    157                         { 
    158                                 update_interval         1 
    159                                 reduced_resolution 4 
    160                                 resolution 128 
    161                                 distance_calc false 
    162                                 face_angle_calc false 
    163                                 update_all_face         false 
    164                         } 
    165                 }       
    166  
    167                 vertex_program_ref GTP/Basic/Shaded_VS 
    168                 {        
    169                         param_named_auto WorldViewProj worldviewproj_matrix  
    170                 param_named_auto WorldInv      inverse_world_matrix   
    171                 param_named_auto World         world_matrix 
    172          
    173                 }  
    174                 fragment_program_ref GTP/Diffuse/Disc2Point_PS 
     205                                update_interval         0 
     206                                update_all_face         true 
     207                                distance_calc           false 
     208                                face_angle_calc         false 
     209                                resolution                      128                                              
     210                        } 
     211                        RenderTechnique ReducedColorCubeMap 
     212                        { 
     213                                update_interval         1 
     214                                reduced_resolution 4 
     215                                resolution 128 
     216                                distance_calc false 
     217                                face_angle_calc false 
     218                                update_all_face         true 
     219                        } 
     220                }       
     221 
     222                vertex_program_ref GTP/Basic/Shaded_VS 
     223                {        
     224                        param_named_auto WorldViewProj worldviewproj_matrix  
     225                param_named_auto WorldInv      inverse_world_matrix   
     226                param_named_auto World         world_matrix 
     227         
     228                }  
     229                fragment_program_ref GTP/Glossy/Disc2Point_PS 
    175230                {  
    176231                    param_named_auto cameraPos camera_position 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse/GTPDiffuse.program

    r2337 r2471  
    2323 
    2424 
     25fragment_program GTP/Glossy/Disc2Point_PS hlsl 
     26{ 
     27        source GTPDiffuse.hlsl 
     28        entry_point Glossy_Disc2Point_PS 
     29        target ps_3_0 
     30        //flow_control prefer 
     31 
     32 
    2533fragment_program GTP/Diffuse/ReduceCubeMap_PS hlsl 
    2634{ 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.hlsl

    r2368 r2471  
    6262                 
    6363        float3 R = refract(V, wNormal, refIndex);                
    64          
     64        if(dot(R,R) == 0) 
     65          R = reflect(V, wNormal);               
     66 
    6567        dir = R;                         
    6668        dir = Hit(cubeMapPos, R, DistanceMap); 
     
    140142  IN.color = CausticColor; 
    141143  float intens = tex2D(intensityTex, IN.texCoord).r; 
    142   IN.color.a *= intens; 
     144  //IN.color.a *= intens; 
     145  IN.color *= IN.color.a * intens; 
     146  IN.color.a = IN.dist; 
    143147  return IN.color;   
    144148} 
     
    149153{ 
    150154        float4 hPosition        : POSITION; 
    151         float4 color            : COLOR0;        
     155        float4 color            : COLOR0; 
     156        float dist              : TEXCOORD0;     
    152157}; 
    153158 
     
    231236                        OUT.color = float4(1,1,1,1);             
    232237        }   
    233     
     238   
     239   OUT.dist = length(pos.xyz); 
    234240   return OUT; 
    235241} 
     
    238244                uniform float4 CausticColor ):COLOR 
    239245{  
    240   return IN.color * CausticColor;   
     246 
     247  return float4(IN.color.rgb * CausticColor.rgb * IN.color.a, IN.dist);   
    241248} 
    242249 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPCaustic/GTPCaustic.material

    r2368 r2471  
    3333  {  
    3434   cull_hardware none 
    35    scene_blend src_alpha one 
     35   scene_blend one one 
     36   scene_blend_alpha one zero 
    3637   depth_check off 
    3738   point_sprites on 
     
    6566  {  
    6667   cull_hardware none 
    67    scene_blend src_alpha one 
     68   scene_blend one one 
     69   scene_blend_alpha one zero 
    6870   depth_write off 
    6971   vertex_program_ref GTP/Caustic/CauCube_Triangles_VS 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPEnvMap/GTPEnvMap.hlsl

    r2409 r2471  
    1313} 
    1414 
    15 #define SECANT_ITERATIONCOUNT 2 
     15#define SECANT_ITERATIONCOUNT 20 
    1616 
    1717float3 Hit( float3 x, float3 R, samplerCUBE mp ) 
     
    9191                                                                                uniform float sRefraction ) :COLOR0 
    9292{ 
     93        float4 Color = 0; 
    9394        float3 N = normalize(IN.wNormal.xyz); 
    9495        float3 RR, TT;   
     
    9798        float3 R = reflect( V, N);       
    9899        float3 T = refract(V, N, sRefraction); 
    99          
     100 
     101                 
    100102        RR = R; TT = T;  
    101103        RR = Hit(cubePos, R, DistanceMap); 
    102         TT = Hit(cubePos, T, DistanceMap); 
     104        float4 reflectcolor = readCubeMap(CubeMap, RR );                 
    103105         
    104         float4 reflectcolor = readCubeMap(CubeMap, RR );                 
    105         float4 refractcolor = readCubeMap(CubeMap, TT );                 
     106        if(dot(T,T)!=0) 
     107        { 
     108                TT = Hit(cubePos, T, DistanceMap); 
     109                float4 refractcolor = readCubeMap(CubeMap, TT );                 
    106110         
    107         float cos_theta = -dot(V, N); 
    108         float F = (sFresnel + pow(1 - cos_theta, 5.0f) * (1 - sFresnel)); 
    109          
    110         return (F * reflectcolor + (1 - F) * refractcolor);      
     111                float cos_theta = -dot(V, N); 
     112                float F = (sFresnel + pow(1 - cos_theta, 5.0f) * (1 - sFresnel)); 
     113                F = saturate(F); 
     114                Color =  (F * reflectcolor + (1 - F) * refractcolor); 
     115        } 
     116        else 
     117        { 
     118                Color = reflectcolor; 
     119        } 
     120  return Color; 
    111121} 
    112122 
Note: See TracChangeset for help on using the changeset viewer.