Changeset 3206 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 12/02/08 19:15:08 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3205 r3206 116 116 117 117 118 static Sample2 UnitTest 2(float x, float y, int wi, int he)118 static Sample2 UnitTest(float x, float y, int wi, int he) 119 119 { 120 120 Sample2 s; … … 351 351 352 352 InitCg(); 353 354 float x = 400.5f / w;355 float y = 100.5f / h;356 357 Sample2 res = UnitTest2(x, y, dsw, dsh);358 359 cout << "input : " << x << ", " << y << endl;360 cout << "result : " << res.x << " " << res.y << endl;361 cout << "result2: " << res.x * w << " " << res.y * h << endl;362 353 } 363 354 … … 366 357 { 367 358 CLEAR_CONTAINER(mFBOs); 359 368 360 glDeleteTextures(1, &noiseTex2D); 369 361 glDeleteTextures(1, &noiseTex1D); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3204 r3206 11 11 //#define NUM_SAMPLES 96 12 12 13 #define SAMPLE_INTENSITY 0. 3f13 #define SAMPLE_INTENSITY 0.2f 14 14 //#define SAMPLE_INTENSITY 2.0f 15 15 … … 27 27 //#define NUM_SSAO_FILTERSAMPLES 80 28 28 #define NUM_SSAO_FILTER_SAMPLES 16 29 29 30 #define SSAO_FILTER_WIDTH 12.0f 30 #define SSAO_CONVERGENCE_WEIGHT 300.0f 31 //#define SSAO_FILTER_WIDTH 6.0f 32 33 #define SSAO_CONVERGENCE_THRESHOLD 700.0f 31 34 32 35 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3205 r3206 166 166 uniform float3 tl, 167 167 uniform float3 tr, 168 uniform float 3w,169 uniform float 3h168 uniform float w, 169 uniform float h 170 170 ) 171 171 { … … 200 200 //const float convergence = ao.y; 201 201 202 // filter reaches size 1 pixel after thres samples:202 // filter reaches size 1 pixel when sample size reaches threshold 203 203 // afterwards we do not use the filter anymore 204 const float thres = 500.0f;205 204 206 205 // filter up to a certain convergance value and leave out background (sky) by checking depth 207 if ((convergence < thres) && (col.w < 1e10f))206 if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (col.w < 1e10f)) 208 207 { 209 208 const float distanceScale = 1.0f; 210 209 211 210 // descend to zero filter size after reaching thres pixels 212 const float convergenceWeight = thres/ (SSAO_FILTER_WIDTH - 1.0f);211 const float convergenceWeight = SSAO_CONVERGENCE_THRESHOLD / (SSAO_FILTER_WIDTH - 1.0f); 213 212 const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 214 213 const float scale = SSAO_FILTER_WIDTH * convergenceScale * distanceScale; … … 235 234 236 235 237 238 236 /** Function combining image and indirect illumination buffer using a 239 237 depth and normal aware discontinuity filter. -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3204 r3206 201 201 valid in the current frame 202 202 */ 203 inline float PixelValid(sampler2D oldTex,203 inline float2 PixelValid(sampler2D oldTex, 204 204 float4 color, 205 205 float3 difVec, … … 262 262 const bool newDynamic = (oldPixel.z > DYNAMIC_OBJECTS_THRESHOLD); 263 263 264 const float xOffs = 1.0f / 1024.0f;265 const float yOffs = 1.0f / 768.0f;264 //const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f; 265 //const float eps = 1e-6f; 266 266 267 267 // actually 0 means pixel is valid … … 270 270 const float pixelNotValid = 10.0f; 271 271 272 const float eps = 1e-6f; 273 274 if (0 275 //&& !(oldDynamic && newDynamic && (depthDif <= MIN_DEPTH_DIFF)) 276 //&& (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= (1.0f - xOffs) + eps ) 277 //&& (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= (1.0f - yOffs) + eps ) 278 || (oldTexCoords.x < .0f) || (oldTexCoords.x >= 1.0f) 279 || (oldTexCoords.y < .0f) || (oldTexCoords.y >= 1.0f) 280 ) 272 if ((oldTexCoords.x < .0f) || (oldTexCoords.x >= 1.0f) || 273 (oldTexCoords.y < .0f) || (oldTexCoords.y >= 1.0f)) 281 274 { 282 275 pixelValid = pixelNotValid; 283 276 } 284 // check if changed from dynamic to not dynamic object285 // or there is a depth discontinuity286 277 else 287 if ((oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 288 (oldDynamic && newDynamic && (depthDif <= MIN_DEPTH_DIFF))) 278 if ( 279 // check if changed from dynamic to not dynamic object 280 (oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 281 // check if we have a dynamic object and is a depth discontinuity 282 ((oldDynamic || newDynamic) && (depthDif <= MIN_DEPTH_DIFF))) 289 283 { 290 284 pixelValid = pixelCouldBeValid; … … 295 289 } 296 290 297 return pixelValid;291 return float2(pixelValid, abs(oldEyeSpaceDepth - projectedEyeSpaceDepth)); 298 292 } 299 293 … … 325 319 326 320 // do reprojection and filter out the pixels that are not save 327 float pValid = PixelValid(oldTex,321 float2 pValid = PixelValid(oldTex, 328 322 color, 329 323 difVec.xyz, … … 337 331 338 332 pix.color = color; 339 pix.color.x = pValid;333 pix.color.xy = pValid.xy; 340 334 pix.normal = normal; 341 335 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3205 r3206 322 322 #endif 323 323 324 ++ numSamples; 325 324 326 // check if the samples have been valid in the last frame 325 // hack: the distance measure can fail in some cases => choose something different 326 const float tooFarAway = step(1.0f, lengthToSample); 327 validSamples = max(validSamples, (1.0f - tooFarAway) * sampleColor.x); 328 327 // only mark sample as invalid if taking it into account can have influence the ssao: 328 // hence we also check if the sample or the same sample in the previous frame 329 // had any chance to be near the current sample 330 const float changeFactor = sampleColor.y; 331 const float pixelValid = sampleColor.x; 332 333 // hack: cedistance measure can fail in some cases => choose something different 334 const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 335 validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid); 329 336 //validSamples += sampleColor.x; 330 331 ++ numSamples;332 337 333 338 //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; … … 417 422 const float squaredLen = SqrLen(diffVec); 418 423 419 if (ao.y > 4.0f) oldWeight = 0; 420 else if ((ao.y > 1.0f) && (squaredLen < DYNAMIC_OBJECTS_THRESHOLD)) 421 oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); 422 424 // check if we have to reset pixel because one of the sample points was invalid 425 if (squaredLen < DYNAMIC_OBJECTS_THRESHOLD) 426 { 427 if (ao.y > 4.0f) 428 oldWeight = 0; 429 else if (ao.y > 1.0f) 430 oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); 431 } 432 423 433 const float newWeight = ao.z; 424 434 const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 435 436 425 437 // blend between old and new samples (and avoid division by zero) 426 OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, (newWeight + oldWeight)); 427 OUT.illum_col.y = clamp(newWeight + oldWeight, .0f, temporalCoherence); 428 438 OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 429 439 OUT.illum_col.z = SqrLen(diffVec); 440 OUT.illum_col.y = combinedWeight; 430 441 OUT.illum_col.w = eyeSpaceDepth; 431 442
Note: See TracChangeset
for help on using the changeset viewer.