- Timestamp:
- 02/12/09 14:38:14 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
r3304 r3305 19 19 float4 illum_col: COLOR0; 20 20 }; 21 22 23 float 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 } 21 51 22 52 … … 45 75 // combine the weights 46 76 float w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; 47 48 77 float average = aoSample.x * w; 49 78 … … 94 123 uniform float3 tl, 95 124 uniform float3 tr, 96 uniform float2 xyStep97 125 uniform float2 res 126 ) 98 127 { 99 128 pixel OUT; … … 108 137 // afterwards we do not use the filter anymore 109 138 139 float2 xyStep = float2(1.0f / res.x, 0); 140 110 141 // filter up to a certain convergance value and leave out background (sky) by checking depth 111 142 if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) … … 118 149 } 119 150 151 /** In between step that only filters in one direction 152 */ 153 pixel 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 } 120 185 121 186 /** Function combining image and indirect illumination buffer using a 122 187 depth and convergence aware discontinuity filter. 123 188 */ 124 pixel CombineSsao FullRes(fragment IN,125 126 127 128 129 130 131 uniform float2 xyStep132 189 pixel 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 ) 133 198 { 134 199 pixel OUT; … … 141 206 const float convergence = ao.y; 142 207 208 const float2 xyStep = float2(0, 1.0f / res.y); 209 143 210 // filter reaches size 1 pixel when sample size reaches threshold 144 211 // afterwards we do not use the filter anymore
Note: See TracChangeset
for help on using the changeset viewer.