Ignore:
Timestamp:
11/17/08 19:43:12 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3132 r3133  
    7878        float depthFactor; 
    7979        float normalFactor; 
     80        float converganceFactor; 
    8081 
    8182        for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 
     
    8990                depthFactor = max(step(5e-1f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 
    9091                normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f); 
    91  
    92                 w = filterWeights[i] * normalFactor * depthFactor; 
     92                converganceFactor = max(step(8.5f, aoSample.y), 1e-3f); 
     93 
     94                //w = filterWeights[i] * normalFactor * depthFactor * converganceFactor; 
     95                w = filterWeights[i];// * normalFactor * converganceFactor; 
    9396                //w = filterWeights[i] * depthFactor; 
    9497 
     
    107110                          uniform sampler2D ssaoTex, 
    108111                          uniform sampler2D normalsTex, 
     112                          uniform sampler2D offsetTex, 
    109113                          uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 
    110114                          uniform float filterWeights[NUM_SSAO_FILTERSAMPLES] 
     
    119123        if (col.w < 1e10f) 
    120124        { 
    121                 const float xoffs = 4.0f / 1024.0f; 
    122                 const float yoffs = 4.0f / 768.0f; 
    123 /* 
     125                const float xoffs = 20.0f / 1024.0f; 
     126                const float yoffs = 20.0f / 768.0f; 
     127 
     128                /*float3 b2 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).xyz; 
     129                float3 b3 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).xyz; 
     130                float3 b4 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).xyz; 
     131                float3 b5 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).xyz; 
     132 
     133                float border = step(0.001f,  b2 
     134 
    124135                //float3 id = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    125                 float3 x2 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).xyz; 
     136*/ 
     137                 
     138                /*float3 x2 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).xyz; 
    126139                float3 x3 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).xyz; 
    127140                float3 x4 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).xyz; 
     
    129142 
    130143                //ao.x = (ao.x + x2 + x3 + x4 + x5) * 0.2f; 
     144                if (ao.y < 1.5f) 
    131145                ao.x = (x2 + x3 + x4 + x5) * 0.25f; 
    132146 
     
    134148                const static float scaleFactor = 1.0f; 
    135149                //const static float scaleFactor = 10.0f; 
    136                 const static float adaptFactor = 50.0f; 
     150                const static float adaptFactor = 50000.0f; 
    137151 
    138152                //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 
     
    140154                //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, adaptFactor * scaleFactor * ao.z  / (adaptFactor + ao.y), 0); 
    141155                //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, adaptFactor * scaleFactor  / (adaptFactor + ao.y), 0); 
    142         } 
    143  
     156 
     157                if (ao.y < 10.5f) ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1, 0); 
     158                //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1, 0); 
     159        } 
     160 
     161        //float dummy = clamp(1.0f - ao.y * 1e-2f, 0, 1); 
     162        //float dummy2 = ao.y < 1.5f ? 1.0f : .0f; 
    144163        OUT.illum_col.xyz = col.xyz * ao.x; 
    145         //OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 
    146         //OUT.illum_col.xyz = float3(1.0f - ao.x, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 
     164 
     165//      if (ao.y < 1.5f) OUT.illum_col.xyz = float3(10000, 10000, 0); 
     166//      else if (ao.y < 3.5f) OUT.illum_col.xyz = float3(10000, 0, 10000); 
     167//      else 
     168        //      if (ao.y < 10.5f) OUT.illum_col.xyz = float3(0, 10000, 0); 
     169        //OUT.illum_col = float4(dummy3, dummy3, dummy3, col.w); 
     170        OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 
     171 
     172        //OUT.illum_col.xyz = float3(1.0f - ao.x, dummy2, 0);//dummy2); 
     173        //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 
    147174        OUT.illum_col.w = col.w; 
    148175 
    149176        return OUT; 
    150177} 
     178 
    151179 
    152180float DiscontinuityFilter2(float2 texCoord, 
     
    181209                //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 
    182210                depthFactor = max(step(5e-1f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 
    183                 normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f); 
     211                //normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f); 
    184212 
    185213                //w = filterWeights[i] * normalFactor * depthFactor; 
    186                 w = normalFactor * depthFactor; 
     214                //w = normalFactor * depthFactor; 
     215                w = depthFactor; 
    187216 
    188217                average += aoSample.y * w; 
     
    208237        //const static float scaleFactor = 20.0f; 
    209238        const static float scaleFactor = 10.0f; 
    210         ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor * ao.z, 1); 
     239        //ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 0.5f, 1); 
    211240        //ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor, 1); 
    212241         
Note: See TracChangeset for help on using the changeset viewer.