Ignore:
Timestamp:
02/18/09 18:34:49 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg

    r3318 r3319  
    5959                                        float3 tl, 
    6060                                        float3 tr, 
    61                                         float maxConvergence) 
     61                                        float maxConvergence, 
     62                                        float spatialWeight) 
    6263{ 
    6364        float2 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 
     
    7172        //float len = min(SqrLen(centerPos - samplePos), 1e2f); 
    7273        float len = distance(centerPos, samplePos); 
    73         float spatialFactor = 1.0f / max(len, 1e-3f); 
     74        //float spatialFactor = 1.0f / max(len, 1e-3f); 
     75        float spatialFactor = 1.0f / max(spatialWeight + len, 1e-3f); 
    7476 
    7577        float convergenceFactor = min(aoSample.y + 1.0f, maxConvergence); 
    76         convergenceFactor *= convergenceFactor; 
     78        //convergenceFactor *= convergenceFactor; 
    7779 
    7880        // combine the weights 
     81        //float w = convergenceFactor * exp(1.0f + spatialFactor); 
    7982        float w = convergenceFactor * spatialFactor; 
    8083        //float w = spatialFactor; 
     
    98101                           float2 xyStep, 
    99102                           float convergence, 
    100                            float maxConvergence 
     103                           float maxConvergence, 
     104                           float spatialWeight 
    101105                           ) 
    102106{ 
     
    105109        const float3 centerPos = ReconstructSamplePos(colorsTex, texCoord, bl, br, tl, tr); 
    106110 
    107         const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
     111        const float scale = 1.0f;//saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    108112        //const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    109113         
     
    112116        { 
    113117                float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 
    114                 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence); 
     118                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 
    115119        } 
    116120 
     
    151155        { 
    152156                // the filtered ssao value 
    153                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
     157                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
    154158        } 
    155159 
     
    167171                                                uniform float3 tr, 
    168172                                                uniform float2 res, 
    169                                                 uniform float maxConvergence 
     173                                                uniform float maxConvergence, 
     174                                                uniform float spatialWeight 
    170175                                                ) 
    171176{ 
     
    187192        { 
    188193                // the filtered ssao value 
    189                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
     194                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
    190195        } 
    191196 
     
    205210                                  uniform float3 tr, 
    206211                                  uniform float2 res, 
    207                                   uniform float maxConvergence 
     212                                  uniform float maxConvergence, 
     213                                  uniform float spatialWeight 
    208214                                  ) 
    209215{ 
     
    226232        { 
    227233                // the filtered ssao value 
    228                 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
    229         } 
     234                ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
     235        } 
     236 
     237        //const float minAO = 2e-2f; 
     238        const float minAO = 1e-3f; 
    230239 
    231240        // just apply ssao if we are not in the sky 
    232241        if (depth < DEPTH_THRESHOLD) 
    233242        { 
    234                 //OUT.illum_col.xyz = col.xyz * max(1e-3f, 1.0f - ao.x); 
    235                 OUT.illum_col.xyz = max(1e-3f, 1.0f - ao.x); 
     243                OUT.illum_col.xyz = col.xyz * max(minAO, 1.0f - ao.x); 
     244                //OUT.illum_col.xyz = max(minAO, 1.0f - ao.x); 
    236245        } 
    237246        else 
Note: See TracChangeset for help on using the changeset viewer.