- Timestamp:
- 11/05/08 00:35:08 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3094 r3095 422 422 InitFrame(); 423 423 424 // switch roles of old and new fbo425 // the algorihm uses two input fbos, where the one426 // contais the color buffer from the last frame,427 // the other one will be written428 429 mIllumFboIndex = 2 - mIllumFboIndex;430 431 // enable fragment shading432 ShaderManager::GetSingleton()->EnableFragmentProfile();433 434 glDisable(GL_ALPHA_TEST);435 glDisable(GL_TEXTURE_2D);436 glDisable(GL_LIGHTING);437 glDisable(GL_BLEND);438 glDisable(GL_DEPTH_TEST);439 440 glPolygonMode(GL_FRONT, GL_FILL);441 442 glMatrixMode(GL_PROJECTION);443 glPushMatrix();444 glLoadIdentity();445 446 const float offs = 0.5f;447 //glOrtho(-offs, offs, -offs, offs, 0, 1);448 //glOrtho(0, 1, 0, 1, 0, 1);449 gluOrtho2D(0, 1, 0, 1);450 451 452 glMatrixMode(GL_MODELVIEW);453 glPushMatrix();454 glLoadIdentity();455 456 457 glPushAttrib(GL_VIEWPORT_BIT);458 glViewport(0, 0, mWidth, mHeight);459 460 424 if (shadowMap) 461 425 FirstPassShadow(fbo, light, shadowMap); … … 534 498 glDrawBuffers(1, mrt + mIllumFboIndex); 535 499 536 sCgSsaoProgram->SetTexture(0, colorsTex); 537 sCgSsaoProgram->SetTexture(1, normalsTex); 538 sCgSsaoProgram->SetTexture(2, oldTex); 539 sCgSsaoProgram->SetTexture(3, noiseTex); 540 541 sCgSsaoProgram->SetValue1f(4, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 500 int i = 0; 501 502 sCgSsaoProgram->SetTexture(i ++, colorsTex); 503 sCgSsaoProgram->SetTexture(i ++, normalsTex); 504 sCgSsaoProgram->SetTexture(i ++, oldTex); 505 sCgSsaoProgram->SetTexture(i ++, noiseTex); 506 507 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 542 508 543 509 if (mUseTemporalCoherence || mRegenerateSamples) … … 549 515 // needs longer to converge 550 516 GenerateSamples(mSamplingMethod); 551 sCgSsaoProgram->SetArray2f(5, (float *)samples2, NUM_SAMPLES); 552 } 553 554 Vector3 bl = mCornersView[0]; 555 Vector3 br = mCornersView[1]; 556 Vector3 tl = mCornersView[2]; 557 Vector3 tr = mCornersView[3]; 558 559 sCgSsaoProgram->SetValue3f(6, bl.x, bl.y, bl.z); 560 sCgSsaoProgram->SetValue3f(7, br.x, br.y, br.z); 561 sCgSsaoProgram->SetValue3f(8, tl.x, tl.y, tl.z); 562 sCgSsaoProgram->SetValue3f(9, tr.x, tr.y, tr.z); 563 564 sCgSsaoProgram->SetMatrix(10, mProjViewMatrix); 565 sCgSsaoProgram->SetMatrix(11, mOldProjViewMatrix); 566 567 bl = mOldCornersView[0]; 568 br = mOldCornersView[1]; 569 tl = mOldCornersView[2]; 570 tr = mOldCornersView[3]; 571 572 Vector3 d = mOldEyePos - mEyePos; 573 //Vector3 d = mEyePos - mOldEyePos; 574 575 sCgSsaoProgram->SetValue3f(12, d.x, d.y, d.z); 576 sCgSsaoProgram->SetValue3f(13, bl.x, bl.y, bl.z); 577 sCgSsaoProgram->SetValue3f(14, br.x, br.y, br.z); 578 sCgSsaoProgram->SetValue3f(15, tl.x, tl.y, tl.z); 579 sCgSsaoProgram->SetValue3f(16, tr.x, tr.y, tr.z); 517 sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 518 } 519 520 ++ i; 521 522 for (int j = 0; j < 4; ++ j, ++ i) 523 sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 524 525 sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 526 sCgSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 527 528 Vector3 de = mOldEyePos - mEyePos; 529 //Vector3 de = mEyePos - mOldEyePos; 530 531 sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 532 533 for (int j = 0; j < 4; ++ j, ++ i) 534 sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 580 535 581 536 DrawQuad(sCgSsaoProgram); … … 1001 956 void DeferredRenderer::InitFrame() 1002 957 { 958 for (int i = 0; i < 4; ++ i) 959 mOldCornersView[i] = mCornersView[i]; 960 1003 961 mOldProjViewMatrix = mProjViewMatrix; 962 mOldEyePos = mEyePos; 963 964 965 /////////////////// 1004 966 1005 967 Matrix4x4 matViewing, matProjection; … … 1010 972 1011 973 mProjViewMatrix = matViewing * matProjection; 1012 1013 for (int i = 0; i < 4; ++ i)1014 {1015 mOldCornersView[i] = mCornersView[i];1016 }1017 1018 974 ComputeViewVectors(mCamera, mCornersView[0], mCornersView[1], mCornersView[2], mCornersView[3]); 1019 1020 mOldEyePos = mEyePos;1021 975 mEyePos = mCamera->GetPosition(); 976 977 978 // switch roles of old and new fbo 979 // the algorihm uses two input fbos, where the one 980 // contais the color buffer from the last frame, 981 // the other one will be written 982 983 mIllumFboIndex = 2 - mIllumFboIndex; 984 985 // enable fragment shading 986 ShaderManager::GetSingleton()->EnableFragmentProfile(); 987 988 glDisable(GL_ALPHA_TEST); 989 glDisable(GL_TEXTURE_2D); 990 glDisable(GL_LIGHTING); 991 glDisable(GL_BLEND); 992 glDisable(GL_DEPTH_TEST); 993 994 glPolygonMode(GL_FRONT, GL_FILL); 995 996 glMatrixMode(GL_PROJECTION); 997 glPushMatrix(); 998 glLoadIdentity(); 999 1000 gluOrtho2D(0, 1, 0, 1); 1001 1002 1003 glMatrixMode(GL_MODELVIEW); 1004 glPushMatrix(); 1005 glLoadIdentity(); 1006 1007 1008 glPushAttrib(GL_VIEWPORT_BIT); 1009 glViewport(0, 0, mWidth, mHeight); 1022 1010 } 1023 1011
Note: See TracChangeset
for help on using the changeset viewer.