Changeset 3117 for GTP/trunk/App/Demos
- Timestamp:
- 11/11/08 12:18:07 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3115 r3117 2 2 # environment file for the friendlyculling demo 3 3 4 ############ 5 ## chc++ options 6 4 7 assumedVisibleFrames=10 5 8 maxBatchSize=50 9 # triangles per bvh leaf (influences hierarchy depth vs. occlusion power) 6 10 trianglesPerVirtualLeaf=300 7 #trianglesPerVirtualLeaf=30000 8 keyForwardMotion=20.0f 9 keyRotation=1.5f 11 12 13 # move speed 14 keyForwardMotion=5.0f 15 keyRotation=0.5f 16 #keyForwardMotion=20.0f 17 #keyRotation=1.5f 18 19 10 20 winWidth=1024 11 21 winHeight=768 22 23 # initial positin + orientation 12 24 camPosition=483.398f 242.364f 186.078f 13 25 camDirection=1 0 0 26 14 27 #lightDirection=-0.8f 1.0f -0.7f 15 28 lightDirection=-0.3f 0.2f -0.7f 16 #lightDirection=0.0f 0.0f -1.0f 29 17 30 useFullScreen=0 18 31 useLODs=1 19 32 shadowSize=4096 33 20 34 #modelPath=data/city/model/ 35 21 36 22 37 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3115 r3117 234 234 235 235 236 static void InitBuffer(FrameBufferObject *fbo, int index)237 {238 // read the second buffer, write to the first buffer239 fbo->Bind();240 glDrawBuffers(1, mrt + index);241 242 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);243 244 FrameBufferObject::Release();245 }246 247 248 236 DeferredRenderer::DeferredRenderer(int w, int h, PerspectiveCamera *cam): 249 237 mWidth(w), mHeight(h), … … 270 258 { 271 259 mIllumFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 272 InitBuffer(mIllumFbo, i); 273 } 260 FrameBufferObject::InitBuffer(mIllumFbo, i); 261 } 262 263 264 /////////////// 265 //-- the downsampled ssao + color bleeding textures: as gi is inherently low frequency, we can use these to improve performance 274 266 275 267 mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); … … 278 270 // downsample buffer for the normal texture 279 271 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 272 // downsample buffer for the offset texture 273 mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 274 275 for (int i = 0; i < 3; ++ i) 276 { 277 FrameBufferObject::InitBuffer(mDownSampleFbo, i); 278 } 280 279 281 280 mFBOs.push_back(mDownSampleFbo); … … 453 452 // normals 454 453 DownSample(fbo, 1, mDownSampleFbo, 1); 454 // offsets 455 DownSample(fbo, 2, mDownSampleFbo, 2); 455 456 } 456 457 … … 458 459 { 459 460 case SSAO: 460 461 461 ComputeSsao(fbo, tempCohFactor); 462 462 CombineSsao(fbo); … … 501 501 float tempCohFactor) 502 502 { 503 GLuint colorsTex, normalsTex, attribsTex; 504 505 if (0) 506 { 507 colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 508 normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 509 attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 510 } 511 else 512 { 513 colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 514 normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 515 attribsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 516 } 517 518 // flip flop between illumination buffers 519 GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 520 521 cout << colorBufferIdx; 522 523 glPushAttrib(GL_VIEWPORT_BIT); 524 glViewport(0, 0, mIllumFbo->GetWidth(), mIllumFbo->GetHeight()); 525 526 // read the second buffer, write to the first buffer 527 mIllumFbo->Bind(); 528 glDrawBuffers(1, mrt + mIllumFboIndex); 529 530 int i = 0; 531 532 sCgSsaoProgram->SetTexture(i ++, colorsTex); 533 sCgSsaoProgram->SetTexture(i ++, normalsTex); 534 sCgSsaoProgram->SetTexture(i ++, oldTex); 535 sCgSsaoProgram->SetTexture(i ++, noiseTex); 536 537 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 538 539 if (mUseTemporalCoherence || mRegenerateSamples) 540 { 541 mRegenerateSamples = false; 542 543 // q: should we generate new samples or only rotate the old ones? 544 // in the first case, the sample patterns look nicer, but the kernel 545 // needs longer to converge 546 GenerateSamples(mSamplingMethod); 547 sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 548 } 549 550 ++ i; 551 552 for (int j = 0; j < 4; ++ j, ++ i) 553 sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 554 555 sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 556 sCgSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 557 558 Vector3 de; 559 de.x = mOldEyePos.x - mEyePos.x; 560 de.y = mOldEyePos.y - mEyePos.y; 561 de.z = mOldEyePos.z - mEyePos.z; 562 563 sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 564 565 for (int j = 0; j < 4; ++ j, ++ i) 566 sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 567 568 sCgSsaoProgram->SetTexture(i ++, attribsTex); 569 570 DrawQuad(sCgSsaoProgram); 571 572 glPopAttrib(); 573 574 PrintGLerror("ssao first pass"); 575 } 576 577 578 static void SetVertex(float x, float y, float x_offs, float y_offs) 579 { 580 glMultiTexCoord2fARB(GL_TEXTURE0_ARB, x, y); // center 581 glMultiTexCoord2fARB(GL_TEXTURE1_ARB, x - x_offs, y + y_offs); // left top 582 glMultiTexCoord2fARB(GL_TEXTURE2_ARB, x + x_offs, y - y_offs); // right bottom 583 glMultiTexCoord2fARB(GL_TEXTURE3_ARB, x + x_offs, y + y_offs); // right top 584 glMultiTexCoord2fARB(GL_TEXTURE4_ARB, x - x_offs, y - y_offs); // left bottom 585 586 glMultiTexCoord4fARB(GL_TEXTURE5_ARB, x - x_offs, y, x + x_offs, y); // left right 587 glMultiTexCoord4fARB(GL_TEXTURE6_ARB, x, y + y_offs, x, y - y_offs); // top bottom 588 589 //glVertex3f(x - 0.5f, y - 0.5f, -0.5f); 590 glVertex2f(x, y); 591 } 592 593 594 void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light) 595 { 596 FrameBufferObject::Release(); 597 598 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 599 600 GLuint colorsTex = colorBuffer->GetTexture(); 601 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 602 603 sCgAntiAliasingProgram->SetTexture(0, colorsTex); 604 sCgAntiAliasingProgram->SetTexture(1, normalsTex); 605 606 sCgAntiAliasingProgram->Bind(); 607 608 glBegin(GL_QUADS); 609 610 // the neighbouring texels 611 float x_offs = 1.0f / mWidth; 612 float y_offs = 1.0f / mHeight; 613 614 SetVertex(0, 0, x_offs, y_offs); 615 SetVertex(1, 0, x_offs, y_offs); 616 SetVertex(1, 1, x_offs, y_offs); 617 SetVertex(0, 1, x_offs, y_offs); 618 619 glEnd(); 620 621 PrintGLerror("antialiasing"); 622 } 623 624 625 void DeferredRenderer::FirstPass(FrameBufferObject *fbo, DirectionalLight *light) 626 { 627 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 628 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 629 630 fbo->Bind(); 631 632 colorBufferIdx = 3 - colorBufferIdx; 633 glDrawBuffers(1, mrt + colorBufferIdx); 634 635 const Vector3 lightDir = -light->GetDirection(); 636 637 sCgDeferredProgram->SetTexture(0, colorsTex); 638 sCgDeferredProgram->SetTexture(1, normalsTex); 639 sCgDeferredProgram->SetValue3f(2, lightDir.x, lightDir.y, lightDir.z); 640 641 DrawQuad(sCgDeferredProgram); 642 643 PrintGLerror("deferred shading"); 644 } 645 646 647 void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo, 648 float tempCohFactor) 649 { 503 650 #if 0 504 651 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); … … 509 656 #endif 510 657 511 // flip flop between illumination buffers512 GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture();513 514 658 glPushAttrib(GL_VIEWPORT_BIT); 515 659 glViewport(0, 0, mIllumFbo->GetWidth(), mIllumFbo->GetHeight()); … … 517 661 // read the second buffer, write to the first buffer 518 662 mIllumFbo->Bind(); 519 glDrawBuffers(1, mrt + mIllumFboIndex);520 521 int i = 0;522 523 sCgSsaoProgram->SetTexture(i ++, colorsTex);524 sCgSsaoProgram->SetTexture(i ++, normalsTex);525 sCgSsaoProgram->SetTexture(i ++, oldTex);526 sCgSsaoProgram->SetTexture(i ++, noiseTex);527 528 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0);529 530 if (mUseTemporalCoherence || mRegenerateSamples)531 {532 mRegenerateSamples = false;533 534 // q: should we generate new samples or only rotate the old ones?535 // in the first case, the sample patterns look nicer, but the kernel536 // needs longer to converge537 GenerateSamples(mSamplingMethod);538 sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES);539 }540 541 ++ i;542 543 for (int j = 0; j < 4; ++ j, ++ i)544 sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z);545 546 sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix);547 sCgSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix);548 549 //Vector3 de = mOldEyePos - mEyePos;550 Vector3 de;551 de.x = mOldEyePos.x - mEyePos.x;552 de.y = mOldEyePos.y - mEyePos.y;553 de.z = mOldEyePos.z - mEyePos.z;554 //Vector3 de = mEyePos - mOldEyePos;555 556 sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z);557 558 for (int j = 0; j < 4; ++ j, ++ i)559 sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z);560 561 GLuint attribsTex = fbo->GetColorBuffer(2)->GetTexture();562 sCgSsaoProgram->SetTexture(i ++, attribsTex);563 564 float trafos[32];565 for (int i = 0; i < 16; ++ i)566 trafos[i] = ((const float *)invTrafo.x)[i];567 568 static Matrix4x4 identity = IdentityMatrix();569 570 for (int i = 0; i < 16; ++ i)571 trafos[i+16] = ((const float *)identity.x)[i];572 573 //sCgSsaoProgram->SetMatrixArray(i ++, trafos, 2);574 //sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix());575 576 DrawQuad(sCgSsaoProgram);577 578 glPopAttrib();579 580 PrintGLerror("ssao first pass");581 }582 583 584 static void SetVertex(float x, float y, float x_offs, float y_offs)585 {586 glMultiTexCoord2fARB(GL_TEXTURE0_ARB, x, y); // center587 glMultiTexCoord2fARB(GL_TEXTURE1_ARB, x - x_offs, y + y_offs); // left top588 glMultiTexCoord2fARB(GL_TEXTURE2_ARB, x + x_offs, y - y_offs); // right bottom589 glMultiTexCoord2fARB(GL_TEXTURE3_ARB, x + x_offs, y + y_offs); // right top590 glMultiTexCoord2fARB(GL_TEXTURE4_ARB, x - x_offs, y - y_offs); // left bottom591 592 glMultiTexCoord4fARB(GL_TEXTURE5_ARB, x - x_offs, y, x + x_offs, y); // left right593 glMultiTexCoord4fARB(GL_TEXTURE6_ARB, x, y + y_offs, x, y - y_offs); // top bottom594 595 //glVertex3f(x - 0.5f, y - 0.5f, -0.5f);596 glVertex2f(x, y);597 }598 599 600 void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light)601 {602 FrameBufferObject::Release();603 604 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx);605 606 GLuint colorsTex = colorBuffer->GetTexture();607 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture();608 609 sCgAntiAliasingProgram->SetTexture(0, colorsTex);610 sCgAntiAliasingProgram->SetTexture(1, normalsTex);611 612 sCgAntiAliasingProgram->Bind();613 614 glBegin(GL_QUADS);615 616 // the neighbouring texels617 float x_offs = 1.0f / mWidth;618 float y_offs = 1.0f / mHeight;619 620 SetVertex(0, 0, x_offs, y_offs);621 SetVertex(1, 0, x_offs, y_offs);622 SetVertex(1, 1, x_offs, y_offs);623 SetVertex(0, 1, x_offs, y_offs);624 625 glEnd();626 627 PrintGLerror("antialiasing");628 }629 630 631 void DeferredRenderer::FirstPass(FrameBufferObject *fbo, DirectionalLight *light)632 {633 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();634 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture();635 636 fbo->Bind();637 638 colorBufferIdx = 3 - colorBufferIdx;639 glDrawBuffers(1, mrt + colorBufferIdx);640 641 const Vector3 lightDir = -light->GetDirection();642 643 sCgDeferredProgram->SetTexture(0, colorsTex);644 sCgDeferredProgram->SetTexture(1, normalsTex);645 sCgDeferredProgram->SetValue3f(2, lightDir.x, lightDir.y, lightDir.z);646 647 DrawQuad(sCgDeferredProgram);648 649 PrintGLerror("deferred shading");650 }651 652 653 void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo,654 float tempCohFactor)655 {656 #if 0657 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture();658 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture();659 #else660 GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture();661 GLuint normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture();662 #endif663 664 glPushAttrib(GL_VIEWPORT_BIT);665 glViewport(0, 0, mIllumFbo->GetWidth(), mIllumFbo->GetHeight());666 667 // read the second buffer, write to the first buffer668 mIllumFbo->Bind();669 663 670 664 glDrawBuffers(2, mrt + mIllumFboIndex); … … 672 666 GLuint oldSsaoTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 673 667 GLuint oldIllumTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 674 675 668 676 669 sCgGiProgram->SetTexture(0, colorsTex); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp
r3021 r3117 364 364 365 365 366 void FrameBufferObject::InitBuffer(FrameBufferObject *fbo, int index) 367 { 368 // read the second buffer, write to the first buffer 369 fbo->Bind(); 370 glDrawBuffers(1, mrt + index); 371 372 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 373 374 FrameBufferObject::Release(); 375 } 376 366 377 } // namespace -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
r3017 r3117 29 29 WRAP_TYPE wrapType, 30 30 FILTER_TYPE filterType); 31 32 31 /** Same as above, with mipmapping enabled. 33 32 */ … … 41 40 42 41 ~ColorBufferObject(); 43 42 /** Returns associated texture id. 43 */ 44 44 inline unsigned int GetTexture() const { return mTexId; } 45 45 /** Returns width of render target. 46 */ 46 47 inline int GetWidth() { return mWidth; } 47 48 /** Returns height of render target. 49 */ 48 50 inline int GetHeight() { return mHeight; } 49 51 /** Returns texture data. … … 78 80 79 81 80 /** This class implements a wrapper for a frame buffer object 82 /** This class implements a wrapper for a frame buffer object. 81 83 */ 82 84 class FrameBufferObject … … 84 86 public: 85 87 88 /// Available depth formats 86 89 enum DEPTH_FORMAT {DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32}; 87 90 … … 89 92 */ 90 93 FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false); 91 94 /** Destructor destroying gl resources. 95 */ 92 96 ~FrameBufferObject(); 93 97 /** Creates and adds a color buffer to the current frame buffer object. … … 105 109 ColorBufferObject::FILTER_TYPE filterTypeMipMap); 106 110 107 /** Returns the color buffer object on position i.108 */109 ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; }110 111 /** Binds this frame buffer object. 111 112 */ 112 113 void Bind() const; 114 115 /////////////////// 116 117 /** Returns the color buffer object on position i. 118 */ 119 inline ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; } 120 /** Returns depth texture id 121 */ 122 inline unsigned int GetDepthTex() const { return mDepthTexId; } 123 /** Returns width of fbo 124 */ 125 inline int GetWidth() { return mWidth; } 126 /** Returns height of fbo 127 */ 128 inline int GetHeight() { return mHeight; } 129 130 131 //////////////// 132 133 /** Initialise a render target (using current clear color) 134 */ 135 static void InitBuffer(FrameBufferObject *fbo, int index); 113 136 /** Releases any bound frame buffer object. 114 137 */ 115 138 static void Release(); 116 139 117 unsigned int GetDepthTex() const { return mDepthTexId; }118 119 inline int GetWidth() { return mWidth; }120 121 inline int GetHeight() { return mHeight; }122 123 124 140 protected: 125 141 … … 137 153 }; 138 154 155 139 156 } // namespace 157 140 158 #endif // _FrameBufferObject_H__ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3114 r3117 139 139 { 140 140 //if (mCurrentTechnique == tech) return; 141 142 141 mCurrentTechnique = tech; 143 142 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3115 r3117 361 361 env.GetIntParam(string("winWidth"), winWidth); 362 362 env.GetIntParam(string("winHeight"), winHeight); 363 364 env.GetBoolParam(string("useFullScreen"), useFullScreen);365 363 env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 366 364 env.GetVectorParam(string("camPosition"), camPos); 367 365 env.GetVectorParam(string("camDirection"), camDir); 368 366 env.GetVectorParam(string("lightDirection"), lightDir); 369 367 env.GetIntParam(string("shadowSize"), shadowSize); 368 369 env.GetBoolParam(string("useFullScreen"), useFullScreen); 370 370 env.GetBoolParam(string("useLODs"), useLODs); 371 env.GetIntParam(string("shadowSize"), shadowSize);372 373 371 env.GetBoolParam(string("useHDR"), useHDR); 372 374 373 375 374 //env.GetStringParam(string("modelPath"), model_path); … … 464 463 //-- load some dynamic stuff 465 464 466 LoadModel("hbuddha.dem", dynamicObjects);465 /* LoadModel("hbuddha.dem", dynamicObjects); 467 466 buddha = dynamicObjects.back(); 468 467 … … 488 487 dynamicObjects.push_back(ent); 489 488 } 490 489 */ 491 490 492 491 /////////// … … 523 522 preetham = new SkyPreetham(turbitiy, skyDome); 524 523 525 CreateAnimation(); 526 527 for (int i = 0; i < sceneEntities.size(); ++ i) 528 sceneEntities[i]->mId = 0; 529 for (int i = 0; i < dynamicObjects.size(); ++ i) 530 dynamicObjects[i]->mId = 0; 531 532 //buddha->mId = 250; 533 buddha->mId = 1; 524 //CreateAnimation(); 534 525 535 526 … … 567 558 // we store diffuse colors, eye space depth and normals 568 559 fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32); 569 //fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_24);570 560 571 561 // the diffuse color buffer … … 575 565 // a rgb buffer which could hold material properties 576 566 //fbo->AddColorBuffer(ColorBufferObject::RGB_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 577 // holding the difference vector to the old frame567 // buffer holding the difference vector to the old frame 578 568 fbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 579 569 // another color buffer 580 570 fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, ColorBufferObject::FILTER_NEAREST); 581 571 582 PrintGLerror("fbo"); 572 for (int i = 0; i < 4; ++ i) 573 FrameBufferObject::InitBuffer(fbo, i); 574 575 PrintGLerror("init fbo"); 583 576 } 584 577 … … 902 895 void MainLoop() 903 896 { 904 GPUProgramParameters *vtxParams =897 /*GPUProgramParameters *vtxParams = 905 898 buddha->GetShape(0)->GetMaterial()->GetTechnique(1)->GetVertexProgramParameters(); 906 899 … … 915 908 dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 916 909 917 910 */ 918 911 ///////////// 919 912 … … 1144 1137 ///////////////////////// 1145 1138 1146 / /motionPath->Move(0.3f);1139 /*//motionPath->Move(0.3f); 1147 1140 motionPath->Move(0.01f); 1148 1141 Vector3 oldBuddhaPos = buddhaPos; … … 1155 1148 invTrafo = TranslationMatrix(diff); 1156 1149 //cout<< "diff " << diff << endl; 1150 */ 1157 1151 } 1158 1152 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3113 r3117 16 16 17 17 float4 color: COLOR0; 18 float4 eyePos: TEXCOORD1; // eye position 18 // eye position 19 float4 eyePos: TEXCOORD1; 19 20 float4 normal: TEXCOORD2; 20 21 float4 worldPos: TEXCOORD3; … … 30 31 31 32 float4 winPos: WPOS; 32 float4 eyePos: TEXCOORD1; // eye position 33 // eye position 34 float4 eyePos: TEXCOORD1; 33 35 float4 normal: TEXCOORD2; 34 36 float4 worldPos: TEXCOORD3; … … 61 63 // transform the vertex position into post projection space 62 64 OUT.position = mul(glstate.matrix.mvp, IN.position); 63 64 65 // the normal has to be correctly transformed with the inverse transpose 65 66 OUT.normal = mul(glstate.matrix.invtrans.modelview[0], IN.normal); 66 67 67 // transform the old vertex position into world space 68 68 OUT.worldPos = mul(modelMatrix, IN.position); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3115 r3117 177 177 178 178 #else 179 179 180 // calculate eye space position of sample in old frame 180 181 const float oldDepth = oldPixel.w; … … 182 183 // vector from eye pos to old sample 183 184 const float depthDif = abs(projectedDepth - oldDepth); 185 184 186 #endif 185 187 … … 210 212 } 211 213 212 213 // the number of valid samples in this frame214 //const float newNumSamples = ao.y;215 //const float oldNumSamples = oldCol.y;216 217 214 const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence); 218 215 float newWeight; … … 256 253 */ 257 254 float2 ssao(fragment IN, 258 uniform sampler2D colors, 259 uniform sampler2D noiseTex, 260 uniform float2 samples[NUM_SAMPLES], 261 uniform float3 normal, 262 uniform float3 centerPosition, 263 uniform float scaleFactor, 264 uniform float3 bl, 265 uniform float3 br, 266 uniform float3 tl, 267 uniform float3 tr, 268 uniform float3 viewDir 255 sampler2D colors, 256 sampler2D noiseTex, 257 float2 samples[NUM_SAMPLES], 258 float3 normal, 259 float3 centerPosition, 260 float scaleFactor, 261 float3 bl, 262 float3 br, 263 float3 tl, 264 float3 tr, 265 float3 viewDir 266 //,float2 noiseOffs 269 267 ) 270 268 { … … 285 283 //-- add random noise: reflect around random normal vector (rather slow!) 286 284 285 //float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f + noiseOffs, 0, 0)).xy; 287 286 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 288 287 const float2 offsetTransformed = myreflect(offset, mynoise); … … 374 373 { 375 374 ao = ssao(IN, colors, noiseTex, samples, normal, 376 eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir)); 375 eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir));//, noiseOffs); 377 376 } 378 377
Note: See TracChangeset
for help on using the changeset viewer.