Ignore:
Timestamp:
02/23/09 18:33:26 (15 years ago)
Author:
mattausch
Message:

strange texture error!!

File:
1 edited

Legend:

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

    r3325 r3326  
    268268 
    269269 
     270static void UpdateSampleTex(Sample2 *samples, int numSamples) 
     271{ 
     272        glEnable(GL_TEXTURE_2D); 
     273        glBindTexture(GL_TEXTURE_2D, sampleTex2D); 
     274                 
     275        const int w = numSamples; const int h = 1; 
     276 
     277        float *tempBuffer = new float[numSamples * 3]; 
     278 
     279        for (int i = 0; i < numSamples; ++ i) 
     280        { 
     281                tempBuffer[i * 3 + 0] = samples[i].x; 
     282                tempBuffer[i * 3 + 1] = samples[i].y; 
     283                tempBuffer[i * 3 + 2] = 0; 
     284                 
     285        } 
     286 
     287        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGB, GL_FLOAT, (float *)tempBuffer); 
     288 
     289        glBindTexture(GL_TEXTURE_2D, 0); 
     290        glDisable(GL_TEXTURE_2D); 
     291 
     292        cout << "updated sample texture" << endl; 
     293 
     294        delete [] tempBuffer; 
     295 
     296        PrintGLerror("noisetexture"); 
     297} 
     298 
     299 
    270300static void CreateSampleTex(Sample2 *samples, int numSamples) 
    271301{ 
     
    279309        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
    280310 
    281         int w = numSamples; 
    282         int h = 1; 
     311        const int w = numSamples; const int h = 1; 
    283312 
    284313        float *tempBuffer = new float[numSamples * 3]; 
     
    506535 
    507536        string combineSsaoParams[] =  
    508                 //{"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 
    509537                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 
    510538 
    511         //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 
    512539        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 9); 
    513540 
     
    517544        string filterSsaoParams[] =  
    518545                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 
    519  
    520546        sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 9); 
    521547 
     
    549575         
    550576        string prepareSsaoParams[] =  
    551                 {"colorsTex", "normalsTex", "diffVals", "oldTex", "oldTex2",  
     577                {"colorsTex", "normalsTex", "diffVals", "oldTex",  
    552578                 "oldEyePos", "modelViewProj", "oldModelViewProj", 
    553                  "oldbl", "oldbr", "oldtl", "oldtr"}; 
    554  
     579                 "oldbl", "oldbr", "oldtl", "oldtr", "myTex"}; 
    555580        sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 12); 
    556581 
     
    673698        // if it hasn't been done yet => just output the latest buffer 
    674699        if (!mUseAntiAliasing || !displayAfterAA) 
     700        { 
    675701                Output(fbo);  
     702        } 
    676703 
    677704        glEnable(GL_LIGHTING); 
     
    801828                // needs longer to converge 
    802829                GenerateSamples(mSamplingMethod); 
    803                 CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 
     830 
     831                if (!sampleTex2D) 
     832                { 
     833                        CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 
     834                } 
     835                else 
     836                { 
     837                        UpdateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 
     838                } 
     839 
    804840                //if (mSortSamples) { SortSamples(); } 
    805841                //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 
     
    936972        // read the second buffer, write to the first buffer 
    937973        mIllumFbo->Bind(); 
    938  
    939974        glDrawBuffers(2, mrt + mIllumFboIndex); 
    940975 
     976        // bind the old buffers for temporal coherence 
    941977        GLuint oldSsaoTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
    942978        GLuint oldIllumTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 
     
    10121048        GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 
    10131049         
    1014         //mIllumFbo->Bind(); 
    1015         //glDrawBuffers(1, mrt + mIllumFboIndex + 1); 
    10161050        mTempFbo->Bind(); 
    10171051        glDrawBuffers(1, mrt); 
     
    10401074        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    10411075        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    1042         //GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex + 1)->GetTexture(); 
    10431076        GLuint ssaoTex = mTempFbo->GetColorBuffer(0)->GetTexture(); 
    10441077         
     
    11731206        // flip flop between illumination buffers 
    11741207        GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
    1175         GLuint oldTex2 = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 
     1208        GLuint myTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 
    11761209 
    11771210        int i = 0; 
     
    11811214        sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); 
    11821215        sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); 
    1183         sCgPrepareSsaoProgram->SetTexture(i ++, oldTex2); 
    11841216 
    11851217        Vector3 de; 
     
    11931225        sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 
    11941226 
     1227 
    11951228        for (int j = 0; j < 4; ++ j, ++ i) 
    11961229        { 
    11971230                sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
    11981231        } 
     1232 
     1233        sCgPrepareSsaoProgram->SetTexture(i ++, myTex); 
    11991234 
    12001235        glPushAttrib(GL_VIEWPORT_BIT); 
     
    12441279        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
    12451280        GLuint colorsTex = colorBuffer->GetTexture(); 
    1246         //FrameBufferObject::Release(); 
     1281         
    12471282 
    12481283        FlipFbos(fbo); 
     
    12721307        DrawQuad(sCgDownSampleProgram); 
    12731308 
    1274         PrintGLerror("output"); 
     1309        PrintGLerror("Output"); 
    12751310} 
    12761311 
     
    12791314{ 
    12801315        for (int i = 0; i < 4; ++ i) 
     1316        { 
    12811317                mOldCornersView[i] = mCornersView[i]; 
     1318        } 
    12821319 
    12831320        mOldProjViewMatrix = mProjViewMatrix; 
Note: See TracChangeset for help on using the changeset viewer.