Changeset 3007 for GTP/trunk/App/Demos/Vis/FriendlyCulling
- Timestamp:
- 10/06/08 15:50:50 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3006 r3007 611 611 612 612 613 FrameBufferObject::Release();614 613 cgGLEnableProfile(RenderState::sCgFragmentProfile); 615 614 … … 617 616 glDisable(GL_TEXTURE_2D); 618 617 glDisable(GL_LIGHTING); 618 glDisable(GL_BLEND); 619 619 620 620 glPushAttrib(GL_VIEWPORT_BIT); … … 631 631 glPushMatrix(); 632 632 glLoadIdentity(); 633 634 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 633 635 634 636 if (shadowMap) … … 663 665 664 666 ComputeToneParameters(fbo, light, imageKey, whiteLum, middleGrey); 665 ToneMap(fbo, light,imageKey, whiteLum, middleGrey);667 ToneMap(fbo, imageKey, whiteLum, middleGrey); 666 668 } 667 669 … … 679 681 glPopAttrib(); 680 682 683 FrameBufferObject::Release(); 681 684 cgGLDisableProfile(RenderState::sCgFragmentProfile); 682 685 } … … 712 715 GLuint positionsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 713 716 GLuint normalsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 717 GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 714 718 715 719 glPushAttrib(GL_VIEWPORT_BIT); … … 720 724 glDrawBuffers(1, mrt + mFboIndex); 721 725 722 GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture();723 726 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 724 727 728 725 729 cgGLBindProgram(sCgSsaoProgram); 726 730 … … 791 795 792 796 glPopAttrib(); 793 FrameBufferObject::Release();794 797 795 798 PrintGLerror("ssao first pass"); … … 827 830 void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light) 828 831 { 832 FrameBufferObject::Release(); 833 829 834 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 830 835 831 836 GLuint colorsTex = colorBuffer->GetTexture(); 832 837 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 833 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 838 839 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 834 840 cgGLBindProgram(sCgAntiAliasingProgram); 835 841 … … 874 880 glDrawBuffers(1, mrt + colorBufferIdx); 875 881 876 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);882 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 877 883 878 884 cgGLBindProgram(sCgDeferredProgram); … … 907 913 cgGLDisableTextureParameter(sPositionsTexDeferredParam); 908 914 cgGLDisableTextureParameter(sNormalsTexDeferredParam); 909 910 FrameBufferObject::Release();911 915 912 916 PrintGLerror("deferred shading"); … … 1016 1020 cgGLDisableTextureParameter(sOldIllumTexGiParam); 1017 1021 1018 FrameBufferObject::Release();1019 1020 1022 glPopAttrib(); 1021 1023 … … 1070 1072 cgGLDisableTextureParameter(sIllumTexCombinedIllumParam); 1071 1073 1072 FrameBufferObject::Release();1073 1074 1074 PrintGLerror("combine"); 1075 1075 } … … 1115 1115 cgGLDisableTextureParameter(sSsaoTexCombinedSsaoParam); 1116 1116 1117 FrameBufferObject::Release();1118 1119 1117 PrintGLerror("combine ssao"); 1120 1118 } … … 1189 1187 cgGLDisableTextureParameter(sNoiseTexShadowParam); 1190 1188 1191 FrameBufferObject::Release();1192 1193 1189 PrintGLerror("deferred shading + shadows"); 1194 1190 } … … 1266 1262 1267 1263 cgGLDisableTextureParameter(sColorsTexLogLumParam); 1268 FrameBufferObject::Release();1269 1264 1270 1265 PrintGLerror("ToneMapParams"); … … 1275 1270 //-- compute avg loglum in scene using mipmapping 1276 1271 1277 glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture());1278 glGenerateMipmapEXT(GL_TEXTURE_2D);1272 //glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture()); 1273 //glGenerateMipmapEXT(GL_TEXTURE_2D); 1279 1274 } 1280 1275 … … 1342 1337 1343 1338 cgGLDisableTextureParameter(sColorsTexDownSampleParam); 1344 FrameBufferObject::Release();1345 1339 1346 1340 /*float *data = (float *)mDownSampleFbo->GetColorBuffer(0)->ReadTexture(); … … 1355 1349 1356 1350 void DeferredRenderer::ToneMap(FrameBufferObject *fbo, 1357 DirectionalLight *light,1358 1351 float imageKey, 1359 1352 float whiteLum, … … 1364 1357 1365 1358 fbo->Bind(); 1366 1359 #if 0 1367 1360 colorBufferIdx = 3 - colorBufferIdx; 1368 1361 glDrawBuffers(1, mrt + colorBufferIdx); 1362 1369 1363 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1370 1364 1371 1365 cgGLBindProgram(sCgToneProgram); 1372 1366 1373 1367 cgGLSetTextureParameter(sColorsTexToneParam, colorsTex); 1374 1368 cgGLEnableTextureParameter(sColorsTexToneParam); … … 1380 1374 glColor3f(1.0f, 1.0f, 1.0f); 1381 1375 1376 1382 1377 glBegin(GL_QUADS); 1383 1378 1384 // the neighbouring texels 1385 const float x_offs = 1.0f / mWidth; 1386 const float y_offs = 1.0f / mHeight; 1387 1388 SetVertex(0, 0, x_offs, y_offs); 1389 SetVertex(1, 0, x_offs, y_offs); 1390 SetVertex(1, 1, x_offs, y_offs); 1391 SetVertex(0, 1, x_offs, y_offs); 1379 const float offs = 0.5f; 1380 1381 1382 glTexCoord2f(0, 0); glVertex3f(-offs, -offs, -0.5f); 1383 glTexCoord2f(1, 0); glVertex3f( offs, -offs, -0.5f); 1384 glTexCoord2f(1, 1); glVertex3f( offs, offs, -0.5f); 1385 glTexCoord2f(0, 1); glVertex3f(-offs, offs, -0.5f); 1392 1386 1393 1387 glEnd(); 1388 #endif 1394 1389 1395 1390 cgGLDisableTextureParameter(sColorsTexToneParam); 1396 FrameBufferObject::Release();1397 1391 1398 1392 PrintGLerror("ToneMap"); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3006 r3007 80 80 void ComputeToneParameters(FrameBufferObject *fbo, DirectionalLight *light, float &imageKey, float &whiteLum, float &middleGrey); 81 81 82 void ToneMap(FrameBufferObject *fbo, DirectionalLight *light,float imageKey, float whiteLum, float middleGrey);82 void ToneMap(FrameBufferObject *fbo, float imageKey, float whiteLum, float middleGrey); 83 83 84 84 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp
r3005 r3007 8 8 namespace CHCDemoEngine 9 9 { 10 11 int FrameBufferObject::sCurrentFbo = -1; 10 12 11 13 … … 337 339 void FrameBufferObject::Bind() const 338 340 { 339 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 341 if (sCurrentFbo != mId) 342 { 343 sCurrentFbo = mId; 344 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mId); 345 } 340 346 } 341 347 … … 344 350 { 345 351 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 352 sCurrentFbo = -1; 346 353 } 347 354 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
r3006 r3007 132 132 133 133 unsigned int mDepthTexId; 134 135 static int sCurrentFbo; 134 136 }; 135 137 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg
r3006 r3007 67 67 average = exp(average * 0.25f); 68 68 69 float4 hcols= cols[0] + cols[1] + cols[2] + cols[3];69 float4 c = cols[0] + cols[1] + cols[2] + cols[3]; 70 70 71 return hcols * 0.25f; 72 //return float4(average, maximum, 0.0f, cols[0].w); 73 71 return c * 0.25f; 74 72 // Output the luminance to the render target 75 73 //return float4(average, maximum, 0.0f, 1.0f); … … 84 82 { 85 83 pixel OUT; 84 return OUT; 86 85 float4 color = tex2D(colors, IN.texCoord); 87 86 … … 113 112 114 113 pixel OUT; 115 116 float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0));114 return OUT;/* 115 const float4 color = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 117 116 118 117 OUT.col = color; … … 135 134 OUT.col.w = logLumScaled; 136 135 137 return OUT; 136 return OUT;*/ 138 137 }
Note: See TracChangeset
for help on using the changeset viewer.