Ignore:
Timestamp:
02/12/09 14:38:14 (15 years ago)
Author:
mattausch
Message:

removed filter radius

File:
1 edited

Legend:

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

    r3304 r3305  
    1919        float4 illum_col: COLOR0; 
    2020}; 
     21 
     22 
     23float ComputeConvergenceHalfRes(uniform sampler2D ssaoTex, 
     24                                                                float2 texCoord,  
     25                                                                float2 halfres) 
     26{ 
     27    // the following has to be done for half resolution ssao: 
     28        // get the minimum convergence by exactly sampling the 4 surrounding 
     29        // texels in the old texture, otherwise flickering because convergence 
     30        // will be interpolated when upsampling and filter size does not match! 
     31 
     32        float4 texelCenterConv; 
     33        const float xoffs = .5f / halfres.x; const float yoffs = .5f / halfres.y; 
     34 
     35        // get position exactly between old texel centers 
     36        float2 center; 
     37        center.x = (floor(texCoord.x * halfres.x - .5f) + 1.0f) / halfres.x; 
     38        center.y = (floor(texCoord.y * halfres.y - .5f) + 1.0f) / halfres.y; 
     39 
     40        texelCenterConv.x = tex2Dlod(ssaoTex, float4(center + float2( xoffs,  yoffs), 0, 0)).y; 
     41        texelCenterConv.y = tex2Dlod(ssaoTex, float4(center + float2( xoffs, -yoffs), 0, 0)).y; 
     42        texelCenterConv.z = tex2Dlod(ssaoTex, float4(center + float2(-xoffs, -yoffs), 0, 0)).y; 
     43        texelCenterConv.w = tex2Dlod(ssaoTex, float4(center + float2(-xoffs,  yoffs), 0, 0)).y; 
     44 
     45        const float m1 = min(texelCenterConv.x, texelCenterConv.y); 
     46        const float m2 = min(texelCenterConv.z, texelCenterConv.w); 
     47 
     48        const float minConvergence = min(m1, m2); 
     49        return minConvergence; 
     50} 
    2151 
    2252 
     
    4575        // combine the weights 
    4676        float w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; 
    47  
    4877        float average = aoSample.x * w; 
    4978 
     
    94123                                                uniform float3 tl, 
    95124                                                uniform float3 tr, 
    96                                                 uniform float2 xyStep 
    97                                                  ) 
     125                                                uniform float2 res 
     126                                                ) 
    98127{ 
    99128        pixel OUT; 
     
    108137        // afterwards we do not use the filter anymore 
    109138 
     139        float2 xyStep = float2(1.0f / res.x, 0); 
     140 
    110141        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    111142        if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     
    118149} 
    119150 
     151/** In between step that only filters in one direction 
     152*/ 
     153pixel FilterSsaoHalfRes(fragment IN,  
     154                                                uniform sampler2D colorsTex, 
     155                                                uniform sampler2D ssaoTex, 
     156                                                uniform float3 bl, 
     157                                                uniform float3 br, 
     158                                                uniform float3 tl, 
     159                                                uniform float3 tr, 
     160                                                uniform float2 res 
     161                                                 ) 
     162{ 
     163        pixel OUT; 
     164 
     165        const float depth = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)).w; 
     166 
     167        OUT.illum_col = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
     168        // just take unfiltered convergence in current pixel 
     169        const float convergence = ComputeConvergenceHalfRes(ssaoTex, IN.texCoord, res * 0.5f); 
     170 
     171        const float2 xyStep = float2(1.0f / res.x, 0); 
     172 
     173        // filter reaches size 1 pixel when sample size reaches threshold  
     174        // afterwards we do not use the filter anymore 
     175 
     176        // filter up to a certain convergance value and leave out background (sky) by checking depth 
     177        if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     178        { 
     179                // the filtered ssao value 
     180                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 
     181        } 
     182 
     183        return OUT; 
     184} 
    120185 
    121186/** Function combining image and indirect illumination buffer using a  
    122187    depth and convergence aware discontinuity filter. 
    123188*/ 
    124 pixel CombineSsaoFullRes(fragment IN,  
    125                                                 uniform sampler2D colorsTex, 
    126                                                 uniform sampler2D ssaoTex, 
    127                                                 uniform float3 bl, 
    128                                                 uniform float3 br, 
    129                                                 uniform float3 tl, 
    130                                                 uniform float3 tr, 
    131                                                  uniform float2 xyStep 
    132                                                 ) 
     189pixel CombineSsao(fragment IN,  
     190                                  uniform sampler2D colorsTex, 
     191                                  uniform sampler2D ssaoTex, 
     192                                  uniform float3 bl, 
     193                                  uniform float3 br, 
     194                                  uniform float3 tl, 
     195                                  uniform float3 tr, 
     196                                  uniform float2 res 
     197                                  ) 
    133198{ 
    134199        pixel OUT; 
     
    141206        const float convergence = ao.y; 
    142207 
     208        const float2 xyStep = float2(0, 1.0f / res.y); 
     209         
    143210        // filter reaches size 1 pixel when sample size reaches threshold  
    144211        // afterwards we do not use the filter anymore 
Note: See TracChangeset for help on using the changeset viewer.