- Timestamp:
- 08/26/08 18:09:03 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SsaoShader.cpp
r2868 r2869 21 21 static CGprogram sCgDeferredProgram2 = NULL; 22 22 static CGprogram sCgAntiAliasingProgram = NULL; 23 static CGprogram sCgCombineProgram = NULL; 24 25 static CGparameter sColorsTexCombineParam; 26 static CGparameter sSsaoTexCombineParam; 23 27 24 28 static CGparameter sColorsTexDeferredParam; … … 91 95 // the diffuse color buffer 92 96 mFbo3->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 93 97 98 mFbo4 = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 99 // the diffuse color buffer 100 mFbo4->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, false); 94 101 95 102 // create noise texture for ssao … … 131 138 else 132 139 cerr << "deferred program failed to load" << endl; 140 141 142 sCgCombineProgram = 143 cgCreateProgramFromFile(context, 144 CG_SOURCE, 145 "src/shaders/ssao.cg", 146 RenderState::sCgFragmentProfile, 147 "combined", 148 NULL); 149 150 if (sCgCombineProgram != NULL) 151 { 152 cgGLLoadProgram(sCgCombineProgram); 153 154 // we need size of texture for scaling 155 sColorsTexCombineParam = cgGetNamedParameter(sCgCombineProgram, "colors"); 156 sSsaoTexCombineParam = cgGetNamedParameter(sCgCombineProgram, "ssaoTex"); 157 } 158 else 159 cerr << "combined program failed to load" << endl; 133 160 134 161 … … 230 257 FirstPass(fbo); 231 258 ComputeSsao(fbo, expFactor); 259 Combine(fbo); 232 260 AntiAliasing(fbo); 233 261 … … 415 443 void SsaoShader::AntiAliasing(FrameBufferObject *fbo) 416 444 { 417 GLuint colorsTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 445 GLuint colorsTex = mFbo4->GetColorBuffer(0)->GetTexture(); 446 //GLuint colorsTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 418 447 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 419 448 … … 503 532 } 504 533 534 535 void SsaoShader::Combine(FrameBufferObject *fbo) 536 { 537 GLuint colorsTex = mFbo3->GetColorBuffer(0)->GetTexture(); 538 GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 539 540 mFbo4->Bind(); 541 //mNewFbo->Bind(); 542 543 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 544 545 glDrawBuffers(1, mymrt); 546 547 cgGLEnableProfile(RenderState::sCgFragmentProfile); 548 549 cgGLBindProgram(sCgCombineProgram); 550 551 cgGLSetTextureParameter(sColorsTexCombineParam, colorsTex); 552 cgGLEnableTextureParameter(sColorsTexCombineParam); 553 554 cgGLSetTextureParameter(sSsaoTexCombineParam, ssaoTex); 555 cgGLEnableTextureParameter(sSsaoTexCombineParam); 556 557 glColor3f(1.0f, 1.0f, 1.0f); 558 559 const float offs = 0.5f; 560 561 glBegin(GL_QUADS); 562 563 glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 564 glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 565 glTexCoord2f(1, 1); glVertex3f( offs, offs, -0.5f); 566 glTexCoord2f(0, 1); glVertex3f(-offs, offs, -0.5f); 567 568 glEnd(); 569 570 cgGLDisableTextureParameter(sColorsTexCombineParam); 571 cgGLDisableTextureParameter(sSsaoTexCombineParam); 572 573 cgGLDisableProfile(RenderState::sCgFragmentProfile); 574 575 FrameBufferObject::Release(); 576 577 PrintGLerror("deferred shading"); 578 } 579 580 505 581 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.