- Timestamp:
- 09/01/08 08:58:38 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp
r2890 r2891 193 193 mUseTemporalCoherence(true), 194 194 mUseGlobIllum(false), 195 mSampling(POISSON) 195 mSampling(POISSON), 196 mFboIndex(0) 196 197 { 197 198 // create noise texture for ssao … … 201 202 //-- the flip-flop fbos 202 203 203 mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE);204 /*mNewFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 204 205 205 206 mNewFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); … … 212 213 213 214 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); 218 223 } 219 224 … … 227 232 if (sCgAntiAliasingProgram) cgDestroyProgram(sCgAntiAliasingProgram); 228 233 229 DEL_PTR(mNewFbo);230 DEL_PTR(mOldFbo);231 //DEL_PTR(mFbo);234 //DEL_PTR(mNewFbo); 235 //DEL_PTR(mOldFbo); 236 DEL_PTR(mFbo); 232 237 233 238 glDeleteTextures(1, &noiseTex); … … 418 423 // contais the color buffer from the last frame, 419 424 // the other one will be written 420 swap(mNewFbo, mOldFbo);421 425 //swap(mNewFbo, mOldFbo); 426 mFboIndex = 2 - mFboIndex; 422 427 FrameBufferObject::Release(); 423 428 … … 492 497 493 498 // 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(); 499 506 500 507 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 545 552 //const float new_offs = 0.55f; 546 553 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 553 555 glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 554 556 glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs, -new_offs, -0.5f); … … 715 717 716 718 // 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(); 722 729 723 730 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 766 773 ComputeViewVectors(tl, tr, bl, br); 767 774 768 glColor3f(1.0f, 1.0f, 1.0f);769 770 775 glBegin(GL_QUADS); 771 776 … … 773 778 //const float new_offs = 0.55f; 774 779 const float new_offs = 0.5f; 775 776 gl Color3f(bl.x, bl.y, bl.z); glTexCoord2f(0, 0); glVertex3f(-new_offs, -new_offs, -0.5f);777 gl Color3f(br.x, br.y, br.z); glTexCoord2f(1, 0); glVertex3f( new_offs, -new_offs, -0.5f);778 gl Color3f(tr.x, tr.y, tr.z); glTexCoord2f(1, 1); glVertex3f( new_offs, new_offs, -0.5f);779 gl Color3f(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); 780 785 781 786 glEnd(); … … 798 803 GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 799 804 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 802 810 803 811 fbo->Bind(); … … 850 858 { 851 859 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(); 853 862 854 863 fbo->Bind();
Note: See TracChangeset
for help on using the changeset viewer.