Changeset 3316 for GTP


Ignore:
Timestamp:
02/17/09 19:21:52 (15 years ago)
Author:
mattausch
Message:

surpressed blur, worked on object placing in sibenik (why performance worse than vienna??)

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3313 r3316  
    9191/** Helper method that computes the view vectors in the corners of the current view frustum. 
    9292*/ 
    93 static void ComputeViewVectors(PerspectiveCamera *cam, Vector3 &bl, Vector3 &br, Vector3 &tl, Vector3 &tr) 
     93static void ComputeViewVectors(PerspectiveCamera *cam,  
     94                                                           Vector3 &bl,  
     95                                                           Vector3 &br,  
     96                                                           Vector3 &tl,  
     97                                                           Vector3 &tr) 
    9498{ 
    9599        Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 
     
    304308mUseAntiAliasing(false), 
    305309mUseDepthOfField(false), 
    306 mSsaoUseFullResolution(ssaoUseFullResolution) 
     310mSsaoUseFullResolution(ssaoUseFullResolution), 
     311mMaxConvergence(2000.0f) 
    307312{ 
    308313        /////////// 
     
    460465 
    461466        string combineSsaoParams[] =  
    462         {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res"}; 
     467                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 
    463468 
    464469        //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 
    465         sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 7); 
     470        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 8); 
    466471 
    467472         
     
    469474 
    470475        string filterSsaoParams[] =  
    471                 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res"}; 
    472  
    473         sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 7); 
     476                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 
     477 
     478        sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 8); 
    474479 
    475480 
     
    980985 
    981986        sCgFilterSsaoProgram->SetValue2f(i ++, (float)mWidth, (float)mHeight); 
     987        sCgFilterSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 
    982988 
    983989        DrawQuad(sCgFilterSsaoProgram); 
     
    10061012 
    10071013        sCgCombineSsaoProgram->SetValue2f(i ++, mWidth, mHeight); 
     1014        sCgCombineSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 
    10081015 
    10091016        DrawQuad(sCgCombineSsaoProgram); 
     
    15061513 
    15071514 
     1515void DeferredRenderer::SetMaxConvergence(float c) 
     1516{ 
     1517        mMaxConvergence = c; 
     1518} 
     1519 
     1520 
    15081521} // namespace 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3305 r3316  
    9595        void SetTemporalCoherenceFactorForSsao(float factor); 
    9696 
     97        /** Sets the maxinal convergence factor for ssao filter 
     98        */ 
     99        void SetMaxConvergence(float c); 
     100 
    97101 
    98102        // hack: store the color buffer idx for the currently used flip flop-MRT here 
     
    222226 
    223227        bool mSsaoUseFullResolution; 
     228 
     229        float mMaxConvergence; 
    224230}; 
    225231 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3315 r3316  
    286286float viewCellsScaleFactor = 1.0f; 
    287287 
     288float maxConvergence = 2000.0f; 
     289 
     290 
    288291 
    289292////////////// 
     
    377380inline float KeyShift() { return keyForwardMotion * elapsedTime * 1e-3f; } 
    378381 
    379 void CreateAnimation(); 
     382void CreateAnimation(const Vector3 &pos); 
    380383 
    381384SceneQuery *GetOrCreateSceneQuery(); 
     
    390393 
    391394void LoadOrUpdatePVSs(const Vector3 &pos); 
     395 
     396void CreateNewInstance(SceneEntity *parent, const Vector3 &pos); 
     397 
     398 
     399///////////// 
    392400 
    393401string envFileName = "default.env"; 
     
    626634 
    627635#if 1 
    628         const Vector3 sceneCenter(470.398f, 240.364f, 181.7f); 
     636 
     637#if 0 
     638        VertexArray positions; 
     639        positions.push_back(Vector3(478.398f, 268.0f, 181.3)); 
     640        positions.push_back(Vector3(470.461, 268.543, 181.7)); 
     641        positions.push_back(Vector3(499.648, 264.358, 181.7)); 
     642        positions.push_back(Vector3(487.913, 285.162, 181.7)); 
     643 
     644#else 
     645 
     646        VertexArray positions; 
     647        //positions.push_back(Vector3(6.07307, 8.20723, 6.7)); 
     648        positions.push_back(Vector3(6.07307, 8.20723, 6.62)); 
     649        positions.push_back(Vector3(-17.1935, 11.1687, 8.8781)); 
     650        //positions.push_back(Vector3(499.648, 264.358, 181.7)); 
     651        //positions.push_back(Vector3(487.913, 285.162, 181.7)); 
     652 
     653#endif 
     654 
    629655        //const Vector3 sceneCenter(470.398f, 240.364f, 180.3); 
    630         Matrix4x4 transl = TranslationMatrix(sceneCenter); 
     656        Matrix4x4 transl = TranslationMatrix(positions[0]); 
    631657         
    632658        LoadModel("hbuddha.dem", dynamicObjects); 
     
    635661        buddha->GetTransform()->SetMatrix(transl); 
    636662 
    637         for (int i = 0; i < 10; ++ i) 
    638         { 
    639                 SceneEntity *ent = new SceneEntity(*buddha); 
    640                 resourceManager->AddSceneEntity(ent); 
    641  
    642                 Vector3 offs = Vector3::ZERO(); 
    643  
    644                 offs.x = RandomValue(.0f, 50.0f); 
    645                 offs.y = RandomValue(.0f, 50.0f); 
    646  
    647                 Vector3 newPos = sceneCenter + offs; 
    648  
    649                 transl = TranslationMatrix(newPos); 
    650                 Transform3 *transform = resourceManager->CreateTransform(transl); 
    651  
    652                 ent->SetTransform(transform); 
    653                 dynamicObjects.push_back(ent); 
    654         } 
     663         
     664        for (size_t i = 1; i < positions.size(); ++ i) 
     665        { 
     666                CreateNewInstance(buddha, positions[i]); 
     667        } 
     668 
    655669#endif 
    656670 
     
    706720        preetham = new SkyPreetham(turbitity, skyDome); 
    707721 
    708         CreateAnimation(); 
     722        CreateAnimation(positions[0]); 
    709723 
    710724 
     
    11511165 
    11521166                //const float rotAngle = M_PI * 1e-3f; 
    1153                 const float rotAngle = 0.3f * M_PI / 180.0f; 
    1154                 //const float rotAngle = 1.0f * M_PI / 180.0f; 
     1167                //const float rotAngle = 0.3f * M_PI / 180.0f; 
     1168                const float rotAngle = 0.6f * M_PI / 180.0f; 
    11551169 
    11561170                Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 
     1171                // hack: second buddha 
    11571172                dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
    11581173 
    1159                 const float moveSpeed = 5e-3f; 
     1174                //const float moveSpeed = 5e-3f; 
     1175                const float moveSpeed = 1e-1f; 
    11601176                motionPath->Move(moveSpeed); 
    11611177        } 
     
    14121428                deferredShader->SetUseToneMapping(useHDR); 
    14131429                deferredShader->SetUseAntiAliasing(useAntiAliasing); 
     1430                deferredShader->SetMaxConvergence(maxConvergence); 
    14141431 
    14151432 
     
    15821599                traverser->SetUseOptimization(useOptimization); 
    15831600                break;*/ 
     1601        case 'o': 
     1602        case 'O': 
     1603                if (maxConvergence > 100.0f) 
     1604                        maxConvergence = 1.0f; 
     1605                else  
     1606                        maxConvergence = 5000.0f; 
     1607 
     1608                cout << "max convergence: " << maxConvergence << endl; 
     1609 
     1610                break; 
    15841611        case 'l': 
    15851612        case 'L': 
     
    25952622 
    25962623 
    2597 void CreateAnimation() 
    2598 { 
    2599         const float radius = 5.0f; 
    2600         //const Vector3 center(480.398f, 268.364f, 181.3); 
    2601         const Vector3 center(480.398f, 269.364f, 181.3); 
     2624void CreateAnimation(const Vector3 &pos) 
     2625{ 
     2626        //const float b = 5.0f; const float a = 1.5f; 
     2627        const float a = 5.0f; const float b = 1.5f; 
    26022628 
    26032629        VertexArray vertices; 
    26042630 
    2605         /*for (int i = 0; i < 360; ++ i) 
    2606         { 
    2607                 float angle = (float)i * M_PI / 180.0f; 
    2608  
    2609                 Vector3 offs = Vector3(cos(angle) * radius, sin(angle) * radius, 0); 
     2631        for (int i = 0; i < 360; ++ i) 
     2632        { 
     2633                const float angle = (float)i * M_PI / 180.0f; 
     2634 
     2635                Vector3 offs = Vector3(cos(angle) * a, sin(angle) * b, 0); 
     2636                vertices.push_back(pos + offs); 
     2637        } 
     2638 
     2639        /*for (int i = 0; i < 5; ++ i) 
     2640        { 
     2641                Vector3 offs = Vector3(i, 0, 0); 
     2642                vertices.push_back(center + offs); 
     2643        } 
     2644         
     2645        for (int i = 0; i < 5; ++ i) 
     2646        { 
     2647                Vector3 offs = Vector3(4 - i, 0, 0); 
    26102648                vertices.push_back(center + offs); 
    26112649        }*/ 
    26122650 
    2613         for (int i = 0; i < 5; ++ i) 
    2614         { 
    2615                 Vector3 offs = Vector3(i, 0, 0); 
    2616                 vertices.push_back(center + offs); 
    2617         } 
    2618  
    2619          
    2620         for (int i = 0; i < 5; ++ i) 
    2621         { 
    2622                 Vector3 offs = Vector3(4 -i, 0, 0); 
    2623                 vertices.push_back(center + offs); 
    2624         } 
    2625  
    26262651        motionPath = new MotionPath(vertices); 
    26272652} 
     2653 
    26282654 
    26292655/** This function returns the number of visible pixels of a 
     
    28052831        if (viewCellsTree) UpdatePvs(pos); 
    28062832} 
     2833 
     2834 
     2835void CreateNewInstance(SceneEntity *parent, const Vector3 &pos) 
     2836{ 
     2837        SceneEntity *ent = new SceneEntity(*parent); 
     2838        resourceManager->AddSceneEntity(ent); 
     2839 
     2840        Matrix4x4 transl = TranslationMatrix(pos); 
     2841        Transform3 *transform = resourceManager->CreateTransform(transl); 
     2842 
     2843        ent->SetTransform(transform); 
     2844        dynamicObjects.push_back(ent); 
     2845        //Debug << "positions: " << newPos << endl; 
     2846} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg

    r3314 r3316  
    5858                                        float3 br, 
    5959                                        float3 tl, 
    60                                         float3 tr) 
     60                                        float3 tr, 
     61                                        float maxConvergence) 
    6162{ 
    6263        float2 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 
     
    7273        float spatialFactor = 1.0f / max(len, 1e-3f); 
    7374 
    74         float convergenceFactor = aoSample.y + 1.0f; 
     75        float convergenceFactor = min(aoSample.y + 1.0f, maxConvergence); 
     76        convergenceFactor *= convergenceFactor; 
    7577 
    7678        // combine the weights 
    77         //float w = convergenceFactor * convergenceFactor * spatialFactor; 
    7879        float w = convergenceFactor * spatialFactor; 
    7980        //float w = spatialFactor; 
     
    9697                           float3 tr, 
    9798                           float2 xyStep, 
    98                            float convergence) 
     99                           float convergence, 
     100                           float maxConvergence 
     101                           ) 
    99102{ 
    100103        float2 result = float2(0.0f, 0.0f); 
     
    109112        { 
    110113                float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 
    111                 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr); 
     114                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence); 
    112115        } 
    113116 
     
    148151        { 
    149152                // the filtered ssao value 
    150                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 
     153                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
    151154        } 
    152155 
     
    163166                                                uniform float3 tl, 
    164167                                                uniform float3 tr, 
    165                                                 uniform float2 res 
     168                                                uniform float2 res, 
     169                                                uniform float maxConvergence 
    166170                                                ) 
    167171{ 
     
    183187        { 
    184188                // the filtered ssao value 
    185                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 
     189                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
    186190        } 
    187191 
     
    200204                                  uniform float3 tl, 
    201205                                  uniform float3 tr, 
    202                                   uniform float2 res 
     206                                  uniform float2 res, 
     207                                  uniform float maxConvergence 
    203208                                  ) 
    204209{ 
     
    221226        { 
    222227                // the filtered ssao value 
    223                 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 
     228                ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
    224229        } 
    225230 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3314 r3316  
    4848        weight of the pixel in the new frame. 
    4949*/ 
    50 inline float2 temporalSmoothing(float4 worldPos, 
     50inline float2 Reproject(float4 worldPos, 
    5151                                                                float eyeSpaceDepth, 
    5252                                                                float2 texcoord0, 
     
    107107        { 
    108108                // pixel valid => retrieve the convergence weight 
    109                 w = oldPixel.y; 
     109                float w1 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 
     110                float w2 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 
     111                float w3 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0, 0.5f / 768.0f), .0f, .0f)).y; 
     112                float w4 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0, 0.5f / 768.0f), .0f, .0f)).y; 
     113 
     114                w = min(min(w1, w2), min(w3, w4)); 
     115                //w = oldPixel.y; 
    110116        } 
    111117        else 
     
    385391        //-- compute temporal reprojection 
    386392 
    387         float2 temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 
    388                                                 oldTex, oldModelViewProj,  
    389                                                                                         colors,  
    390                                                                                         projPos.xyz,  
    391                                                                                         invw,  
    392                                                                                         oldbl, oldbr, oldtl, oldtr, 
    393                                                                                         diffVec 
    394                                                                                         ); 
     393        float2 temporalVals = Reproject(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 
     394                                        oldTex, oldModelViewProj,  
     395                                                                        colors,  
     396                                                                        projPos.xyz,  
     397                                                                        invw,  
     398                                                                        oldbl, oldbr, oldtl, oldtr, 
     399                                                                        diffVec 
     400                                                                        ); 
    395401 
    396402        const float oldSsao = temporalVals.x; 
Note: See TracChangeset for help on using the changeset viewer.