Ignore:
Timestamp:
04/24/09 18:00:06 (15 years ago)
Author:
mattausch
Message:

cleaned up algorithm

File:
1 edited

Legend:

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

    r3361 r3362  
    105105                           ) 
    106106{ 
    107         float2 result = float2(0.0f, 0.0f); 
     107        //return tex2Dlod(ssaoTex, float4(texCoord, .0f, .0f)).x; 
     108        float2 result = float2(.0f); 
    108109         
    109110        const float3 centerPos = ReconstructSamplePos(colorsTex, texCoord, bl, br, tl, tr); 
    110111 
     112#if 0 
     113        //const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence + 100) / SSAO_CONVERGENCE_THRESHOLD); 
    111114        const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    112         //const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    113115         
    114         //for (int i = -radius; i <= radius; ++ i) 
    115         for (int i = -SSAO_FILTER_RADIUS; i <= SSAO_FILTER_RADIUS; ++ i) 
     116        //for (int i = -SSAO_FILTER_RADIUS; i <= SSAO_FILTER_RADIUS; ++ i) 
    116117        { 
    117118                const float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 
    118119                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 
    119120        } 
    120  
     121#else 
     122 
     123        const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence + 100) / SSAO_CONVERGENCE_THRESHOLD); 
     124 
     125        for (int i = -radius; i <= radius; ++ i) 
     126        { 
     127                const float4 sampleTexCoord = float4(texCoord + i * xyStep, .0f, .0f); 
     128                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 
     129        } 
     130 
     131#endif 
    121132        result.x /= max(result.y, 1e-6f); 
    122133        return saturate(result.x); 
     
    133144                                                uniform float3 tl, 
    134145                                                uniform float3 tr, 
    135                                                 uniform float2 res 
     146                                                uniform float2 res, 
     147                                                uniform float maxConvergence, 
     148                                                uniform float spatialWeight 
     149 
    136150                                                 ) 
    137151{ 
     
    151165 
    152166        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    153         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     167        if ((!USE_OPTIMIZATION || (convergence < SSAO_CONVERGENCE_THRESHOLD)) &&  
     168                (depth < DEPTH_THRESHOLD)) 
    154169        { 
    155170                // the filtered ssao value 
    156                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
     171                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex,  
     172                                               bl, br, tl, tr, xyStep,  
     173                                                                   convergence, maxConvergence, spatialWeight); 
    157174        } 
    158175 
     
    185202        // afterwards we do not use the filter anymore 
    186203 
    187         float2 xyStep = float2(1.0f / res.x, 0); 
     204        float2 xyStep = float2(1.0f / res.x, .0f); 
    188205 
    189206        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    190         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     207        if ((!USE_OPTIMIZATION || convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
    191208        { 
    192209                // the filtered ssao value 
    193                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
     210                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex,  
     211                                               bl, br, tl, tr, xyStep,  
     212                                                                   convergence, maxConvergence, spatialWeight); 
    194213        } 
    195214 
     
    228247 
    229248        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    230         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     249        if ((!USE_OPTIMIZATION || (convergence < SSAO_CONVERGENCE_THRESHOLD))  
     250                && (depth < DEPTH_THRESHOLD)) 
    231251        { 
    232252                // the filtered ssao value 
Note: See TracChangeset for help on using the changeset viewer.