Ignore:
Timestamp:
08/27/08 17:22:34 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2874 r2875  
    104104mWidth(w), mHeight(h),  
    105105mCamera(cam), 
    106 mScaleFactor(scaleFactor) 
     106mScaleFactor(scaleFactor), 
     107mUseTemporalCoherence(true), 
     108mUseGlobIllum(false) 
    107109{ 
    108110        /////////// 
     
    140142 
    141143        glDeleteTextures(1, &noiseTex); 
     144} 
     145 
     146 
     147void SsaoShader::SetUseGlobIllum(bool useGlobIllum) 
     148{ 
     149        mUseGlobIllum = useGlobIllum; 
     150} 
     151 
     152 
     153void SsaoShader::SetUseTemporalCoherence(bool temporal) 
     154{ 
     155        mUseTemporalCoherence = temporal; 
    142156} 
    143157 
     
    198212                GenerateSamples();  
    199213                cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples); 
     214 
     215                cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
    200216        } 
    201217        else 
     
    233249                GenerateSamples();  
    234250                cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples); 
     251 
     252                cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f)); 
    235253        } 
    236254        else 
     
    298316        FirstPass(fbo); 
    299317         
    300         //ComputeSsao(fbo, expFactor, oldProjViewMatrix); 
    301         ComputeGlobIllum(fbo, expFactor, oldProjViewMatrix); 
    302  
    303         //Combine(fbo); 
     318        if (!mUseGlobIllum) 
     319                ComputeSsao(fbo, expFactor, oldProjViewMatrix); 
     320        else 
     321                ComputeGlobIllum(fbo, expFactor, oldProjViewMatrix); 
     322 
    304323        AntiAliasing(fbo); 
    305324 
     
    363382        cgGLSetTextureParameter(sOldTexParam, oldTex); 
    364383        cgGLEnableTextureParameter(sOldTexParam); 
    365  
    366         cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
    367384         
    368385        cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 
    369         cgGLSetParameter1f(sExpFactorParam, expFactor); 
    370  
    371  
    372         // q: should we generate new samples or only rotate the old ones? 
    373         // in the first case, the sample patterns look nicer, but the kernel 
    374         // needs longer to converge 
    375         GenerateSamples();  
    376         cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples); 
     386         
     387        if (mUseTemporalCoherence) 
     388        { 
     389                cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
     390                cgGLSetParameter1f(sExpFactorParam, expFactor); 
     391 
     392 
     393                // q: should we generate new samples or only rotate the old ones? 
     394                // in the first case, the sample patterns look nicer, but the kernel 
     395                // needs longer to converge 
     396                GenerateSamples();  
     397                cgGLSetParameterArray2f(sSamplesParam, 0, NUM_SAMPLES, (const float *)samples); 
     398        } 
     399        else 
     400        { 
     401                        cgGLSetParameter1f(sExpFactorParam, 1.0f); 
     402        } 
    377403 
    378404        Vector3 tl, tr, bl, br; 
     
    638664        cgGLEnableTextureParameter(sOldIllumTexGiParam); 
    639665 
    640         cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f)); 
    641          
    642666        cgGLSetParameter1f(sMaxDepthGiParam, mScaleFactor); 
    643         cgGLSetParameter1f(sExpFactorGiParam, expFactor); 
    644  
    645  
    646         // q: should we generate new samples or only rotate the old ones? 
    647         // in the first case, the sample patterns look nicer, but the kernel 
    648         // needs longer to converge 
    649         GenerateSamples();  
    650         cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples); 
     667 
     668 
     669        if (mUseTemporalCoherence) 
     670        { 
     671                cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f)); 
     672                cgGLSetParameter1f(sExpFactorGiParam, expFactor); 
     673 
     674 
     675                // q: should we generate new samples or only rotate the old ones? 
     676                // in the first case, the sample patterns look nicer, but the kernel 
     677                // needs longer to converge 
     678                GenerateSamples();  
     679                cgGLSetParameterArray2f(sSamplesGiParam, 0, NUM_SAMPLES, (const float *)samples); 
     680        } 
     681        else 
     682        { 
     683                        cgGLSetParameter1f(sExpFactorGiParam, 1.0f); 
     684        } 
    651685 
    652686        Vector3 tl, tr, bl, br; 
Note: See TracChangeset for help on using the changeset viewer.