Changeset 3309 for GTP


Ignore:
Timestamp:
02/13/09 11:49:44 (15 years ago)
Author:
mattausch
Message:

working on changed sampling scheme for temporal coherence

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env

    r3296 r3309  
    106106ssaoSampleIntensity=0.8f 
    107107# ssao temporal coherence factor 
    108 tempCohFactor=2000.0f 
     108tempCohFactor=150.0f 
    109109# ssao filter radius 
    110110ssaoFilterRadius=12.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3308 r3309  
    7373 
    7474 
     75 
     76static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
    7577// ssao random spherical samples 
    7678//static Sample2 samples2[NUM_SAMPLES]; 
    77 #define NUM_PRECOMPUTED_SAMPLES 2001 
    78  
    79 static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
     79 
    8080// pcf samples 
    8181static Sample2 pcfSamples[NUM_PCF_TABS]; 
     
    743743        sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
    744744         
    745         static int currentPos = 0; 
    746  
    747745        if (/*mUseTemporalCoherence || */mRegenerateSamples) 
    748746        { 
     
    752750                // in the first case, the sample patterns look nicer, but the kernel 
    753751                // needs longer to converge 
    754                 //if (currentPos + NUM_SAMPLES >= NUM_PRECOMPUTED_SAMPLES)      { 
    755                         currentPos = 0; 
    756                         GenerateSamples(mSamplingMethod); 
    757                 //} 
     752                GenerateSamples(mSamplingMethod); 
    758753 
    759754                //if (mSortSamples) { SortSamples(); } 
    760                 //sCgSsaoProgram->SetArray2f(i, (float *)samples2 + currentPos, NUM_SAMPLES); 
    761                 sCgSsaoProgram->SetArray2f(i, (float *)samples2 + currentPos, NUM_PRECOMPUTED_SAMPLES); 
    762  
    763                 currentPos += NUM_SAMPLES; 
    764         } 
    765          
     755                //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 
     756                sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_PRECOMPUTED_SAMPLES); 
     757        } 
     758         
     759 
    766760        ++ i; 
    767761 
    768762        for (int j = 0; j < 4; ++ j, ++ i) 
     763        { 
    769764                sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
     765        } 
    770766 
    771767        sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3306 r3309  
    55//////////// 
    66//-- ssao + gi parameters 
    7  
     7#define NUM_PRECOMPUTED_SAMPLES 200 
    88//#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3306 r3309  
    269269        const float pixelIsValid = 0.0f; 
    270270        // means that we only use slight temporal coherence over some frames 
    271         // so that there si no noticeable drag 
     271        // so that there is no noticeable drag 
    272272        const float pixelCouldBeValid = 2.0f; 
    273273        // this pixel information has to be discarded in order to not create artifacts 
    274274        const float pixelIsNotValid = 100.0f; 
    275275 
    276         const float xOffs = 0;// 0.5f / 1024.0f; 
    277         const float yOffs = 0;// 0.5f / 768.0f; 
    278  
    279         if ((oldTexCoords.x < xOffs) || (oldTexCoords.x > (1.0f - xOffs)) ||  
    280                 (oldTexCoords.y < yOffs) || (oldTexCoords.y > (1.0f - yOffs)) 
     276        // check if the pixel was outside of the frame buffer 
     277        if ((oldTexCoords.x <= 0) || (oldTexCoords.x >= 1.0f) ||  
     278                (oldTexCoords.y <= 0) || (oldTexCoords.y >= 1.0f) 
    281279                ) 
    282280        { 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3307 r3309  
    142142        float validSamples = .0f; 
    143143 
    144         for (int i = 0; i < NUM_SAMPLES; ++ i)  
     144        for (int i = 0; i < NUM_PRECOMPUTED_SAMPLES; ++ i)  
    145145        { 
    146146                const float2 offset = samples[i]; 
     
    220220                        sampler2D colors, 
    221221                        sampler2D noiseTex, 
    222                         float2 samples[NUM_SAMPLES], 
     222                        float2 samples[NUM_PRECOMPUTED_SAMPLES], 
    223223                        float3 normal, 
    224224                        float3 centerPosition, 
     
    231231                        float convergence, 
    232232                        float sampleIntensity, 
    233                         bool isMovingObject 
     233                        bool isMovingObject, 
     234                        int idx 
    234235                        ) 
    235236{ 
     
    237238        float validSamples = .0f; 
    238239        float numSamples = .0f; 
    239  
     240         
    240241        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    241242        { 
     
    250251                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    251252                        //offset = myreflect(samples[i], mynoise); 
    252                         offset = myrotate(samples[i + (int)convergence], mynoise.x); 
     253                        offset = myrotate(samples[i + idx], mynoise.x); 
    253254                } 
    254255                else 
    255256                { 
    256                         offset = samples[i]; 
     257                        offset = samples[i + idx]; 
    257258                } 
    258259                 
     
    334335                   uniform sampler2D normals, 
    335336                   uniform sampler2D noiseTex, 
    336                    uniform float2 samples[NUM_SAMPLES], 
     337                   uniform float2 samples[NUM_PRECOMPUTED_SAMPLES], 
    337338                   uniform sampler2D oldTex, 
    338339                   uniform float4x4 modelViewProj, 
     
    394395 
    395396        float usedWeight = min(temporalCoherence, abs(oldWeight)); 
     397        int idx = (int)oldWeight % (int)temporalCoherence; 
    396398 
    397399        float3 ao; 
     
    400402        if (eyeSpaceDepth < DEPTH_THRESHOLD) 
    401403        { 
    402                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), usedWeight, sampleIntensity, isMovingObject); 
     404                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), usedWeight, sampleIntensity, isMovingObject, idx); 
    403405                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    404406        } 
Note: See TracChangeset for help on using the changeset viewer.