Ignore:
Timestamp:
02/18/09 08:01:56 (15 years ago)
Author:
mattausch
Message:

played around with reprojection, cleaned up code

File:
1 edited

Legend:

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

    r3316 r3318  
    4343 
    4444 
     45float ComputeConvergence(uniform sampler2D tex, float2 texCoord, float2 res) 
     46{ 
     47        // get the minimum convergence by exactly sampling the 4 surrounding 
     48        // texels in the old texture, otherwise flickering because convergence 
     49        // will be interpolated when upsampling and filter size does not match! 
     50 
     51        float4 texelCenterConv; 
     52        const float2 offs(1.0f / res.x, 1.0f / res.y); 
     53 
     54        // get position exactly between texel centers 
     55        float2 center = (floor(texCoord * res) + float2(.5f)) * offs; 
     56        //center.x = (floor(texCoord.x * res.x - .5f) + 1.0f) / res.x; 
     57        //center.y = (floor(texCoord.y * res.y - .5f) + 1.0f) / res.y; 
     58        //center.y = (floor(texCoord.y * res.y) + .5f) * yOffs; 
     59 
     60        /*texelCenterConv.x = tex2Dlod(tex, float4(center + float2( xoffs,  yoffs), 0, 0)).y; 
     61        texelCenterConv.y = tex2Dlod(tex, float4(center + float2( xoffs, -yoffs), 0, 0)).y; 
     62        texelCenterConv.z = tex2Dlod(tex, float4(center + float2(-xoffs, -yoffs), 0, 0)).y; 
     63        texelCenterConv.w = tex2Dlod(tex, float4(center + float2(-xoffs,  yoffs), 0, 0)).y; 
     64 
     65        const float m1 = min(texelCenterConv.x, texelCenterConv.y); 
     66        const float m2 = min(texelCenterConv.z, texelCenterConv.w); 
     67 
     68        const float convergence = min(m1, m2);*/ 
     69 
     70        const float convergence = tex2Dlod(tex, float4(center, 0, 0)).y; 
     71 
     72        return convergence; 
     73} 
    4574 
    4675/** This shader computes the reprojection and stores  
     
    107136        { 
    108137                // pixel valid => retrieve the convergence weight 
    109                 float w1 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 
     138                /*float w1 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 
    110139                float w2 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 
    111140                float w3 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0, 0.5f / 768.0f), .0f, .0f)).y; 
    112141                float w4 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0, 0.5f / 768.0f), .0f, .0f)).y; 
    113142 
    114                 w = min(min(w1, w2), min(w3, w4)); 
     143                w = min(min(w1, w2), min(w3, w4));*/ 
     144                 
     145                w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 
    115146                //w = oldPixel.y; 
    116147        } 
Note: See TracChangeset for help on using the changeset viewer.