Changeset 3369 for GTP


Ignore:
Timestamp:
05/13/09 18:33:02 (15 years ago)
Author:
mattausch
Message:

cleaned up code: working ok now

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

Legend:

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

    r3368 r3369  
    104104float farDist = 1e6f; 
    105105/// the field of view 
    106 const float fov = 50.0f; 
     106//const float fov = 50.0f; 
     107const float fov = 90.0f; 
    107108 
    108109float skyDomeScaleFactor = 80.0f; 
     
    627628        //LoadModel("elephal.dem", dynamicObjects); 
    628629 
    629         if (0) LoadPompeiiFloor(); 
     630        if (1) LoadPompeiiFloor(); 
    630631 
    631632#if 1 
     
    643644        // sibenik positions 
    644645        VertexArray positions; 
    645         const float factor2 = 1.6f; 
     646        //const float factor2 = 1.6f; 
     647        const float factor2 = 1.5f; 
     648 
    646649        // for buddha (lowres) 
    647650        positions.push_back(Vector3(6.07307, 8.20723, 6.62 - factor2)); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3368 r3369  
    1010//#define NUM_PRECOMPUTED_SAMPLES 2048 
    1111 
    12 #define NUM_SAMPLES 48 
    1312//#define NUM_SAMPLES 16 
    1413//#define NUM_SAMPLES 24 
    1514//#define NUM_SAMPLES 32 
    16 //#define NUM_SAMPLES 48 
     15#define NUM_SAMPLES 48 
    1716 
    18 #define MIN_SAMPLES 48 
     17#define MIN_SAMPLES 8 
    1918//#define MIN_SAMPLES 48 
    2019 
     
    2827//#define SSAO_CONVERGENCE_THRESHOLD 300.0f 
    2928#define SSAO_CONVERGENCE_THRESHOLD 700.0f 
     29//#define SSAO_CONVERGENCE_THRESHOLD 1300.0f 
    3030//#define SSAO_CONVERGENCE_THRESHOLD 1500.0f 
    3131 
     
    7474#define PERFORMANCE_TEST 1 
    7575 
    76 #define USE_OPTIMIZATION 0 
     76#define USE_OPTIMIZATION 1 
    7777 
    7878 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg

    r3365 r3369  
    253253                // the filtered ssao value 
    254254                ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex,  
    255                                      bl, br, tl, tr,  
    256                                                  xyStep, convergence, maxConvergence, spatialWeight); 
     255                                    bl, br, tl, tr,  
     256                                                xyStep, convergence, maxConvergence, spatialWeight); 
    257257        } 
    258258 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3366 r3369  
    305305                                                 float3 difVec, 
    306306                                                 float3 viewDir, 
    307                                                  float3 oldEyePos 
     307                                                 float3 oldEyePos, 
     308                                                 float4x4 oldModelViewProj 
    308309                                                 ) 
    309310{ 
     
    312313        const float4 worldPos = float4(-viewDir * eyeSpaceDepth, 1.0f); 
    313314        // compute position from old frame for dynamic objects + translational portion 
    314         const float3 translatedPos = -oldEyePos + worldPos.xyz + difVec; 
    315          
     315        float3 translatedPos = -oldEyePos + worldPos.xyz + difVec; 
     316         
     317        ///////////////// 
     318        //-- reproject into old frame and calculate texture position of sample in old frame 
     319 
     320        // note: the old model view matrix only holds the view orientation part 
     321        float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 
     322        backProjPos /= backProjPos.w; 
     323         
     324        // fit from unit cube into 0 .. 1 
     325        const float2 oldTexCoords = backProjPos.xy * .5f + .5f; 
     326 
     327        // check if the pixel was outside of the frame buffer 
     328        if ((oldTexCoords.x <= .0f) || (oldTexCoords.x >= 1.0f) ||  
     329                (oldTexCoords.y <= .0f) || (oldTexCoords.y >= 1.0f) 
     330                ) 
     331        { 
     332                translatedPos = float3(1e15f); 
     333        } 
     334 
    316335        return translatedPos; 
    317336} 
     
    362381        pix.color.z = color.w; 
    363382*/ 
    364         const float3 translatedPos = ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos); 
     383        const float3 translatedPos = ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj); 
    365384 
    366385        pix.color.xyz = translatedPos; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3368 r3369  
    359359                { 
    360360                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    361                         //offset = myreflect(samples[i], mynoise); 
    362361                        //offset = myrotate(samples[i], mynoise.x); 
    363362                        offset = myrotate(ssaoOffset, mynoise.x); 
     
    418417                const float tooFarAway = step(.5f, lengthToSample - changeFactor); 
    419418                if (0)//pixelValid <= partlyResetThres) 
    420                         validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
     419                        validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-.1f, cosAngle)); 
    421420                else 
    422421                        validSamples = max(validSamples, pixelValid); 
     
    550549                const float3 oldVector = oldSamplePos - oldPos; 
    551550                const float oldDistance = length(oldVector); 
    552                 const float cosAngle2 = dot(oldVector, normal); 
    553  
    554                 if ((cosAngle >= 0) || (cosAngle2 >= 0)) 
    555                 { 
    556                         const float oldDistance = length(oldSamplePos - oldPos); 
    557                         const float distanceDiff = abs(oldDistance - lengthToSample); 
    558  
    559                         float pixelValid = (distanceDiff > 1e-3f) ? 100.0f : 0; 
    560  
    561                         validSamples = max(validSamples, pixelValid); 
    562                 } 
     551                //const float cosAngle2 = dot(oldVector, normal); 
     552                 
     553                const float distanceDiff = abs(oldDistance - lengthToSample); 
     554 
     555                float pixelValid = (oldSamplePos.x > 1e14f) ? 100.0f : .0f; 
     556 
     557                if ((cosAngle >= 0) && (pixelValid < 90.0f))// || (cosAngle2 >= 0)) 
     558                { 
     559                        //pixelValid = (distanceDiff > 1e-3f) ? 100.0f : .0f; 
     560                        pixelValid = (distanceDiff > 1e-3f) ? 5.0f : .0f; 
     561                } 
     562 
     563                validSamples = max(validSamples, pixelValid); 
     564 
    563565#ifdef USE_GTX 
    564566                // we can bail out early and use a minimal #samples) 
     
    682684 
    683685        float3 ao; 
    684         // $$temp matt 
    685         oldIdx = dummyIdx; 
     686        //$$temp matt 
     687        //oldIdx = dummyIdx; 
    686688 
    687689        // cull background note: this should be done with the stencil buffer 
     
    708710                                   bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity,  
    709711                                           isMovingObject, normals, oldIdx); 
    710                                            */ 
     712                        */ 
    711713                } 
    712714        } 
     
    730732        const float partlyResetThres = 1.0f; 
    731733         
     734        // the new index for the next frame 
     735        float newIdx; 
     736        // the new weight for the next frame 
     737        float combinedWeight; 
     738 
    732739        // don't check for moving objects, otherwise almost no coherence 
    733         if (1)//!isMovingObject) 
    734         { 
    735                 if (ao.y > completelyResetThres)  
    736                 { 
    737                         oldWeight = .0f; 
    738                         oldIdx    = .0f; 
    739                 } 
    740                 else if (ao.y > partlyResetThres) 
    741                 { 
    742                         const float factor = 4.0f; 
    743                         //if (oldIdx >= factor * newWeight) oldIdx = 0; 
    744                         //oldWeight = min(oldWeight, factor * newWeight); 
    745                         oldWeight = oldIdx = .0f;  
    746                 } 
    747         } 
     740        if (ao.y > completelyResetThres)  
     741        { 
     742                oldWeight = newIdx = .0f; 
     743        } 
     744        else 
     745        { 
     746                newIdx = oldIdx + newWeight; 
     747        } 
     748 
     749        if (ao.y > partlyResetThres) 
     750        { 
     751                const float factor = 3.0f; 
     752 
     753                oldWeight = min(oldWeight, factor * NUM_SAMPLES); 
     754                if (newIdx >= factor * NUM_SAMPLES) {newIdx = 0; /*oldWeight = .0f;*/ } 
     755 
     756                //combinedWeight = oldWeight; 
     757        } 
     758 
     759        // the new weight for the next frame 
     760        combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    748761 
    749762 
     
    756769        //OUT.illum_col.x = ao.y; 
    757770 
    758         // the new weight for the next frame 
    759         const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    760  
    761771        OUT.illum_col.y = combinedWeight; 
    762         OUT.illum_col.z = oldIdx + newWeight; // the new index 
     772        OUT.illum_col.z = newIdx; // the new index 
    763773        OUT.illum_col.w = eyeSpaceDepth; 
    764774 
Note: See TracChangeset for help on using the changeset viewer.