- Timestamp:
- 09/26/08 10:31:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2974 r2975 9 9 #include "ShadowMapping.h" 10 10 #include "Light.h" 11 #include "ToneMapper.h"12 11 13 12 … … 553 552 FirstPass(fbo, light); 554 553 555 glEnable(GL_TEXTURE_2D);556 // generate mip map levels for position texture557 glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture());558 glGenerateMipmapEXT(GL_TEXTURE_2D);559 560 554 561 555 switch (mShadingMethod) … … 576 570 float imageKey, whiteLum, middleGrey; 577 571 572 // generate mip map levels of position texture 573 glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture()); 574 glGenerateMipmapEXT(GL_TEXTURE_2D); 575 578 576 ComputeToneParameters(fbo, light, imageKey, whiteLum, middleGrey); 579 577 ToneMap(fbo, light, imageKey, whiteLum, middleGrey); … … 603 601 { 604 602 #ifdef USE_3D_SSAO 603 // bias from [-1, 1] to [0, 1] 605 604 static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.5f, 606 605 0.0f, 0.5f, 0.0f, 0.5f, 607 606 0.0f, 0.0f, 0.5f, 0.5f, 608 0.0f, 0.0f, 0.0f, 1.0f); //bias from [-1, 1] to [0, 1]607 0.0f, 0.0f, 0.0f, 1.0f); 609 608 610 609 Matrix4x4 m = projViewMatrix * biasMatrix; … … 615 614 cgGLSetMatrixParameterfc(sOldModelViewProjMatrixParam, (const float *)oldProjViewMatrix.x); 616 615 617 GLuint colorsTex = fbo->GetColorBuffer( 3)->GetTexture();616 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 618 617 GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 619 618 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 620 619 621 // generate mip map levels forposition texture620 // generate mip map levels of position texture 622 621 glBindTexture(GL_TEXTURE_2D, positionsTex); 623 622 glGenerateMipmapEXT(GL_TEXTURE_2D); … … 628 627 glDrawBuffers(1, mrt + mFboIndex); 629 628 630 631 //GLuint oldTex = mOldFbo->GetColorBuffer(0)->GetTexture();632 629 GLuint oldTex = mFbo->GetColorBuffer(2 - mFboIndex)->GetTexture(); 633 630 … … 677 674 glBegin(GL_QUADS); 678 675 679 // note: slightly larger texture hides ambient occlusion error on border but costs resolution 680 //const float new_offs = 0.55f; 681 const float new_offs = 0.5f; 682 683 glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-new_offs, -new_offs, -0.5f); 684 glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( new_offs, -new_offs, -0.5f); 685 glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( new_offs, new_offs, -0.5f); 686 glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-new_offs, new_offs, -0.5f); 676 // note: slightly larger texture could hide ambient occlusion error on border but costs resolution 677 const float offs = 0.5f; 678 679 glTexCoord2f(0, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, bl.x, bl.y, bl.z); glVertex3f(-offs, -offs, -0.5f); 680 glTexCoord2f(1, 0); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, br.x, br.y, br.z); glVertex3f( offs, -offs, -0.5f); 681 glTexCoord2f(1, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tr.x, tr.y, tr.z); glVertex3f( offs, offs, -0.5f); 682 glTexCoord2f(0, 1); glMultiTexCoord3fARB(GL_TEXTURE1_ARB, tl.x, tl.y, tl.z); glVertex3f(-offs, offs, -0.5f); 687 683 688 684 glEnd(); … … 1133 1129 float &middleGrey) 1134 1130 { 1135 ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 1136 1137 // we assume that we have a floating point rgba texture 1138 float *pixels = (float *)colorBuffer->ReadTexture(); 1139 1140 const int w = colorBuffer->GetHeight(); 1141 const int h = colorBuffer->GetWidth(); 1142 1143 imageKey = ToneMapper().CalcImageKey(pixels, w, h); 1144 whiteLum = 1.0f * ToneMapper().CalcMaxLuminance(pixels, w, h); 1145 1146 //const float minKey = 0.18f; 1147 //const float maxKey = 0.72f; 1148 1149 //const float minKey = 0.0045f; 1131 // hack: estimate value where sky burns out 1132 whiteLum = log(1e4f); 1133 1134 //////////////////// 1135 //-- linear interpolate brightness key depending on the current sun position 1136 1150 1137 const float minKey = 0.09f; 1151 1138 const float maxKey = 0.5f; … … 1153 1140 const float lightIntensity = DotProd(-light->GetDirection(), Vector3::UNIT_Z()); 1154 1141 middleGrey = lightIntensity * maxKey + (1.0f - lightIntensity) * minKey; 1155 1156 //cout << "middlegrey: " << middleGrey << endl;1157 delete [] pixels;1158 1159 1160 /////////////1161 1162 /*GLuint colorsTex = colorBuffer->GetTexture();1163 1164 fbo->Bind();1165 1166 colorBufferIdx = 3 - colorBufferIdx;1167 glDrawBuffers(1, mrt + colorBufferIdx);1168 1169 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);1170 1171 cgGLEnableProfile(RenderState::sCgFragmentProfile);1172 cgGLBindProgram(sCgInitialIntensityProgram);1173 1174 cgGLSetTextureParameter(sColorsTexInitialParam, colorsTex);1175 cgGLEnableTextureParameter(sColorsTexInitialParam);1176 1177 // first pass: create high res intensity texture1178 glColor3f(1.0f, 1.0f, 1.0f);1179 1180 float offs2 = 0.5f;1181 1182 glBegin(GL_QUADS);1183 1184 // the neighbouring texels1185 float x_offs = 0;//1.0f / mWidth;1186 float y_offs = 0;//1.0f / mHeight;1187 1188 SetVertex(0, 0, x_offs, y_offs);1189 SetVertex(1, 0, x_offs, y_offs);1190 SetVertex(1, 1, x_offs, y_offs);1191 SetVertex(0, 1, x_offs, y_offs);1192 1193 glEnd();1194 1195 cgGLDisableTextureParameter(sColorsTexToneParam);1196 1197 FrameBufferObject::Release();1198 1199 1200 ////////////1201 //-- second phase: down sample the texture in order to compute the average1202 1203 // q: required passes for computing 1x1 texture?1204 int passes = 32;1205 1206 for (int i = 0; i < 32; ++ i)1207 {1208 //DownSample(fbo);1209 }1210 */1211 PrintGLerror("antialiasing");1212 1142 } 1213 1143
Note: See TracChangeset
for help on using the changeset viewer.