Ignore:
Timestamp:
02/10/09 17:43:43 (15 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3285 r3296  
    115115        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    116116 
    117 #if 0 // for half resolution 
    118  
    119117        // the following has to be done for half resolution ssao: 
    120118        // get the minimum convergence by exactly sampling the 4 surrounding 
     
    141139        const float convergence = minConvergence; 
    142140 
    143 #else 
    144          
    145         // just take unfiltered convergence in current pixel 
    146         const float convergence = ao.y; 
    147  
    148 #endif 
    149141         
    150142        // filter reaches size 1 pixel when sample size reaches threshold  
     
    188180        return OUT; 
    189181} 
     182 
     183 
     184/** Function combining image and indirect illumination buffer using a  
     185        depth and normal aware discontinuity filter. We assume that  
     186        we are using half resolution ssao for this version of the combineSsao 
     187*/ 
     188pixel CombineSsaoFullRes(fragment IN,  
     189                                                 uniform sampler2D colorsTex, 
     190                                                 uniform sampler2D ssaoTex, 
     191                                                 uniform sampler2D normalsTex, 
     192                                                 uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 
     193                                                 uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 
     194                                                 uniform float ssaoFilterRadius, 
     195                                                 uniform float4x4 modelViewProj, 
     196                                                 uniform float3 bl, 
     197                                                 uniform float3 br, 
     198                                                 uniform float3 tl, 
     199                                                 uniform float3 tr, 
     200                                                 uniform float w, 
     201                                                 uniform float h 
     202                                                 ) 
     203{ 
     204        pixel OUT; 
     205 
     206        float4 col = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 
     207        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
     208 
     209        // just take unfiltered convergence in current pixel 
     210        const float convergence = ao.y; 
     211         
     212        // filter reaches size 1 pixel when sample size reaches threshold  
     213        // afterwards we do not use the filter anymore 
     214 
     215        // filter up to a certain convergance value and leave out background (sky) by checking depth 
     216        if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (col.w < 1e10f)) 
     217        { 
     218                const float distanceScale = 1.0f; 
     219 
     220                // descend to zero filter size after reaching thres pixels 
     221                const float convergenceWeight = SSAO_CONVERGENCE_THRESHOLD / (ssaoFilterRadius - 1.0f); 
     222                const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 
     223                const float scale = ssaoFilterRadius * convergenceScale * distanceScale; 
     224 
     225                // the filtered ssao value 
     226                ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 
     227        } 
     228 
     229        // just apply ssao if we are not in the sky 
     230        if (col.w < 1e10f) 
     231                OUT.illum_col.xyz = col.xyz * max(2e-2f, 1.0f - ao.x); 
     232                //OUT.illum_col.xyz = col.xyz * ao.x; 
     233        else 
     234                OUT.illum_col.xyz = col.xyz; 
     235 
     236        OUT.illum_col.w = col.w; 
     237 
     238        return OUT; 
     239} 
Note: See TracChangeset for help on using the changeset viewer.