Changeset 2977


Ignore:
Timestamp:
09/26/08 18:41:22 (16 years ago)
Author:
mattausch
Message:

tonemapping working but suddenly slow!

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  
    113113static CGparameter sIntensityTexDownSampleParam; 
    114114 
    115 static unsigned int pbo[] = {0, 0}; 
    116  
    117 static unsigned int sCurrentPBOIdx = 0; 
    118115//#define USE_3D_SSAO 
    119116 
     
    273270        mFbo->AddColorBuffer(ColorBufferObject::BUFFER_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    274271        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); 
    286272} 
    287273 
     
    795781{ 
    796782        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    797         GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture(); 
    798783        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    799784        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     785 
     786        GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture(); 
    800787 
    801788        fbo->Bind(); 
     
    864851 
    865852        // 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); 
    868855 
    869856        // read the second buffer, write to the first buffer 
     
    11591146                                                                                         float &middleGrey) 
    11601147{ 
    1161         // read pixels from framebuffer to PBO 
    1162 /*      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 CPU 
    1169  
    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 operation 
    1196         glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); 
    1197  
    1198  
    11991148        // hack: estimate value where sky burns out 
    12001149        whiteLum = log(1e4f); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r2976 r2977  
    164164        if (useMipMap)  
    165165        { 
    166                 //glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE); 
    167166                glGenerateMipmapEXT(GL_TEXTURE_2D); 
    168167        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2976 r2977  
    617617 
    618618        // 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); 
    620620 
    621621        // the positions buffer 
     
    626626 
    627627        // 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); 
    629629 
    630630        PrintGLerror("fbo"); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2976 r2977  
    9797        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
    9898 
    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; 
    102103 
    103104        return OUT; 
Note: See TracChangeset for help on using the changeset viewer.