Ignore:
Timestamp:
09/01/08 08:58:38 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2890 r2891  
    193193mUseTemporalCoherence(true), 
    194194mUseGlobIllum(false), 
    195 mSampling(POISSON) 
     195mSampling(POISSON), 
     196mFboIndex(0) 
    196197{ 
    197198        // create noise texture for ssao 
     
    201202        //-- the flip-flop fbos 
    202203 
    203         mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
     204        /*mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    204205         
    205206        mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     
    212213         
    213214        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    214         mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    215          
    216         //mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    217         //mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);*/ 
     215        mOldFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false);*/ 
     216         
     217        mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
     218 
     219        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     220        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     221        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
     222        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 
    218223} 
    219224 
     
    227232        if (sCgAntiAliasingProgram) cgDestroyProgram(sCgAntiAliasingProgram); 
    228233 
    229         DEL_PTR(mNewFbo); 
    230         DEL_PTR(mOldFbo); 
    231         //DEL_PTR(mFbo); 
     234        //DEL_PTR(mNewFbo); 
     235        //DEL_PTR(mOldFbo); 
     236        DEL_PTR(mFbo); 
    232237 
    233238        glDeleteTextures(1, &noiseTex); 
     
    418423        // contais the color buffer from the last frame,  
    419424        // the other one will be written 
    420         swap(mNewFbo, mOldFbo);  
    421  
     425        //swap(mNewFbo, mOldFbo);        
     426        mFboIndex = 2 - mFboIndex; 
    422427        FrameBufferObject::Release(); 
    423428 
     
    492497 
    493498        // read the second buffer, write to the first buffer 
    494         mNewFbo->Bind(); 
    495         glDrawBuffers(1, mymrt); 
    496  
    497  
    498         GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     499        //mNewFbo->Bind(); 
     500        mFbo->Bind(); 
     501        glDrawBuffers(1, mymrt + mFboIndex); 
     502 
     503 
     504        //GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     505        GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
    499506 
    500507        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    545552        //const float new_offs = 0.55f; 
    546553        const float new_offs = 0.5f; 
    547         /* 
    548         glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 
    549         glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( new_offs, -new_offs, -0.5f); 
    550         glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs,  new_offs, -0.5f); 
    551         glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs,  new_offs, -0.5f); 
    552 */ 
     554         
    553555        glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 
    554556        glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs, -new_offs, -0.5f); 
     
    715717 
    716718        // read the second buffer, write to the first buffer 
    717         mNewFbo->Bind(); 
    718         glDrawBuffers(2, mymrt); 
    719  
    720         GLuint oldSsaoTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
    721         GLuint oldIllumTex = mOldFbo->GetColorBuffer(1)->GetTexture(); 
     719        //mNewFbo->Bind(); 
     720        mFbo->Bind(); 
     721 
     722        glDrawBuffers(2, mymrt + mFboIndex); 
     723 
     724        //GLuint oldSsaoTex = mOldFbo->GetColorBuffer(0)->GetTexture(); 
     725        //GLuint oldIllumTex = mOldFbo->GetColorBuffer(1)->GetTexture(); 
     726         
     727        GLuint oldSsaoTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 
     728        GLuint oldIllumTex = mFbo->GetColorBuffer(2 - mFboIndex + 1)->GetTexture(); 
    722729 
    723730        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     
    766773        ComputeViewVectors(tl, tr, bl, br); 
    767774 
    768         glColor3f(1.0f, 1.0f, 1.0f); 
    769  
    770775        glBegin(GL_QUADS); 
    771776 
     
    773778        //const float new_offs = 0.55f; 
    774779        const float new_offs = 0.5f; 
    775          
    776         glColor3f(bl.x, bl.y, bl.z); glTexCoord2f(0, 0); glVertex3f(-new_offs, -new_offs, -0.5f); 
    777         glColor3f(br.x, br.y, br.z); glTexCoord2f(1, 0); glVertex3f( new_offs, -new_offs, -0.5f); 
    778         glColor3f(tr.x, tr.y, tr.z); glTexCoord2f(1, 1); glVertex3f( new_offs,  new_offs, -0.5f); 
    779         glColor3f(tl.x, tl.y, tl.z); glTexCoord2f(0, 1); glVertex3f(-new_offs,  new_offs, -0.5f); 
     780                 
     781        glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 
     782        glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs, -new_offs, -0.5f); 
     783        glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( new_offs,  new_offs, -0.5f); 
     784        glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-new_offs,  new_offs, -0.5f); 
    780785 
    781786        glEnd(); 
     
    798803        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    799804 
    800         GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
    801         GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
     805        //GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     806        //GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
     807        GLuint ssaoTex = mFbo->GetColorBuffer(mFboIndex)->GetTexture(); 
     808        GLuint illumTex = mFbo->GetColorBuffer(mFboIndex + 1)->GetTexture(); 
     809 
    802810 
    803811        fbo->Bind(); 
     
    850858{ 
    851859        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    852         GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     860        //GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
     861        GLuint ssaoTex = mFbo->GetColorBuffer(mFboIndex)->GetTexture(); 
    853862 
    854863        fbo->Bind(); 
Note: See TracChangeset for help on using the changeset viewer.