Changeset 1534


Ignore:
Timestamp:
09/29/06 09:06:21 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/EnvMap
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/EnvMap/.matrix

    r1488 r1534  
    11 
    22World matrix: 
    3          1          0          0          0 
    4          0          1          0          0 
    5          0          0          1          0 
    6          0          0       6.82          1 
     3         1  -0.003845  -0.004636          0 
     4  0.004172     0.9974    0.07259          0 
     5  0.004345   -0.07261     0.9974          0 
     6-1.863e-009 -5.96e-008       6.82          1 
    77 
    88Camera position: 
    9          0          0      -6.82 
     9 0.0316175  -0.495054   -6.80194 
    1010 
    1111Mesh position: 
    12       -1.4          0          0 
     12-0.0666665          0          0 
  • GTP/trunk/App/Demos/Illum/EnvMap/.params

    r1488 r1534  
    1147 version ----- RayTraceEffects: Saved parameters of the algorithm ----- 
    22Bool values: 
    3 0001 
    4 (Help [F1]; [A]utoGenCubeMap; ; [F]ireballs; Multiple [O]bjects; Between [W]alls only; ) 
     30111 
     4(Help [F1]; [F]ireballs; Multiple [O]bjects; Between [W]alls only; ) 
    55Float values: 
    6 2       (WhichMethod [Q,TAB], 0..2) 
     63       (WhichMethod [TAB,Q], 0..3) 
    778       (WhichMesh [Home,End], 0..9) 
    8834      (Mesh size [Ins,Del], 0..100) 
  • GTP/trunk/App/Demos/Illum/EnvMap/EnvMap.cpp

    r1488 r1534  
    288288                        sprintf(techniqueName, "EnvMapDiffuseLocalized%i", LR_CUBEMAP_SIZE ); 
    289289                        V( g_pEffect->SetTechnique( techniqueName ) ); 
     290                        break; 
     291                case DIFFUSE_SPECULAR_LOCALIZED_NEW: 
     292                        sprintf(techniqueName, "EnvMapDiffuseLocalizedNew%i", LR_CUBEMAP_SIZE ); 
     293                        V( g_pEffect->SetTechnique( "EnvMapDiffuseLocalizedNew" ) ); 
    290294                        break; 
    291295                case DIFFUSE_SPECULAR_LOCALIZED_5TEX: 
  • GTP/trunk/App/Demos/Illum/EnvMap/EnvMap.fx

    r1488 r1534  
    455455} 
    456456 
     457// Method #3 
     458 
     459/// \brief Calculates diffuse or specular contributions of the 5 "most important" texels of #SmallEnvironmentMap to the current point. 
     460/// For these texels, function GetContr(int,float3,float3,float3,float3) is called. 
     461float4 GetContibution(float3 L1, float3 L2, float3 L3, float3 L4, float3 pos, float3 N, float d) 
     462{ 
     463        L1 = d * normalize(L1); 
     464        L2 = d * normalize(L2); 
     465        L3 = d *  normalize(L3); 
     466        L4 = d * normalize(L4);  
     467         
     468    float3 r1 = normalize(L1 - pos);     
     469    float3 r2 = normalize(L2 - pos); 
     470    float3 r3 = normalize(L3 - pos); 
     471    float3 r4 = normalize(L4 - pos); 
     472    
     473     
     474        float kd = 0.3; // 0.3 
     475        /* 
     476        float3 R; 
     477        R = cross(r1, r2); 
     478        float tri1 = asin(length(R)) * dot(R, N); 
     479        R = cross(r2, r3); 
     480        float tri2 = asin(length(R)) * dot(R, N); 
     481        R = cross(r3, r4); 
     482        float tri3 = asin(length(R)) * dot(R, N); 
     483        R = cross(r4, r1); 
     484        float tri4 = asin(length(R)) * dot(R, N); 
     485        */ 
     486         
     487        float tri1 = acos(dot(r1, r2)) * dot(cross(r1, r2), N); 
     488        float tri2 = acos(dot(r2, r3)) * dot(cross(r2, r3), N); 
     489        float tri3 = acos(dot(r3, r4)) * dot(cross(r3, r4), N); 
     490        float tri4 = acos(dot(r4, r1)) * dot(cross(r4, r1), N); 
     491         
     492        return max(tri1 + tri2 + tri3 + tri4, 0);        
     493        //return tri1 + tri2 + tri3 + tri4;      
     494} 
     495 
     496float4 EnvMapDiffuseLocalizedNewPS( _EnvMapVS_output IN ) : COLOR                        
     497{                
     498        float M = 4.0;                                                                                                                                                   
     499        IN.View = -normalize( IN.View );                                                                                                 
     500        IN.Normal = normalize( IN.Normal );                                                                                              
     501        IN.Position -= reference_pos.xyz;                                
     502        float3 pos = IN.Position.xyz;    
     503         
     504        //return        reference_pos; 
     505        //return  texCUBE(SmallEnvironmentMapSampler, pos);      
     506                                                                                                 
     507        float3 N =IN.Normal;                                                                                                                                                             
     508        float3 R = -reflect( IN.View, IN.Normal );               
     509                                                                                                         
     510    float4 I = 0;                                                                        
     511        float3 L1, L2, L3, L4, L;                                                
     512        float4 Le;                                                                               
     513        float d;                                                                                 
     514        float width = 1.0 / M;                                                   
     515         
     516        for (int x = 0; x < M; x++)                      
     517         for (int y = 0; y < M; y++)                                                                                     
     518         {                                                                                                                               
     519                float2 p, tpos;  
     520            tpos.x = (x + 0.5) * width; // 0..1 
     521            tpos.y = (y + 0.5) * width; // 0..1 
     522             
     523            p = tpos.xy;     
     524            p = 2.0 * p - 1.0; //-1..1 
     525                             
     526                L1 = float3(p.x - width, p.y - width, 1);        
     527                L2 = float3(p.x + width, p.y - width, 1);        
     528                L3 = float3(p.x + width, p.y + width, 1);        
     529                L4 = float3(p.x - width, p.y + width, 1); 
     530                L = float3(p.x, p.y, 1); 
     531                Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 
     532                d = texCUBE(SmallEnvironmentMapSampler, L).a;    
     533                 
     534                I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d);                      
     535                //I += Le / 16.0; 
     536         }                                                                                                                                                       
     537                         
     538        for (int x = 0; x < M; x++)                      
     539         for (int y = 0; y < M; y++)                                                                                     
     540         {                                                                                                                               
     541                float2 p, tpos;  
     542            tpos.x = (x + 0.5) * width; // 0..1 
     543            tpos.y = (y + 0.5) * width; // 0..1 
     544             
     545            p = tpos.xy;     
     546            p = 2.0 * p - 1.0; //-1..1 
     547                             
     548                L4 = float3(p.x - width, p.y - width, -1);       
     549                L3 = float3(p.x + width, p.y - width, -1);       
     550                L2 = float3(p.x + width, p.y + width, -1);       
     551                L1 = float3(p.x - width, p.y + width, -1); 
     552                L = float3(p.x, p.y, -1); 
     553                Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 
     554                d = texCUBE(SmallEnvironmentMapSampler, L).a;    
     555                 
     556                I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d);                      
     557                //I += Le / 16.0; 
     558         }       
     559          
     560        for (int x = 0; x < M; x++)                      
     561         for (int y = 0; y < M; y++)                                                                                     
     562         {                                                                                                                               
     563                float2 p, tpos;  
     564            tpos.x = (x + 0.5) * width; // 0..1 
     565            tpos.y = (y + 0.5) * width; // 0..1 
     566             
     567            p = tpos.xy;     
     568            p = 2.0 * p - 1.0; //-1..1 
     569                             
     570                L4 = float3(p.x - width, 1, p.y - width); 
     571                L3 = float3(p.x + width, 1, p.y - width);        
     572                L2 = float3(p.x + width, 1, p.y + width);        
     573                L1 = float3(p.x - width, 1, p.y + width);                        
     574                L = float3(p.x, 1, p.y); 
     575                Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 
     576                d = texCUBE(SmallEnvironmentMapSampler, L).a;    
     577                 
     578                I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d);                      
     579                //I += Le / 16.0; 
     580         }               
     581          
     582        for (int x = 0; x < M; x++)                      
     583         for (int y = 0; y < M; y++)                                                                                     
     584         {                                                                                                                               
     585                float2 p, tpos;  
     586            tpos.x = (x + 0.5) * width; // 0..1 
     587            tpos.y = (y + 0.5) * width; // 0..1 
     588             
     589            p = tpos.xy;     
     590            p = 2.0 * p - 1.0; //-1..1 
     591                             
     592                L1 = float3(p.x - width, -1, p.y - width); 
     593                L2 = float3(p.x + width, -1, p.y - width);       
     594                L3 = float3(p.x + width, -1, p.y + width);       
     595                L4 = float3(p.x - width, -1, p.y + width);                       
     596                L = float3(p.x, -1, p.y); 
     597                Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 
     598                d = texCUBE(SmallEnvironmentMapSampler, L).a;    
     599                 
     600                I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d);                      
     601                //I += Le / 16.0; 
     602         } 
     603         for (int x = 0; x < M; x++)                     
     604         for (int y = 0; y < M; y++)                                                                                     
     605         {                                                                                                                               
     606                float2 p, tpos;  
     607            tpos.x = (x + 0.5) * width; // 0..1 
     608            tpos.y = (y + 0.5) * width; // 0..1 
     609             
     610            p = tpos.xy;     
     611            p = 2.0 * p - 1.0; //-1..1 
     612                             
     613                L1 = float3(1, p.x - width, p.y - width); 
     614                L2 = float3(1, p.x + width, p.y - width);        
     615                L3 = float3(1, p.x + width, p.y + width);        
     616                L4 = float3(1, p.x - width, p.y + width);        
     617                L = float3(1, p.x, p.y); 
     618                Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 
     619                d = texCUBE(SmallEnvironmentMapSampler, L).a;    
     620                 
     621                I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d);                      
     622                //I += Le / 16.0; 
     623         } 
     624          
     625         for (int x = 0; x < M; x++)                     
     626         for (int y = 0; y < M; y++)                                                                                     
     627         {                                                                                                                               
     628                float2 p, tpos;  
     629            tpos.x = (x + 0.5) * width; // 0..1 
     630            tpos.y = (y + 0.5) * width; // 0..1 
     631             
     632            p = tpos.xy;     
     633            p = 2.0 * p - 1.0; //-1..1 
     634                             
     635                L4 = float3(-1, p.x - width, p.y - width); 
     636                L3 = float3(-1, p.x + width, p.y - width);       
     637                L2 = float3(-1, p.x + width, p.y + width);       
     638                L1 = float3(-1, p.x - width, p.y + width);       
     639                L = float3(-1, p.x, p.y); 
     640                Le = float4(texCUBE(SmallEnvironmentMapSampler, L).rgb, 1); 
     641                d = texCUBE(SmallEnvironmentMapSampler, L).a;    
     642                 
     643                I += 0.5 * Le * GetContibution( L1, L2, L3, L4, pos, N, d);                      
     644                //I += Le / 16.0; 
     645         }                                                                                                                                                                       
     646        return intensity * I;                                                                                                                    
     647} 
     648 
    457649 
    458650//-------------------------------------------------------------------------------------- 
     
    552744TechniqueUsingCommonVS( EnvMapDiffuseLocalized16 ); 
    553745 
     746TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew ); 
     747//TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew4 ); 
     748//TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew8 ); 
     749//TechniqueUsingCommonVS( EnvMapDiffuseLocalizedNew16 ); 
     750 
    554751#define ReduceTextureTechnique(M);                                                                      \ 
    555752        technique ReduceTexture##M                                                                              \ 
  • GTP/trunk/App/Demos/Illum/EnvMap/Main.cpp

    r1488 r1534  
    199199 
    200200        // SLIDERS 
    201         pp.Add( iWhichMethod, "WhichMethod [TAB,Q]", 2, VK_TAB, 'Q', noconvert, OnChangeCubeMap );       
     201        pp.Add( iWhichMethod, "WhichMethod [TAB,Q]", 3, VK_TAB, 'Q', noconvert, OnChangeCubeMap );       
    202202        pp.Add( iWhichMesh, "WhichMesh [Home,End]", 9, VK_HOME, VK_END, noconvert, OnChangeMesh );       
    203203        pp.Add( fMeshScale, "Mesh size [Ins,Del]", 100, VK_DELETE, VK_INSERT, noconvert, OnChangeMeshSize );     
     
    700700                        else 
    701701                                txtHelper.DrawFormattedTextLine( L"Method : Our method (diffuse)");  
     702                        break; 
     703                case DIFFUSE_SPECULAR_LOCALIZED_NEW: 
     704                        if (pp.GetInt( iShininess ) > 0) 
     705                                txtHelper.DrawFormattedTextLine( L"Method : Our method New (specular, s=%i)", 
     706                                        pp.GetInt( iShininess ));  
     707                        else 
     708                                txtHelper.DrawFormattedTextLine( L"Method : Our method New (diffuse)");  
    702709                        break; 
    703710                case DIFFUSE_SPECULAR_LOCALIZED_5TEX: 
  • GTP/trunk/App/Demos/Illum/EnvMap/Parameters.h

    r1488 r1534  
    1616        DIFFUSE_SPECULAR_CLASSIC,               ///< Classic environment mapping technique. 
    1717        DIFFUSE_SPECULAR_LOCALIZED,             ///< Our proposal. 
    18         DIFFUSE_SPECULAR_LOCALIZED_5TEX ///< Our proposal, using 5 texel only. 
     18        DIFFUSE_SPECULAR_LOCALIZED_5TEX,        ///< Our proposal, using 5 texel only. 
     19        DIFFUSE_SPECULAR_LOCALIZED_NEW          ///< Our proposal.       
    1920} method_t; 
    2021 
Note: See TracChangeset for help on using the changeset viewer.