Ignore:
Timestamp:
07/02/07 04:04:08 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPAdvancedEnvMap/diffuse
Files:
3 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{ 
Note: See TracChangeset for help on using the changeset viewer.