Changeset 3003


Ignore:
Timestamp:
10/03/08 18:42:33 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r2994 r3003  
    2525tempCohFactor=50.0f 
    2626 
    27 useHDR=1 
     27useHDR=0 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3002 r3003  
    1010#include "Light.h" 
    1111 
     12#include <IL/il.h> 
     13#include <assert.h> 
     14 
    1215 
    1316using namespace std; 
    1417 
     18 
     19static void startil() 
     20{ 
     21        ilInit(); 
     22        assert(ilGetError() == IL_NO_ERROR); 
     23} 
     24 
     25 
     26static void stopil() 
     27{ 
     28        ilShutDown(); 
     29        assert(ilGetError() == IL_NO_ERROR); 
     30} 
    1531 
    1632namespace CHCDemoEngine 
     
    279295 
    280296        mDownSampleFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE); 
     297        //mDownSampleFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    281298        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    282299        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     
    902919        cgGLSetMatrixParameterfc(sOldModelViewProjMatrixGiParam, (const float *)oldProjViewMatrix.x); 
    903920 
    904         GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     921//      GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     922        GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
    905923        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    906924        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     
    12671285 
    12681286 
     1287static void ExportData(float *data, int w, int h) 
     1288{ 
     1289        startil(); 
     1290 
     1291        cout << "w: " << w << " h: " << h << endl; 
     1292        ILstring filename = ILstring("downsample2.jpg"); 
     1293        ilRegisterType(IL_FLOAT); 
     1294 
     1295        const int depth = 1; 
     1296        const int bpp = 4; 
     1297 
     1298        if (!ilTexImage(w, h, depth, bpp, IL_RGBA, IL_FLOAT, data)) 
     1299        { 
     1300                cerr << "IL error " << ilGetError() << endl; 
     1301                stopil(); 
     1302                return; 
     1303        } 
     1304 
     1305        if (!ilSaveImage(filename)) 
     1306        { 
     1307                cerr << "TGA write error " << ilGetError() << endl; 
     1308        } 
     1309 
     1310        stopil(); 
     1311 
     1312        // cout << "exported buffer" << endl; 
     1313} 
     1314 
     1315 
    12691316void DeferredRenderer::DownSample(FrameBufferObject *fbo) 
    12701317{ 
    1271         glPushAttrib(GL_VIEWPORT_BIT); 
    1272         glViewport(0, 0, mWidth, mHeight); 
     1318        //glPushAttrib(GL_VIEWPORT_BIT); 
     1319        glViewport(0, 0, mWidth / 2, mHeight / 2); 
     1320         
     1321        glMatrixMode(GL_PROJECTION); 
     1322        glPushMatrix(); 
     1323        glLoadIdentity(); 
     1324 
     1325        const float offs2 = 0.5f; 
     1326        glOrtho(-offs2, offs2, -offs2, offs2, 0, 1); 
     1327 
     1328        glMatrixMode(GL_MODELVIEW); 
     1329        glPushMatrix(); 
     1330        glLoadIdentity(); 
     1331 
    12731332 
    12741333        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     
    13051364        FrameBufferObject::Release(); 
    13061365 
    1307         glPopAttrib(); 
     1366        //glPopAttrib(); 
     1367        glViewport(0, 0, mWidth, mHeight); 
    13081368        PrintGLerror("downsample"); 
     1369 
     1370        float *data = (float *)mDownSampleFbo->GetColorBuffer(0)->ReadTexture(); 
     1371        //float *data = (float *)mFbo->GetColorBuffer(colorBufferIdx)->ReadTexture(); 
     1372        ExportData(data, mWidth / 2, mHeight / 2); 
     1373        //ExportData(data, mWidth, mHeight); 
     1374 
     1375        glMatrixMode(GL_PROJECTION); 
     1376        glPopMatrix(); 
     1377        glMatrixMode(GL_MODELVIEW); 
     1378        glPopMatrix(); 
     1379 
     1380        delete [] data; 
     1381         
     1382        PrintGLerror("shadow map"); 
    13091383} 
    13101384 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3001 r3003  
    175175        float w = norm.w; 
    176176        // the current world position 
    177         const float4 centerPosition = tex2D(positions, IN.texCoord.xy); 
     177        const float4 centerPosition2 = tex2D(positions, IN.texCoord.xy); 
    178178 
    179179        /// reconstruct position from the eye space depth 
    180         /*float3 viewDir = normalize(IN.view); 
     180        float3 viewDir = normalize(IN.view); 
    181181        const float eyeDepth = tex2D(colors, IN.texCoord.xy).w; 
    182182         
     
    185185 
    186186        centerPosition.w = centerPosition2.w; 
    187 */ 
     187 
    188188        // the current color 
    189189        const float4 currentCol = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 0)); 
     
    191191        const float currentDepth = centerPosition.w; 
    192192 
    193         GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition, w, eyePos, bl, br, tl, tr); 
     193        GiStruct gi = globIllum(IN, colors, noiseTexture, samples, normal, centerPosition2, w, eyePos, bl, br, tl, tr); 
    194194         
    195195 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r3002 r3003  
    3333    average *= 1.0f / 4.0f; 
    3434 
    35     return average; 
     35    return tex2D(colors, IN.texCoord);//average; 
    3636} 
    3737     
Note: See TracChangeset for help on using the changeset viewer.