Ignore:
Timestamp:
11/29/08 18:24:53 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3193 r3195  
    6868                normalFactor = max(dot(sampleNorm, centerNormal), 1e-3f); 
    6969                //convergenceFactor = min(100.0f, aoSample.y); 
    70                 convergenceFactor = aoSample.y; 
     70                convergenceFactor = aoSample.y + 1.0f; 
    7171 
    7272                // combine the weights 
     
    133133                //samplePos = ReconstructSamplePos(ssaoTex, sampleTexCoord.xy, bl, br, tl, tr); 
    134134 
    135                 len = min(SqrLen(centerPos - samplePos), 1e3f); 
     135                len = min(SqrLen(centerPos - samplePos), 1e2f); 
    136136 
    137137                spatialFactor = 1.0f / max(len, 1e-3f); 
    138138 
    139                 normalFactor = max(step(.01f, dot(sampleNorm, centerNormal)), 1e-3f); 
     139                //normalFactor = max(step(.0f, dot(sampleNorm, centerNormal)), 1e-2f); 
    140140                //normalFactor = max(dot(sampleNorm, samplePos), 1e-3f); 
    141                 convergenceFactor = min(convergenceThresh, aoSample.y + 1); 
     141                convergenceFactor = aoSample.y + 1.0f; 
     142                //convergenceFactor = max(step(0.5f + NUM_SAMPLES, aoSample.y), 1e-2f); 
    142143                //convergenceFactor = aoSample.y; 
    143144 
    144145                // combine the weights 
    145                 w = convergenceFactor * spatialFactor * normalFactor; 
     146                w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; 
    146147                //w = spatialFactor * normalFactor; 
    147148 
     
    177178        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    178179 
     180        float4 dummy; 
     181        const float xoffs = .5f / 1024.0f; 
     182        const float yoffs = .5f / 768.0f; 
     183 
     184        dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y; 
     185        dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y; 
     186        dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y; 
     187        dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y; 
     188 
     189        const float convergence = min(min(dummy.x, dummy.y), min(dummy.z, dummy.w)); 
     190        //const float convergence = max(max(dummy.x, dummy.y), max(dummy.z, dummy.w)); 
     191        //const float convergence = ao.y; 
     192 
     193        // filter reaches size 1 after thres samples 
     194        const float thres = 500.0f;  
     195 
    179196        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    180         if ((ao.y < 500.0f) && (col.w < 1e10f)) 
     197        if ((convergence < thres) && (col.w < 1e10f)) 
    181198        //if (col.w < 1e10f) 
    182199        { 
     
    185202                const float distanceScale = 1.0f; 
    186203 
    187                 const float convergence = ao.y + 1; 
    188                 const float convergenceScale = SSAO_CONVERGENCE_WEIGHT / (convergence + SSAO_CONVERGENCE_WEIGHT); 
    189  
    190                 const float scale = NUM_SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 
     204                const float convergenceWeight = thres / (SSAO_FILTER_WIDTH - 1.0f); 
     205                const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 
     206 
     207                const float scale = SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 
    191208 
    192209                // the filtered ssao value 
     
    199216                OUT.illum_col.xyz = col.xyz; 
    200217 
    201         //OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x); 
    202         //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 
     218        OUT.illum_col.xyz = float3(ao.x, ao.x, ao.x); 
     219        //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1); 
     220        //OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1); 
    203221        OUT.illum_col.w = col.w; 
    204222 
Note: See TracChangeset for help on using the changeset viewer.