- Timestamp:
- 08/26/08 18:09:03 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r2868 r2869 181 181 return float4(total_color, 1.0f - total_ao); 182 182 } 183 184 185 float ComputeSmoothedColor(float4 centerPosition, 186 uniform sampler2D oldTex, 187 uniform float maxDepth, 188 uniform float expFactor, 189 const uniform float4x4 oldModelViewProj, 190 float4 currentCol 191 ) 192 { 193 float4 realPos = centerPosition * maxDepth; 194 realPos.w = 1.0f; 195 196 float4 oldPos = mul(oldModelViewProj, realPos); 197 198 float newDepth = oldPos.z / oldPos.w; 199 200 float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 201 float4 oldCol = tex2D(oldTex, tex); 202 203 float oldDepth = oldCol.w; 204 float depthDif = 1.0f - newDepth / oldDepth; 205 206 float4 col; 207 208 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 209 (tex.y >= 0.0f) && (tex.y < 1.0f) && 210 (abs(depthDif) < 1e-4f)) 211 { 212 col = currentCol * expFactor + oldCol * float4(1.0f - expFactor); 213 } 214 else 215 { 216 col = currentCol; 217 } 218 219 return col; 220 } 183 221 184 222 … … 217 255 218 256 float ao = ssao(IN, positions, noiseTexture, samples, normal.xyz, viewDir, noiseMultiplier, centerPosition); 219 float4 attenuated_color = ao * col;257 //float4 attenuated_color = ao * col; 220 258 //float4 attenuated_color = ao; 221 259 … … 223 261 //float4 attenuated_color = ao * col + new_col; 224 262 225 const float x = expFactor; 226 227 float4 dummy = centerPosition * maxDepth; 228 dummy.w = 1.0f; 229 230 float4 oldPos = mul(oldModelViewProj, dummy); 231 232 float newDepth = oldPos.z / oldPos.w; 233 234 float2 tex = (oldPos.xy / oldPos.w) * 0.5f + 0.5f; 235 float4 col1 = tex2D(oldTex, tex); 236 237 float oldDepth = col1.w; 238 float depthDif = 1.0f - newDepth / oldDepth; 239 240 if ((tex.x >= 0.0f) && (tex.x < 1.0f) && 241 (tex.y >= 0.0f) && (tex.y < 1.0f) && 242 (abs(depthDif) < 1e-4f)) 243 { 244 OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); 245 } 246 else 247 { 248 OUT.color = attenuated_color; 249 } 263 // compute temporally smoothed color 264 OUT.color = ComputeSmoothedColor(centerPosition, oldTex, maxDepth, expFactor, oldModelViewProj, float4(ao)); 250 265 251 266 //OUT.color.xyz = viewDir; … … 256 271 return OUT; 257 272 } 273 274 275 pixel combined(fragment IN, 276 uniform sampler2D colors, 277 uniform sampler2D ssaoTex 278 ) 279 { 280 pixel OUT; 281 282 float4 col = tex2D(colors, IN.texCoord.xy); 283 float4 ao = tex2D(ssaoTex, IN.texCoord.xy); 284 285 OUT.color = float4(1,0,0,0); 286 OUT.color = col * ao; 287 288 return OUT; 289 }
Note: See TracChangeset
for help on using the changeset viewer.