Changeset 2970


Ignore:
Timestamp:
09/24/08 14:59:35 (16 years ago)
Author:
mattausch
Message:

tone mapper working better

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r2968 r2970  
    9898static CGparameter sLightDirShadowParam; 
    9999static CGparameter sImageKeyParam; 
     100static CGparameter sMiddleGreyParam; 
    100101static CGparameter sWhiteLumParam; 
    101102 
     
    408409 
    409410                sImageKeyParam = cgGetNamedParameter(sCgAntiAliasingProgram, "imageKey"); 
     411                sMiddleGreyParam = cgGetNamedParameter(sCgAntiAliasingProgram, "middleGrey"); 
    410412                sWhiteLumParam = cgGetNamedParameter(sCgAntiAliasingProgram, "whiteLum"); 
    411413 
     
    513515        } 
    514516 
    515         AntiAliasing(fbo); 
     517        AntiAliasing(fbo, light); 
    516518 
    517519        glEnable(GL_LIGHTING); 
     
    668670 
    669671 
    670 void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo) 
     672void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light) 
    671673{ 
    672674        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     
    679681 
    680682        const float imageKey = ToneMapper().CalcImageKey(pixels, w, h); 
    681         const float whiteLum = 0.5f * ToneMapper().CalcMaxLuminance(pixels, w, h); 
    682  
     683        const float whiteLum = 1.0f * ToneMapper().CalcMaxLuminance(pixels, w, h); 
     684 
     685        //const float minKey = 0.18f; 
     686        //const float maxKey = 0.72f; 
     687 
     688        //const float minKey = 0.0045f; 
     689        const float minKey = 0.09f; 
     690        const float maxKey = 0.5f; 
     691 
     692        const float lightIntensity = DotProd(-light->GetDirection(), Vector3::UNIT_Z()); 
     693        const float middleGrey = lightIntensity * maxKey + (1.0f - lightIntensity) * minKey; 
     694 
     695        cout << "middlegrey: " << middleGrey << endl; 
    683696        delete [] pixels; 
    684697 
     
    699712        cgGLSetParameter1f(sImageKeyParam, imageKey); 
    700713        cgGLSetParameter1f(sWhiteLumParam, whiteLum); 
     714        cgGLSetParameter1f(sMiddleGreyParam, middleGrey); 
    701715 
    702716 
     
    889903        GLuint colorsTex = fbo->GetColorBuffer(3)->GetTexture(); 
    890904 
    891         //GLuint ssaoTex = mNewFbo->GetColorBuffer(0)->GetTexture(); 
    892         //GLuint illumTex = mNewFbo->GetColorBuffer(1)->GetTexture(); 
    893905        GLuint ssaoTex = mFbo->GetColorBuffer(mFboIndex)->GetTexture(); 
    894906        GLuint illumTex = mFbo->GetColorBuffer(mFboIndex + 1)->GetTexture(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r2965 r2970  
    7878        void CombineIllum(FrameBufferObject *fbo); 
    7979 
    80         void AntiAliasing(FrameBufferObject *fbo); 
     80        void AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light); 
    8181        /** Helper method that computes the view vectors in the corners of the current view frustum. 
    8282        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp

    r2968 r2970  
    284284        // downscale ambient color 
    285285        //ambient *= 5e-5f; 
    286         //ambient *= 2e-3f; 
     286        ambient *= 1e-1f; 
    287287 
    288288        // simulate the sun intensity by modulating the ambient term. 
    289         //ambient *= (1.0f - 0.9f * DotProd(sunDir, Vector3::UNIT_Z())); 
     289        ambient *= (10.0f - 9.0f * DotProd(sunDir, Vector3::UNIT_Z())); 
    290290        //ambient += Vector3(0.2f); 
    291291 
     
    321321 
    322322        // Calculate final sun diffuse color. 
    323         //diffuse = color * 2e-3f; 
    324         diffuse = color; 
     323        diffuse = color * 3e-1f; 
     324        //diffuse *= (3.0f - 2.0f * DotProd(sunDir, Vector3::UNIT_Z())); 
     325        //diffuse = color; 
     326         
    325327 
    326328        //cout << "diffuse: " << Magnitude(diffuse) << " ambient: " << Magnitude(ambient) << endl; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ToneMapper.cpp

    r2968 r2970  
    3636 
    3737        static float previousKey = key; 
    38         const float factor = 1.0f; 
     38        const float factor = 0.5f; 
    3939 
    40         const float imageKey = key;// * factor + previousKey * (1.0f - factor); 
     40        float imageKey; 
     41 
     42        if (key > 0) 
     43                imageKey = key * factor + previousKey * (1.0f - factor); 
     44        else  
     45                imageKey = previousKey; 
     46 
    4147        previousKey = imageKey; 
    4248         
    43         cout << "key: " << key << endl; 
     49        //cout << "key: " << key << endl; 
    4450 
    4551        return imageKey; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2968 r2970  
    3333 
    3434///////// 
    35 //-- tone mapping 
    36  
    37 //#define MIDDLE_GRAY 0.5f 
    38 //#define MIDDLE_GRAY 0.72f 
    39 #define MIDDLE_GRAY 0.36f 
    40 //#define MIDDLE_GRAY 0.18f 
    41 //#define MIDDLE_GRAY 0.18f 
    42  
    43  
    44 ///////// 
    4535//-- shadowing 
    4636 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r2969 r2970  
    2121 
    2222 
    23 float3 ToneMap(float imageKey, float whiteLum, float3 color) 
     23float3 ToneMap(float imageKey, float whiteLum, float middleGrey, float3 color) 
    2424{ 
    2525        float3 outCol; 
     
    2727         
    2828        // adjust to middle gray 
    29         const float lum = MIDDLE_GRAY * pixLum / imageKey; 
     29        const float lum = middleGrey * pixLum / imageKey; 
    3030          
    3131        // map to range and calc burnout 
     
    5151                        uniform sampler2D normals, 
    5252                        uniform float imageKey, 
    53                         uniform float whiteLum 
     53                        uniform float whiteLum, 
     54                        uniform float middleGrey 
    5455                        ): COLOR 
    5556{ 
     
    121122 
    122123        //return float4(w); 
    123         col.xyz = ToneMap(imageKey, whiteLum, col.xyz); 
     124        col.xyz = ToneMap(imageKey, whiteLum, middleGrey, col.xyz); 
    124125 
    125126        return col; 
Note: See TracChangeset for help on using the changeset viewer.