Ignore:
Timestamp:
09/23/08 15:41:14 (16 years ago)
Author:
mattausch
Message:

started reinhard tonemapping implementation but slow

File:
1 edited

Legend:

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

    r2965 r2966  
    99#include "ShadowMapping.h" 
    1010#include "Light.h" 
     11#include "ToneMapper.h" 
    1112 
    1213 
     
    9697static CGparameter sLightDirShadowParam; 
    9798 
     99static CGparameter sImageKeyParam; 
     100static CGparameter sImageKeyShadowParam; 
    98101 
    99102//#define USE_3D_SSAO 
     
    108111static Sample2 samples2[NUM_SAMPLES]; 
    109112#endif 
    110 Sample2 pcfSamples[16]; 
     113 
     114// number of pcf tabs 
     115Sample2 pcfSamples[NUM_PCF_TABS]; 
    111116 
    112117static int colorBufferIdx = 0; 
     
    281286                sNormalsTexDeferredParam = cgGetNamedParameter(sCgDeferredProgram, "normals"); 
    282287                sLightDirParam = cgGetNamedParameter(sCgDeferredProgram, "lightDir"); 
     288 
     289                sImageKeyParam = cgGetNamedParameter(sCgDeferredProgram, "imageKey"); 
    283290        } 
    284291        else 
     
    433440                sLightDirShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "lightDir"); 
    434441 
    435                 PoissonDiscSampleGenerator2 poisson(16, 1.0f); 
     442                sImageKeyShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "imageKey"); 
     443 
     444                PoissonDiscSampleGenerator2 poisson(NUM_PCF_TABS, 1.0f); 
    436445                poisson.Generate((float *)pcfSamples); 
    437446 
    438                 cgGLSetParameterArray2f(sSamplesShadowParam, 0, 16, (const float *)pcfSamples); 
     447                cgGLSetParameterArray2f(sSamplesShadowParam, 0, NUM_PCF_TABS, (const float *)pcfSamples); 
    439448        } 
    440449        else 
     
    699708void DeferredRenderer::FirstPass(FrameBufferObject *fbo, DirectionalLight *light) 
    700709{ 
     710        const float imageKey = ToneMapper().CalcImageKey(fbo->GetColorBuffer(0)); 
     711 
    701712        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
    702713        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     
    725736        Vector3 lightDir = -light->GetDirection(); 
    726737        cgGLSetParameter3f(sLightDirParam, lightDir.x, lightDir.y, lightDir.z); 
     738 
     739        cgGLSetParameter1f(sImageKeyParam, imageKey); 
    727740 
    728741        glColor3f(1.0f, 1.0f, 1.0f); 
     
    965978                                                                           ShadowMap *shadowMap) 
    966979{ 
     980        const float imageKey = ToneMapper().CalcImageKey(fbo->GetColorBuffer(0)); 
     981 
    967982        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
    968983 
     
    10091024        cgGLSetParameter3f(sLightDirShadowParam, lightDir.x, lightDir.y, lightDir.z); 
    10101025 
     1026        // the average log luminance for tone mapping 
     1027        cgGLSetParameter1f(sImageKeyShadowParam, imageKey); 
    10111028 
    10121029        glColor3f(1.0f, 1.0f, 1.0f); 
Note: See TracChangeset for help on using the changeset viewer.