Changeset 2978


Ignore:
Timestamp:
09/26/08 22:36:20 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
5 edited

Legend:

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

    r2977 r2978  
    2929static CGparameter sColorsTexDeferredParam; 
    3030static CGparameter sOldColorsTexDeferredParam; 
     31static CGparameter sOldColorsTexShadowParam; 
    3132 
    3233static CGparameter sPositionsTexDeferredParam; 
     
    468469                sLightDirShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "lightDir"); 
    469470 
     471                sOldColorsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "oldColors"); 
     472 
    470473 
    471474                PoissonDiscSampleGenerator2 poisson(NUM_PCF_TABS, 1.0f); 
     
    10561059        GLuint shadowTex = shadowMap->GetDepthTexture(); 
    10571060 
     1061        GLuint oldColorsTex = fbo->GetColorBuffer(3 - colorBufferIdx)->GetTexture(); 
     1062 
    10581063        Matrix4x4 shadowMatrix; 
    10591064        shadowMap->GetTextureMatrix(shadowMatrix); 
     
    10781083        cgGLSetTextureParameter(sShadowMapParam, shadowTex); 
    10791084        cgGLEnableTextureParameter(sShadowMapParam); 
     1085 
     1086        cgGLSetTextureParameter(sOldColorsTexShadowParam, oldColorsTex); 
     1087        cgGLEnableTextureParameter(sOldColorsTexShadowParam); 
    10801088 
    10811089        cgGLSetParameter1f(sMaxDepthShadowParam, mScaleFactor); 
     
    11111119        cgGLDisableTextureParameter(sNormalsTexShadowParam); 
    11121120        cgGLDisableTextureParameter(sShadowMapParam); 
     1121 
     1122        cgGLDisableTextureParameter(sOldColorsTexShadowParam); 
    11131123 
    11141124        cgGLDisableTextureParameter(sNoiseTexShadowParam); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2977 r2978  
    924924        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
    925925        cgGLBindProgram(RenderState::sCgMrtFragmentProgram); 
     926 
     927        // draw to 3 color buffers 
     928        // a color, normal, and positions buffer 
     929        if (sCurrentMrtSet == 0) 
     930        { 
     931                DeferredRenderer::colorBufferIdx = 0; 
     932                glDrawBuffers(3, mrt); 
     933        } 
     934        else  
     935        { 
     936                DeferredRenderer::colorBufferIdx = 3; 
     937                glDrawBuffers(3, mrt2); 
     938        } 
     939        sCurrentMrtSet = 1 - sCurrentMrtSet; 
    926940} 
    927941 
     
    10511065                InitDeferredRendering(); 
    10521066                 
    1053                 // draw to 3 color buffers 
    1054                 // a color, normal, and positions buffer 
    1055                 if (sCurrentMrtSet == 0) 
    1056                 { 
    1057                         DeferredRenderer::colorBufferIdx = 0; 
    1058                         glDrawBuffers(3, mrt); 
    1059                 } 
    1060                 else  
    1061                 { 
    1062                         DeferredRenderer::colorBufferIdx = 3; 
    1063                         glDrawBuffers(3, mrt2); 
    1064                 } 
    1065                 sCurrentMrtSet = 1 - sCurrentMrtSet; 
    1066  
    10671067                glEnableClientState(GL_NORMAL_ARRAY); 
    10681068 
     
    20242024                InitDeferredRendering(); 
    20252025 
    2026                 // draw to 3 color buffers 
    2027                 glDrawBuffers(3, mrt); 
    20282026                glClear(GL_COLOR_BUFFER_BIT); 
    20292027        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r2975 r2978  
    4747#define LOGLUM_RANGE 20.0f 
    4848 
     49#define MAX_LOD_LEVEL 99 
     50 
    4951#endif // __SHADERENV_H 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2977 r2978  
    8787        //-- write out logaritmic luminance for tone mapping 
    8888 
    89         float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, 99)); 
     89        float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 
    9090 
    9191        const float3 w = float3(0.299f, 0.587f, 0.114f); 
     
    157157                                  uniform sampler2D noiseTexture, 
    158158                                  uniform float2 samples[NUM_PCF_TABS], 
    159                                   uniform float3 lightDir 
     159                                  uniform float3 lightDir, 
     160                                  uniform sampler2D oldColors 
    160161                                  ) 
    161162{ 
     
    201202        OUT.color = (emmisive > 1.5f) ? color: (ambient + diffuse) * color; 
    202203 
     204 
    203205        //////////// 
    204206        //-- write out logaritmic luminance for tone mapping 
    205207 
     208        float4 oldColor = tex2Dlod(colors, float4(IN.texCoord.xy, 0, MAX_LOD_LEVEL)); 
     209 
    206210        const float3 w = float3(0.299f, 0.587f, 0.114f); 
    207211 
     
    212216        float logLumScaled = logLum * INV_LOGLUM_RANGE - logLumOffset; 
    213217 
    214         OUT.color.w = logLumScaled; 
     218        if (oldColor.w > 0) 
     219                OUT.color.w = lerp(oldColor.w, logLumScaled, 0.2f); 
     220        else 
     221                OUT.color.w = logLumScaled; 
    215222         
    216223        return OUT; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r2975 r2978  
    5252        float numSamples = 0; 
    5353 
     54        // avoid singularity of  
     55        centerPosition.xyz += currentNormal * 1e-4f; 
     56 
    5457        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    5558        { 
     
    8285                const float cos_angle = max(dot(direction_to_sample, currentNormal), 0.0f); 
    8386 
    84                 // distance between current position and sample position controls AO intensity. 
    8587                const float distance_intensity =  
    8688                        (SAMPLE_INTENSITY * DISTANCE_SCALE) / (DISTANCE_SCALE + length_to_sample * length_to_sample); 
Note: See TracChangeset for help on using the changeset viewer.