- Timestamp:
- 02/13/09 15:59:33 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3309 r3310 48 48 weight of the pixel in the new frame. 49 49 */ 50 inline float 2temporalSmoothing(float4 worldPos,50 inline float3 temporalSmoothing(float4 worldPos, 51 51 float eyeSpaceDepth, 52 52 float2 texcoord0, … … 96 96 // the weight of the accumulated samples from the previous frames 97 97 float w; 98 float idx; 98 99 99 100 ////////////// … … 108 109 // pixel valid => retrieve the convergence weight 109 110 w = oldPixel.y; 111 idx = oldPixel.z; 110 112 } 111 113 else 112 114 { 113 w = 0.0f; 114 } 115 116 return float2(ssao, w); 115 w = .0f; 116 idx = .0f; 117 } 118 119 return float3(ssao, w, idx); 117 120 } 118 121 … … 141 144 float numSamples = .0f; 142 145 float validSamples = .0f; 146 143 147 144 148 for (int i = 0; i < NUM_PRECOMPUTED_SAMPLES; ++ i) … … 247 251 //-- (affects performance for some reason!) 248 252 249 if ( convergence < SSAO_CONVERGENCE_THRESHOLD)253 if (1)//convergence < SSAO_CONVERGENCE_THRESHOLD) 250 254 { 251 255 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 252 256 //offset = myreflect(samples[i], mynoise); 253 offset = myrotate(samples[i + idx], mynoise.x); 257 offset = myrotate(samples[i], mynoise.x); 258 //offset = myrotate(samples[i + idx], mynoise.x); 254 259 } 255 260 else 256 261 { 257 offset = samples[i + idx]; 262 //offset = samples[i + idx]; 263 offset = samples[i]; 258 264 } 259 265 … … 382 388 //-- compute temporal reprojection 383 389 384 float 2temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos,390 float3 temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 385 391 oldTex, oldModelViewProj, 386 392 colors, … … 394 400 float oldWeight = temporalVals.y; 395 401 396 float usedWeight = min(temporalCoherence, abs(oldWeight));397 int idx = (int)oldWeight % (int)temporalCoherence;402 int idx = (int)temporalVals.z; 403 //min(0, (int)oldWeight % max((int)temporalCoherence, 1)); 398 404 399 405 float3 ao; … … 402 408 if (eyeSpaceDepth < DEPTH_THRESHOLD) 403 409 { 404 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), usedWeight, sampleIntensity, isMovingObject, idx); 410 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, 411 scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, 412 sampleIntensity, isMovingObject, idx); 405 413 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 406 414 } … … 428 436 if (ao.y > completelyResetThres) 429 437 { 430 oldWeight = .0f; 438 oldWeight = .0f; 439 idx = .0f; 431 440 } 432 441 else if (ao.y > partlyResetThres) 433 442 { 434 443 oldWeight = min(oldWeight, 4.0f * newWeight); 435 //oldWeight = .0f;444 idx = oldWeight; 436 445 } 437 446 } 447 448 float usedWeight = min(temporalCoherence, oldWeight); 449 438 450 439 451 ////////// 440 452 //-- blend ao between old and new samples (and avoid division by zero) 441 453 442 OUT.illum_col.x = ao.x * newWeight + oldSsao * usedWeight; 443 OUT.illum_col.x /= (newWeight + usedWeight); 454 OUT.illum_col.x = ao.x * newWeight;// + oldSsao * usedWeight; 455 OUT.illum_col.x /= max(newWeight + usedWeight, 1); 456 457 //if (oldWeight >= 10000) oldWeight = 1000; 444 458 445 459 // the new weight for the next frame 446 460 //const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 447 const float combinedWeight = newWeight + oldWeight; 461 float combinedWeight = newWeight + oldWeight; 462 463 clamp(combinedWeight, 0, 1000); 448 464 449 465 OUT.illum_col.y = combinedWeight;
Note: See TracChangeset
for help on using the changeset viewer.