Changeset 3369 for GTP/trunk/App/Demos/Vis/FriendlyCulling
- Timestamp:
- 05/13/09 18:33:02 (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/chcdemo.cpp
r3368 r3369 104 104 float farDist = 1e6f; 105 105 /// the field of view 106 const float fov = 50.0f; 106 //const float fov = 50.0f; 107 const float fov = 90.0f; 107 108 108 109 float skyDomeScaleFactor = 80.0f; … … 627 628 //LoadModel("elephal.dem", dynamicObjects); 628 629 629 if ( 0) LoadPompeiiFloor();630 if (1) LoadPompeiiFloor(); 630 631 631 632 #if 1 … … 643 644 // sibenik positions 644 645 VertexArray positions; 645 const float factor2 = 1.6f; 646 //const float factor2 = 1.6f; 647 const float factor2 = 1.5f; 648 646 649 // for buddha (lowres) 647 650 positions.push_back(Vector3(6.07307, 8.20723, 6.62 - factor2)); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3368 r3369 10 10 //#define NUM_PRECOMPUTED_SAMPLES 2048 11 11 12 #define NUM_SAMPLES 4813 12 //#define NUM_SAMPLES 16 14 13 //#define NUM_SAMPLES 24 15 14 //#define NUM_SAMPLES 32 16 //#define NUM_SAMPLES 4815 #define NUM_SAMPLES 48 17 16 18 #define MIN_SAMPLES 4817 #define MIN_SAMPLES 8 19 18 //#define MIN_SAMPLES 48 20 19 … … 28 27 //#define SSAO_CONVERGENCE_THRESHOLD 300.0f 29 28 #define SSAO_CONVERGENCE_THRESHOLD 700.0f 29 //#define SSAO_CONVERGENCE_THRESHOLD 1300.0f 30 30 //#define SSAO_CONVERGENCE_THRESHOLD 1500.0f 31 31 … … 74 74 #define PERFORMANCE_TEST 1 75 75 76 #define USE_OPTIMIZATION 076 #define USE_OPTIMIZATION 1 77 77 78 78 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
r3365 r3369 253 253 // the filtered ssao value 254 254 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, 255 256 255 bl, br, tl, tr, 256 xyStep, convergence, maxConvergence, spatialWeight); 257 257 } 258 258 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3366 r3369 305 305 float3 difVec, 306 306 float3 viewDir, 307 float3 oldEyePos 307 float3 oldEyePos, 308 float4x4 oldModelViewProj 308 309 ) 309 310 { … … 312 313 const float4 worldPos = float4(-viewDir * eyeSpaceDepth, 1.0f); 313 314 // compute position from old frame for dynamic objects + translational portion 314 const float3 translatedPos = -oldEyePos + worldPos.xyz + difVec; 315 315 float3 translatedPos = -oldEyePos + worldPos.xyz + difVec; 316 317 ///////////////// 318 //-- reproject into old frame and calculate texture position of sample in old frame 319 320 // note: the old model view matrix only holds the view orientation part 321 float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 322 backProjPos /= backProjPos.w; 323 324 // fit from unit cube into 0 .. 1 325 const float2 oldTexCoords = backProjPos.xy * .5f + .5f; 326 327 // check if the pixel was outside of the frame buffer 328 if ((oldTexCoords.x <= .0f) || (oldTexCoords.x >= 1.0f) || 329 (oldTexCoords.y <= .0f) || (oldTexCoords.y >= 1.0f) 330 ) 331 { 332 translatedPos = float3(1e15f); 333 } 334 316 335 return translatedPos; 317 336 } … … 362 381 pix.color.z = color.w; 363 382 */ 364 const float3 translatedPos = ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos );383 const float3 translatedPos = ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj); 365 384 366 385 pix.color.xyz = translatedPos; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3368 r3369 359 359 { 360 360 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 361 //offset = myreflect(samples[i], mynoise);362 361 //offset = myrotate(samples[i], mynoise.x); 363 362 offset = myrotate(ssaoOffset, mynoise.x); … … 418 417 const float tooFarAway = step(.5f, lengthToSample - changeFactor); 419 418 if (0)//pixelValid <= partlyResetThres) 420 validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(- 0.1f, cosAngle));419 validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-.1f, cosAngle)); 421 420 else 422 421 validSamples = max(validSamples, pixelValid); … … 550 549 const float3 oldVector = oldSamplePos - oldPos; 551 550 const float oldDistance = length(oldVector); 552 const float cosAngle2 = dot(oldVector, normal); 553 554 if ((cosAngle >= 0) || (cosAngle2 >= 0)) 555 { 556 const float oldDistance = length(oldSamplePos - oldPos); 557 const float distanceDiff = abs(oldDistance - lengthToSample); 558 559 float pixelValid = (distanceDiff > 1e-3f) ? 100.0f : 0; 560 561 validSamples = max(validSamples, pixelValid); 562 } 551 //const float cosAngle2 = dot(oldVector, normal); 552 553 const float distanceDiff = abs(oldDistance - lengthToSample); 554 555 float pixelValid = (oldSamplePos.x > 1e14f) ? 100.0f : .0f; 556 557 if ((cosAngle >= 0) && (pixelValid < 90.0f))// || (cosAngle2 >= 0)) 558 { 559 //pixelValid = (distanceDiff > 1e-3f) ? 100.0f : .0f; 560 pixelValid = (distanceDiff > 1e-3f) ? 5.0f : .0f; 561 } 562 563 validSamples = max(validSamples, pixelValid); 564 563 565 #ifdef USE_GTX 564 566 // we can bail out early and use a minimal #samples) … … 682 684 683 685 float3 ao; 684 // 685 oldIdx = dummyIdx;686 //$$temp matt 687 //oldIdx = dummyIdx; 686 688 687 689 // cull background note: this should be done with the stencil buffer … … 708 710 bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, 709 711 isMovingObject, normals, oldIdx); 710 712 */ 711 713 } 712 714 } … … 730 732 const float partlyResetThres = 1.0f; 731 733 734 // the new index for the next frame 735 float newIdx; 736 // the new weight for the next frame 737 float combinedWeight; 738 732 739 // don't check for moving objects, otherwise almost no coherence 733 if (1)//!isMovingObject) 734 { 735 if (ao.y > completelyResetThres) 736 { 737 oldWeight = .0f; 738 oldIdx = .0f; 739 } 740 else if (ao.y > partlyResetThres) 741 { 742 const float factor = 4.0f; 743 //if (oldIdx >= factor * newWeight) oldIdx = 0; 744 //oldWeight = min(oldWeight, factor * newWeight); 745 oldWeight = oldIdx = .0f; 746 } 747 } 740 if (ao.y > completelyResetThres) 741 { 742 oldWeight = newIdx = .0f; 743 } 744 else 745 { 746 newIdx = oldIdx + newWeight; 747 } 748 749 if (ao.y > partlyResetThres) 750 { 751 const float factor = 3.0f; 752 753 oldWeight = min(oldWeight, factor * NUM_SAMPLES); 754 if (newIdx >= factor * NUM_SAMPLES) {newIdx = 0; /*oldWeight = .0f;*/ } 755 756 //combinedWeight = oldWeight; 757 } 758 759 // the new weight for the next frame 760 combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 748 761 749 762 … … 756 769 //OUT.illum_col.x = ao.y; 757 770 758 // the new weight for the next frame759 const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence);760 761 771 OUT.illum_col.y = combinedWeight; 762 OUT.illum_col.z = oldIdx + newWeight; // the new index772 OUT.illum_col.z = newIdx; // the new index 763 773 OUT.illum_col.w = eyeSpaceDepth; 764 774
Note: See TracChangeset
for help on using the changeset viewer.