Changeset 3160 for GTP


Ignore:
Timestamp:
11/25/08 00:56:01 (16 years ago)
Author:
mattausch
Message:

working quite well, put filter size adaptation factor from 10 to 5, still
small popping artifact when switching from no filter to filter for convergence 100.
problems with balconies, transition between low convergence regions and high convergence

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

Legend:

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

    r3156 r3160  
    414414        string combineSsaoParams[] =  
    415415                {"colorsTex", "normalsTex", "ssaoTex", "filterOffs",  
    416                  "filterWeights", "bl", "br", "tl", "tr"}; 
    417         sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 9); 
     416                 "filterWeights", "modelViewProj"}; 
     417        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 6); 
    418418 
    419419        ////////////// 
     
    455455 
    456456        const float filterWidth = 100.0f; 
     457        //const float filterWidth = 200.0f; 
    457458 
    458459        PoissonDiscSampleGenerator2 poisson(NUM_SSAO_FILTERSAMPLES, 1.0f); 
     
    740741        GLuint oldIllumTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 
    741742 
    742         sCgGiProgram->SetTexture(0, colorsTex); 
    743         sCgGiProgram->SetTexture(1, normalsTex); 
    744         sCgGiProgram->SetTexture(2, noiseTex2D); 
    745         sCgGiProgram->SetTexture(3, oldSsaoTex); 
    746         sCgGiProgram->SetTexture(4, oldIllumTex); 
    747  
    748         sCgGiProgram->SetValue1f(5,  
     743        int i = 0; 
     744 
     745        sCgGiProgram->SetTexture(i ++, colorsTex); 
     746        sCgGiProgram->SetTexture(i ++, normalsTex); 
     747        sCgGiProgram->SetTexture(i ++, noiseTex2D); 
     748        sCgGiProgram->SetTexture(i ++, oldSsaoTex); 
     749        sCgGiProgram->SetTexture(i ++, oldIllumTex); 
     750 
     751        sCgGiProgram->SetValue1f(i ++,  
    749752                (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
    750753 
     
    758761                GenerateSamples(mSamplingMethod);  
    759762 
    760                 sCgGiProgram->SetArray2f(6, (float *)samples2, NUM_SAMPLES); 
     763                sCgGiProgram->SetArray2f(i ++, (float *)samples2, NUM_SAMPLES); 
    761764        } 
    762765 
     
    766769        Vector3 tr = mCornersView[3]; 
    767770 
    768         sCgGiProgram->SetValue3f(7, bl.x, bl.y, bl.z); 
    769         sCgGiProgram->SetValue3f(8, br.x, br.y, br.z); 
    770         sCgGiProgram->SetValue3f(9, tl.x, tl.y, tl.z); 
    771         sCgGiProgram->SetValue3f(10, tr.x, tr.y, tr.z); 
    772  
    773         sCgGiProgram->SetMatrix(11, mOldProjViewMatrix); 
    774         sCgGiProgram->SetMatrix(12, mProjViewMatrix); 
     771        sCgGiProgram->SetValue3f(i ++, bl.x, bl.y, bl.z); 
     772        sCgGiProgram->SetValue3f(i ++, br.x, br.y, br.z); 
     773        sCgGiProgram->SetValue3f(i ++, tl.x, tl.y, tl.z); 
     774        sCgGiProgram->SetValue3f(i ++, tr.x, tr.y, tr.z); 
     775 
     776        sCgGiProgram->SetMatrix(i ++, mOldProjViewMatrix); 
     777        sCgGiProgram->SetMatrix(i ++, mProjViewMatrix); 
    775778 
    776779 
     
    819822        sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTERSAMPLES); 
    820823         
    821         Vector3 bl = mCornersView[0]; 
    822         Vector3 br = mCornersView[1]; 
    823         Vector3 tl = mCornersView[2]; 
    824         Vector3 tr = mCornersView[3]; 
     824        sCgCombineSsaoProgram->SetMatrix(i++, mProjViewMatrix); 
    825825 
    826826 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3159 r3160  
    5151 
    5252#define MAX_LOD_LEVEL 10 
    53 // burnout (really bright regions will be saturated to white) 
     53/// burnout (really bright regions will be saturated to white) 
    5454#define WHITE_LUMINANCE 3e4f 
    5555 
     
    6464 
    6565 
    66 #define DYNAMIC_OBJECTS_THRESHOLD 1e-7f 
     66#define DYNAMIC_OBJECTS_THRESHOLD 1e-8f 
    6767 
    6868 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3159 r3160  
    8989                          uniform sampler2D ssaoTex, 
    9090                          uniform sampler2D normalsTex, 
    91                           uniform sampler2D offsetTex, 
    9291                          uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 
    93                           uniform float filterWeights[NUM_SSAO_FILTERSAMPLES] 
     92                          uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 
     93                          uniform float4x4 modelViewProj 
    9494                          ) 
    9595{ 
     
    9999        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    100100 
    101         if ((ao.y < 70.0f) && (col.w < 1e10f)) 
     101        // reconstruct position from the eye space depth 
     102        const float eyeSpaceDepth = col.w; 
     103        const float4 worldPos = float4(-IN.view * eyeSpaceDepth, 1.0f); 
     104        // compute w factor from projection in order to control filter size 
     105        const float4 projPos = mul(modelViewProj, worldPos); 
     106        const float distanceScale = 1.0f / projPos.w; 
     107 
     108        const float convergence = ao.y; 
     109 
     110        if ((ao.y < 100.0f) && (col.w < 1e10f)) 
    102111        //if (col.w < 1e10f) 
    103112        { 
    104113                const float scaleFactor = 1.0f; 
    105                 const float adaptFactor = 10.0f; 
    106                 const float scale =     adaptFactor * scaleFactor * ao.z  / (adaptFactor + ao.y); 
     114                const float adaptFactor = 5.0f; 
     115                const float scale =     adaptFactor * scaleFactor * distanceScale / (adaptFactor + convergence); 
    107116 
    108                 //ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale); 
     117                ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale); 
    109118        } 
    110119 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3159 r3160  
    290290        float validPixel; 
    291291 
    292         if (((squaredLen <= DYNAMIC_OBJECTS_THRESHOLD) && (oldPixel.z <= DYNAMIC_OBJECTS_THRESHOLD)) || 
    293                 (1  
     292        if ((((squaredLen <= DYNAMIC_OBJECTS_THRESHOLD) && (oldPixel.z <= DYNAMIC_OBJECTS_THRESHOLD)) ||  
     293                (depthDif <= 1e-2)) 
    294294                && (oldTexCoords.x >= 0.0f) && (oldTexCoords.x < 1.0f) 
    295295                && (oldTexCoords.y >= 0.0f) && (oldTexCoords.y < 1.0f) 
    296                 && (depthDif <= MIN_DEPTH_DIFF) 
    297                 ) 
    298                 //&& (depthDif <= 9e-1f)  
    299296                ) 
    300297        { 
    301                 validPixel = 0.0f;//5f; 
     298                validPixel = 0.0f; 
    302299        } 
    303300        else 
Note: See TracChangeset for help on using the changeset viewer.