Ignore:
Timestamp:
04/24/09 18:00:06 (15 years ago)
Author:
mattausch
Message:

cleaned up algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3361 r3362  
    205205                //-- (affects performance for some reason!) 
    206206 
    207                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     207                if (!USE_OPTIMIZATION || 
     208                        (convergence < SSAO_CONVERGENCE_THRESHOLD)) 
    208209                { 
    209210                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
     
    355356                //-- (affects performance for some reason!) 
    356357 
    357                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     358                if (!USE_OPTIMIZATION || 
     359                        (convergence < SSAO_CONVERGENCE_THRESHOLD)) 
    358360                { 
    359361                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
     
    493495                //-- (affects performance for some reason!) 
    494496 
    495                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     497                if (!USE_OPTIMIZATION || 
     498                        (convergence < SSAO_CONVERGENCE_THRESHOLD)) 
    496499                { 
    497500                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
     
    539542 
    540543 
    541 #ifdef PERFORMANCE_TEST 
     544//#ifdef PERFORMANCE_TEST 
     545#if 1 
    542546                // check if the samples have been valid in the last frame 
    543547                // only mark sample as invalid if in the last / current frame 
    544548                // they possibly have any influence on the ao 
    545549 
    546                 //const float pixelValid = sampleColor.x; 
    547                 //const float pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
    548                 //float pixelValid = max(sampleColor.x, length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f); 
    549                 float pixelValid = sampleColor.x; 
    550  
    551                 if (pixelValid < 1) 
    552                 { 
    553                         const float3 sampleDiffVec = tex2Dlod(attribsTex, float4(texcoord, .0f, .0f)).xyz; 
    554                         pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
    555                 } 
    556  
    557                 // hack: 
    558                 // we check if the sample could have been near enough to the current pixel  
    559                 // or if the angle is small enough 
    560                 // to have any influence in the current or last frame 
    561  
    562 #if 1 
    563                 const float changeFactor = sampleColor.y; 
    564                 const float partlyResetThres = 1.0f; 
    565  
    566                 if (0)//pixelValid <= partlyResetThres) 
    567                 { 
    568                         const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
    569                         validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
    570                 } 
    571                 else 
    572                 { 
    573                         validSamples = max(validSamples, pixelValid); 
    574                 } 
    575 #endif 
    576  
     550                if (cosAngle > 0) 
     551                { 
     552                        float pixelValid = sampleColor.x; 
     553 
     554                        if (1)//pixelValid < 0.5f) 
     555                        { 
     556                                const float3 sampleDiffVec = tex2Dlod(attribsTex, float4(texcoord, .0f, .0f)).xyz; 
     557                                pixelValid = max(pixelValid, length(sampleDiffVec - diffVec) < 5e-3f ? .0f : 10.0f); 
     558                                //pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
     559                        } 
     560 
     561                        // hack: 
     562                        // we check if the sample could have been near enough to the current pixel  
     563                        // or if the angle is small enough 
     564                        // to have any influence in the current or last frame 
     565 
     566                        const float changeFactor = sampleColor.y; 
     567                        const float partlyResetThres = 1.0f; 
     568 
     569                        if (0)//pixelValid <= partlyResetThres) 
     570                        { 
     571                                const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
     572                                validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
     573                        } 
     574                        else 
     575                        { 
     576                                validSamples = max(validSamples, pixelValid); 
     577                        } 
     578                } 
    577579#ifdef USE_GTX 
    578580                // we can bail out early and use a minimal #samples) 
     
    657659         
    658660#ifdef PERFORMANCE_TEST  
     661 
    659662        float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    660663 
     
    750753                { 
    751754                        const float factor = 4.0f; 
     755                        //if (oldIdx >= factor * newWeight) oldIdx = 0; 
    752756                        oldWeight = min(oldWeight, factor * newWeight); 
    753                         //oldWeight = .0f;  
    754                         //oldIdx    = .0f; 
     757                        oldWeight = oldIdx = .0f;  
    755758                } 
    756759        } 
Note: See TracChangeset for help on using the changeset viewer.