Changeset 2977
- Timestamp:
- 09/26/08 18:41:22 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r2976 r2977 113 113 static CGparameter sIntensityTexDownSampleParam; 114 114 115 static unsigned int pbo[] = {0, 0};116 117 static unsigned int sCurrentPBOIdx = 0;118 115 //#define USE_3D_SSAO 119 116 … … 273 270 mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 274 271 mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 275 276 glGenBuffersARB(2, pbo);277 278 int dataSize = 1024 * 1768 * 4 * sizeof(float);279 280 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo[0]);281 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, dataSize, 0, GL_STREAM_READ_ARB);282 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo[1]);283 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, dataSize, 0, GL_STREAM_READ_ARB);284 285 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);286 272 } 287 273 … … 795 781 { 796 782 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 797 GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture();798 783 GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 799 784 GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 785 786 GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture(); 800 787 801 788 fbo->Bind(); … … 864 851 865 852 // generate mip map levels for position texture 866 glBindTexture(GL_TEXTURE_2D, positionsTex);867 glGenerateMipmapEXT(GL_TEXTURE_2D);853 //glBindTexture(GL_TEXTURE_2D, positionsTex); 854 //glGenerateMipmapEXT(GL_TEXTURE_2D); 868 855 869 856 // read the second buffer, write to the first buffer … … 1159 1146 float &middleGrey) 1160 1147 { 1161 // read pixels from framebuffer to PBO1162 /* glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo[sCurrentPBOIdx]);1163 1164 glBindTexture(GL_TEXTURE_2D, fbo->GetColorBuffer(colorBufferIdx)->GetTexture());1165 glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, NULL);1166 1167 /////////////1168 //-- map the PBO to process its data by CPU1169 1170 sCurrentPBOIdx = 1 - sCurrentPBOIdx;1171 1172 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pbo[sCurrentPBOIdx]);1173 GLfloat *ptr = (GLfloat *)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);1174 1175 if (ptr)1176 {1177 float lumScaled = ptr[4 * 2 - 1];1178 float logLum = lumScaled * LOGLUM_RANGE + MINLOGLUM;1179 imageKey = exp(logLum);1180 1181 cout << "key: " << imageKey << " " << lumScaled << endl;1182 glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB);1183 }1184 */1185 float *pixels = (float *)fbo->GetColorBuffer(colorBufferIdx)->ReadTexture();1186 1187 float lumScaled = pixels[3];//4 * 2 - 1];1188 1189 float logLum = lumScaled * LOGLUM_RANGE + MINLOGLUM;1190 imageKey = exp(logLum);1191 1192 delete [] pixels;1193 cout << "key: " << imageKey << " " << lumScaled << endl;1194 1195 // back to conventional pixel operation1196 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);1197 1198 1199 1148 // hack: estimate value where sky burns out 1200 1149 whiteLum = log(1e4f); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp
r2976 r2977 164 164 if (useMipMap) 165 165 { 166 //glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);167 166 glGenerateMipmapEXT(GL_TEXTURE_2D); 168 167 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2976 r2977 617 617 618 618 // the diffuse color buffer 619 fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_ LINEAR, ColorBufferObject::FILTER_LINEAR);619 fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 620 620 621 621 // the positions buffer … … 626 626 627 627 // another color buffer 628 fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_ LINEAR, ColorBufferObject::FILTER_LINEAR);628 fbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 629 629 630 630 PrintGLerror("fbo"); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r2976 r2977 97 97 float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 98 98 99 const static float factor = 0.2f; 100 101 OUT.color.w = lerp(oldColor.w, logLumScaled, factor); 99 if (oldColor.w > 0) 100 OUT.color.w = lerp(oldColor.w, logLumScaled, 0.2f); 101 else 102 OUT.color.w = logLumScaled; 102 103 103 104 return OUT;
Note: See TracChangeset
for help on using the changeset viewer.