Ignore:
Timestamp:
02/16/09 17:08:51 (15 years ago)
Author:
mattausch
Message:

reverted back to before poisson sampling scheme

File:
1 edited

Legend:

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

    r3311 r3313  
    7171static GLuint noiseTex2D = 0; 
    7272static GLuint noiseTex1D = 0; 
    73 static GLuint sampleTex2D = 0; 
    74  
    75  
    76 static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
     73 
     74 
    7775// ssao random spherical samples 
    78 //static Sample2 samples2[NUM_SAMPLES]; 
    79  
     76static Sample2 samples2[NUM_SAMPLES]; 
     77//#define NUM_PRECOMPUTED_SAMPLES 240 
     78//static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
    8079// pcf samples 
    8180static Sample2 pcfSamples[NUM_PCF_TABS]; 
     
    9291/** Helper method that computes the view vectors in the corners of the current view frustum. 
    9392*/ 
    94 static void ComputeViewVectors(PerspectiveCamera *cam,  
    95                                                            Vector3 &bl, 
    96                                                            Vector3 &br,  
    97                                                            Vector3 &tl, 
    98                                                            Vector3 &tr) 
     93static void ComputeViewVectors(PerspectiveCamera *cam, Vector3 &bl, Vector3 &br, Vector3 &tl, Vector3 &tr) 
    9994{ 
    10095        Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 
     
    212207        case DeferredRenderer::SAMPLING_QUADRATIC: 
    213208                { 
    214                         QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 
    215                         //static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f); 
     209                        //static QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 
     210                        static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f); 
    216211                        g.Generate((float *)samples2); 
    217212                } 
     
    262257 
    263258        cout << "created noise texture" << endl; 
    264  
    265         PrintGLerror("noisetexture"); 
    266 } 
    267  
    268  
    269 static void CreateSampleTex(Sample2 *samples, int numSamples) 
    270 { 
    271         glEnable(GL_TEXTURE_2D); 
    272         glGenTextures(1, &sampleTex2D); 
    273         glBindTexture(GL_TEXTURE_2D, sampleTex2D); 
    274                  
    275         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
    276         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
    277         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
    278         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
    279  
    280         int w = numSamples; 
    281         int h = 1; 
    282  
    283         float *tempBuffer = new float[numSamples * 3]; 
    284  
    285         for (int i = 0; i < numSamples; ++ i) 
    286         { 
    287                 tempBuffer[i * 3 + 0] = samples[i].x; 
    288                 tempBuffer[i * 3 + 1] = samples[i].y; 
    289                 tempBuffer[i * 3 + 2] = 0; 
    290                  
    291         } 
    292  
    293         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, w, h, 0, GL_RGB, GL_FLOAT, (float *)tempBuffer); 
    294  
    295         glBindTexture(GL_TEXTURE_2D, 0); 
    296         glDisable(GL_TEXTURE_2D); 
    297  
    298         cout << "created sample texture" << endl; 
    299  
    300         delete [] tempBuffer; 
    301259 
    302260        PrintGLerror("noisetexture"); 
     
    469427 
    470428        string ssaoParams[] =  
    471             {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence",  
     429                {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence",  
    472430                 "samples", "bl", "br", "tl", "tr",  
    473431                 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr",  
    474432                 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"}; 
    475          
    476433        sCgSsaoProgram->AddParameters(ssaoParams, 0, 20); 
    477434         
     
    783740        sCgSsaoProgram->SetTexture(i ++, noiseTex2D); 
    784741 
    785         sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : .0f); 
    786          
    787         if (/*mUseTemporalCoherence || */mRegenerateSamples) 
     742        sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
     743         
     744        static int currentPos = 0; 
     745 
     746        if (mUseTemporalCoherence || mRegenerateSamples) 
    788747        { 
    789748                mRegenerateSamples = false; 
     
    792751                // in the first case, the sample patterns look nicer, but the kernel 
    793752                // needs longer to converge 
    794                 GenerateSamples(mSamplingMethod); 
    795                 CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 
     753                //if (currentPos + NUM_SAMPLES >= NUM_PRECOMPUTED_SAMPLES)      { 
     754                        currentPos = 0; 
     755                        GenerateSamples(mSamplingMethod); 
     756                //} 
     757 
    796758                //if (mSortSamples) { SortSamples(); } 
    797                 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 
    798                 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_PRECOMPUTED_SAMPLES); 
    799                 sCgSsaoProgram->SetTexture(i, sampleTex2D); 
    800         } 
    801          
    802  
     759                sCgSsaoProgram->SetArray2f(i, (float *)samples2 + currentPos, NUM_SAMPLES); 
     760 
     761                currentPos += NUM_SAMPLES; 
     762        } 
     763         
    803764        ++ i; 
    804765 
    805766        for (int j = 0; j < 4; ++ j, ++ i) 
    806         { 
    807767                sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
    808         } 
    809768 
    810769        sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
     
    815774        de.y = mOldEyePos.y - mEyePos.y;  
    816775        de.z = mOldEyePos.z - mEyePos.z; 
    817  
    818776 
    819777        sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 
Note: See TracChangeset for help on using the changeset viewer.