Changeset 2901


Ignore:
Timestamp:
09/04/08 10:14:18 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
1 added
8 edited

Legend:

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

    r2900 r2901  
    808808                        </File> 
    809809                        <File 
    810                                 RelativePath=".\src\shaders\ssao2.cg" 
     810                                RelativePath=".\src\shaders\ssao3d.cg" 
    811811                                > 
    812812                        </File> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r2897 r2901  
    1919# shader stuff 
    2020 
    21 # ssao exponential smoothing factor 
    22 expFactor=0.1f 
    23 #numSsaoSamples=8 
     21# ssao temporal coherence factor 
     22tempCohFactor=100.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r2900 r2901  
    119119static void GenerateSamples(int sampling) 
    120120{ 
    121         static SphericalSampleGenerator gauss(NUM_SAMPLES, 0.5f); 
     121        SphericalSampleGenerator gauss(NUM_SAMPLES, 1.0f); 
    122122        gauss.Generate((float *)samples3); 
    123 /* 
     123         
     124        /* 
    124125        switch (sampling) 
    125126        { 
     
    150151        float *randomNormals = new float[w * h * 3]; 
    151152 
     153        //SphericalSampleGenerator gauss(w * h, 1.0f); 
     154        //gauss.Generate(randomNormals); 
     155 
    152156        static HaltonSequence halton; 
    153157        float r[2]; 
     
    158162                halton.GetNext(2, r); 
    159163 
    160                 /* 
    161                 const float theta = 2.0f * acos(sqrt(1.0f - rx)); 
    162  
    163                 randomNormals[i + 0] = cos(theta); 
    164                 randomNormals[i + 1] = sin(theta); 
    165                 randomNormals[i + 2] = 0;*/ 
     164                 
     165                //const float theta = 2.0f * acos(sqrt(1.0f - rx)); 
     166                //randomNormals[i + 0] = cos(theta); 
     167                //randomNormals[i + 1] = sin(theta); 
     168                //randomNormals[i + 2] = 0; 
    166169 
    167170                const float theta = 2.0f * acos(sqrt(1.0f - r[0])); 
     
    272275                                                                CG_SOURCE, 
    273276                                                                //"src/shaders/ssao.cg",  
    274                                                                 "src/shaders/ssao2.cg",  
     277                                                                "src/shaders/ssao3d.cg",  
    275278                                                                RenderState::sCgFragmentProfile, 
    276279                                                                "main", 
     
    294297                sOldTexParam = cgGetNamedParameter(sCgSsaoProgram, "oldTex");   
    295298                 
    296                 cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(3.0f, 17.0f)); 
     299                cgGLSetParameter1f(sNoiseMultiplierParam, RandomValue(1.0f, 3.0f)); 
    297300                sSamplesParam = cgGetNamedParameter(sCgSsaoProgram, "samples"); 
    298301        } 
     
    328331                sOldIllumTexGiParam = cgGetNamedParameter(sCgGiProgram, "oldIllumTex");   
    329332 
    330                 cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(3.0f, 17.0f)); 
     333                cgGLSetParameter1f(sNoiseMultiplierGiParam, RandomValue(1.0f, 3.0f)); 
    331334        } 
    332335        else 
     
    421424                                                          const Matrix4x4 &oldProjViewMatrix, 
    422425                                                          const Matrix4x4 &projViewMatrix, 
    423                                                           float expFactor, 
     426                                                          float tempCohFactor, 
    424427                                                          ShadowMap *shadowMap) 
    425428{ 
     
    462465        { 
    463466        case SSAO: 
    464                 ComputeSsao(fbo, expFactor, oldProjViewMatrix, projViewMatrix); 
     467                ComputeSsao(fbo, tempCohFactor, oldProjViewMatrix, projViewMatrix); 
    465468                CombineSsao(fbo); 
    466469                break; 
    467470        case GI: 
    468                 ComputeGlobIllum(fbo, expFactor, oldProjViewMatrix); 
     471                ComputeGlobIllum(fbo, tempCohFactor, oldProjViewMatrix); 
    469472                CombineIllum(fbo); 
    470473                break; 
     
    492495 
    493496void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo,  
    494                                                                    float expFactor, 
     497                                                                   float tempCohFactor, 
    495498                                                                   const Matrix4x4 &oldProjViewMatrix, 
    496499                                                                   const Matrix4x4 &projViewMatrix 
     
    550553        cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 
    551554         
    552         cgGLSetParameter1f(sTemporalCoherenceParam, (mUseTemporalCoherence && !mRegenerateSamples) ? 255 : 0); 
     555        cgGLSetParameter1f(sTemporalCoherenceParam, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
    553556 
    554557        if (mUseTemporalCoherence || mRegenerateSamples) 
     
    716719 
    717720void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo,  
    718                                                                   float expFactor, 
    719                                                                   const Matrix4x4 &oldProjViewMatrix 
    720                                                                   ) 
     721                                                                                float tempCohFactor, 
     722                                                                                const Matrix4x4 &oldProjViewMatrix) 
    721723{ 
    722724        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixGiParam, (const float *)oldProjViewMatrix.x); 
    723725 
    724         //GLuint colorsTex = mFbo->GetColorBuffer(0)->GetTexture(); 
    725726        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    726727        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     
    740741 
    741742        // read the second buffer, write to the first buffer 
    742         //mNewFbo->Bind(); 
    743743        mFbo->Bind(); 
    744744 
    745745        glDrawBuffers(2, mrt + mFboIndex); 
    746746 
    747         //GLuint oldSsaoTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
    748         //GLuint oldIllumTex = mOldFbo->GetColorBuffer(1)->GetTexture(); 
    749          
    750747        GLuint oldSsaoTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    751748        GLuint oldIllumTex = mFbo->GetColorBuffer(2 - mFboIndex + 1)->GetTexture(); 
     
    776773        cgGLSetParameter1f(sMaxDepthGiParam, mScaleFactor); 
    777774 
    778         cgGLSetParameter1f(sTemporalCoherenceGiParam, (mUseTemporalCoherence && !mRegenerateSamples) ? 255 : 0); 
     775        cgGLSetParameter1f(sTemporalCoherenceGiParam, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
    779776 
    780777 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r2900 r2901  
    4141                        const Matrix4x4 &oldProjViewMatrix,  
    4242                                const Matrix4x4 &projViewMatrix,  
    43                                 float expFactor,  
     43                                float tempCohFactor,  
    4444                                ShadowMap *shadowMap = NULL); 
    4545 
     
    6262protected: 
    6363 
    64         void ComputeSsao(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix, const Matrix4x4 &projViewMatrix); 
     64        void ComputeSsao(FrameBufferObject *fbo, float tempCohFactor, const Matrix4x4 &oldProjViewMatrix, const Matrix4x4 &projViewMatrix); 
    6565 
    66         void ComputeGlobIllum(FrameBufferObject *fbo, float expFactor, const Matrix4x4 &oldProjViewMatrix); 
     66        void ComputeGlobIllum(FrameBufferObject *fbo, float tempCohFactor, const Matrix4x4 &oldProjViewMatrix); 
    6767 
    6868        void FirstPass(FrameBufferObject *fbo); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp

    r2900 r2901  
    11#include "common.h" 
    22#include "SampleGenerator.h" 
    3 #include "Halton.h" 
     3 
    44 
    55using namespace std; 
    66 
    7 //SampleGenerator::SampleGenerator() {} 
     7HaltonSequence SphericalSampleGenerator::sHalton; 
     8HaltonSequence PoissonDiscSampleGenerator::sHalton; 
     9HaltonSequence GaussianSampleGenerator::sHalton; 
     10 
    811 
    912SampleGenerator::SampleGenerator(int numSamples, float radius): 
     
    98101void GaussianSampleGenerator::Generate(float *samples) const 
    99102{ 
    100         static HaltonSequence halton; 
    101103        float r[2]; 
    102104 
     
    110112        for (int i = 0; i < mNumSamples; ++ i) 
    111113        { 
    112                 halton.GetNext(2, r); 
     114                sHalton.GetNext(2, r); 
    113115 
    114116                float exp_x = -(r[0] * r[0]) / (2.0f * sigma * sigma); 
     
    130132void SphericalSampleGenerator::Generate(float *samples) const 
    131133{ 
    132         static HaltonSequence halton; 
    133134        float r[2]; 
     135        Sample3 *s = (Sample3 *)samples; 
    134136 
    135         Sample3 *s = (Sample3 *)samples; 
     137        // idea: use poisson distribution to generate samples 
     138        PoissonDiscSampleGenerator poisson(mNumSamples, 1.0f); 
     139        Sample2 *pSamples = new Sample2[mNumSamples]; 
     140 
     141        poisson.Generate((float *)pSamples); 
    136142 
    137143        for (int i = 0; i < mNumSamples; ++ i) 
    138144        { 
    139                 halton.GetNext(2, r); 
     145                //sHalton.GetNext(2, r); 
     146                r[0] = pSamples[i].x; r[1] = pSamples[i].y; 
    140147 
    141148                // create stratified samples over sphere 
    142149                const float theta = 2.0f * acos(sqrt(1.0f - r[0])); 
    143150                const float phi = 2.0f * M_PI * r[1]; 
     151  
     152                s[i].x = mRadius * sin(theta) * cos(phi); 
     153                s[i].y = mRadius * sin(theta) * sin(phi); 
     154                s[i].z = mRadius * cos(theta); 
     155        } 
    144156 
    145                 s[i].x = sin(theta) * cos(phi); 
    146                 s[i].y = sin(theta) * sin(phi); 
    147                 s[i].z = cos(theta); 
    148         } 
     157        delete [] pSamples; 
    149158} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h

    r2900 r2901  
    11#ifndef __SAMPLEGENERATOR_H 
    22#define __SAMPLEGENERATOR_H 
     3 
     4#include "Halton.h" 
    35 
    46 
     
    5254 
    5355        virtual void Generate(float *samples) const; 
     56 
     57protected: 
     58 
     59        static HaltonSequence sHalton; 
    5460}; 
    5561 
     
    6268 
    6369        virtual void Generate(float *samples) const; 
     70 
     71protected: 
     72 
     73        static HaltonSequence sHalton; 
    6474}; 
    6575 
     
    7282 
    7383        virtual void Generate(float *samples) const; 
     84 
     85protected: 
     86 
     87        static HaltonSequence sHalton; 
    7488}; 
    7589 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2900 r2901  
    156156bool useTemporalCoherence = true; 
    157157 
    158 static float ssaoExpFactor = 0.1f; 
     158static float ssaoTempCohFactor = 255.0; 
    159159 
    160160bool showAlgorithmTime = false; 
     
    303303 
    304304                env.GetBoolParam(string("useFullScreen"), useFullScreen); 
    305                 env.GetFloatParam(string("expFactor"), ssaoExpFactor); 
     305                env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 
    306306                env.GetVectorParam(string("camPosition"), camPos); 
    307307                env.GetVectorParam(string("camDirection"), camDir); 
     
    324324                cout << "useLODs: " << useLODs << endl; 
    325325                cout << "camPosition: " << camPos << endl; 
    326                 cout << "expFactor: " << ssaoExpFactor << endl; 
     326                cout << "temporal coherence: " << ssaoTempCohFactor << endl; 
    327327 
    328328                //cout << "model path: " << model_path << endl; 
     
    10321032 
    10331033                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
    1034                 ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoExpFactor, sm); 
     1034                ssaoShader->Render(fbo, oldViewProjMatrix, matProjectionView, ssaoTempCohFactor, sm); 
    10351035        } 
    10361036 
     
    11421142                break; 
    11431143        case '7': 
    1144                 ssaoExpFactor *= 0.5f; 
     1144                ssaoTempCohFactor *= 0.5f; 
    11451145                break; 
    11461146        case '8': 
    1147                 ssaoExpFactor *= 2.0f; 
    1148                 if (ssaoExpFactor > 1.0f) ssaoExpFactor = 1.0f; 
     1147                ssaoTempCohFactor *= 2.0f; 
     1148                //if (ssaoTempCohFactor > 1.0f) ssaoExpFactor = 1.0f; 
    11491149                break; 
    11501150        case '9': 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2900 r2901  
    55//#define NUM_SAMPLES 16 
    66 
    7 // rule of thumb: approx 1 / NUM_SAMPLES 
    8 //#define SAMPLE_INTENSITY 0.14f 
     7 
     8// for linear falloff 
     9//#define SAMPLE_INTENSITY 500.0f 
     10//#define SAMPLE_INTENSITY 100.0f 
     11 
     12// for quadradtc falloff 
    913//#define SAMPLE_INTENSITY 0.28f 
    10 #define SAMPLE_INTENSITY 0.32f 
     14//#define SAMPLE_INTENSITY 0.32f 
     15#define SAMPLE_INTENSITY 2.4f 
    1116 
    12 //#define AREA_SIZE 18e-1f 
     17//#define AREA_SIZE 25e-1f 
     18//#define AREA_SIZE 6e-1f 
    1319#define AREA_SIZE 8e-1f 
    1420//#define AREA_SIZE 5e-1f 
     
    1723//#define VIEW_CORRECTION_SCALE 0.1f 
    1824 
    19 //#define DISTANCE_SCALE 1e-6f 
     25//#define DISTANCE_SCALE 5e-7f 
    2026#define DISTANCE_SCALE 1e-6f 
     27//#define DISTANCE_SCALE 1.0f 
    2128 
    2229#define ILLUM_INTENSITY 5e-1f; 
Note: See TracChangeset for help on using the changeset viewer.