Changeset 3372 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 05/19/09 19:17:41 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3371 r3372 226 226 case DeferredRenderer::SAMPLING_QUADRATIC: 227 227 { 228 //PoissonDiscSampleGenerator2D poisson(NUM_PRECOMPUTED_SAMPLES, 1.0f);229 //poisson.Generate((float *)samples2);230 228 QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 231 229 g.Generate((float *)samples2); … … 845 843 846 844 //if (mRegenerateSamples) 847 if (//mUseTemporalCoherence || 848 mRegenerateSamples) 845 if (1)//mUseTemporalCoherence || mRegenerateSamples) 849 846 { 850 847 mRegenerateSamples = false; … … 861 858 else 862 859 { 863 UpdateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES);860 //UpdateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 864 861 } 865 862 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Halton.cpp
r3322 r3372 79 79 } 80 80 81 // only even prime number 81 // only even prime numbers 82 82 if (idx == 1) return 2; 83 83 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3371 r3372 356 356 str.read(reinterpret_cast<char *>(vertices), sizeof(Vector3) * vertexCount); 357 357 358 //cout << "vertexCount: " << vertexCount << endl;359 360 358 normals = new Vector3[vertexCount]; 361 359 str.read(reinterpret_cast<char *>(normals), sizeof(Vector3) * vertexCount); 362 360 363 364 361 Vector3 *tangents; 365 362 … … 377 374 str.read(reinterpret_cast<char *>(&texCoordCount), sizeof(int)); 378 375 379 //cout << "texCoordCount: " << texCoordCount << endl;380 376 381 377 if (texCoordCount) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
r3371 r3372 248 248 for (int i = 0; i < mNumSamples; ++ i) 249 249 { 250 x[0] = RandomValue(0, 1); x[1] = RandomValue(0, 1);251 //mHalton->GetNext(x);250 //x[0] = RandomValue(0, 1); x[1] = RandomValue(0, 1); 251 mHalton->GetNext(x); 252 252 253 253 const float a = 2.0f * M_PI * x[0]; 254 254 const float r = sqrt(x[1]); 255 //const float rad = mRadius * r * r * r * r;256 const float rad = mRadius * r; // * r;255 256 const float rad = mRadius * r; 257 257 258 258 s[i].x = rad * cos(a); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3371 r3372 645 645 VertexArray positions; 646 646 //const float factor2 = 1.6f; 647 const float factor2 = 1.5f; 647 const float factor2 = .0f; 648 //const float factor2 = 1.5f; 648 649 649 650 // for buddha (lowres) … … 835 836 // another color buffer 836 837 fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, ColorBufferObject::FILTER_NEAREST); 837 838 838 839 839 for (int i = 0; i < 4; ++ i) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3371 r3372 8 8 //#define NUM_PRECOMPUTED_SAMPLES 8124 9 9 #define NUM_PRECOMPUTED_SAMPLES 4096 10 //#define NUM_PRECOMPUTED_SAMPLES 1 02410 //#define NUM_PRECOMPUTED_SAMPLES 16 11 11 12 //#define NUM_SAMPLES 16 13 #define NUM_SAMPLES 16 12 #define NUM_SAMPLES 32 13 //#define NUM_SAMPLES 24 14 14 //#define NUM_SAMPLES 32 15 15 //#define NUM_SAMPLES 64 16 16 17 #define MIN_SAMPLES 1617 #define MIN_SAMPLES 8 18 18 //#define MIN_SAMPLES 48 19 19 … … 26 26 27 27 //#define SSAO_CONVERGENCE_THRESHOLD 300.0f 28 #define SSAO_CONVERGENCE_THRESHOLD 700.0f29 //#define SSAO_CONVERGENCE_THRESHOLD 1300.0f28 //#define SSAO_CONVERGENCE_THRESHOLD 700.0f 29 #define SSAO_CONVERGENCE_THRESHOLD 1300.0f 30 30 //#define SSAO_CONVERGENCE_THRESHOLD 1500.0f 31 31 … … 66 66 #define NUM_DOF_TABS 16 67 67 68 //#define USE_GTX68 #define USE_GTX 69 69 70 70 #define SSAO_FILTER_RADIUS 5 … … 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
r3369 r3372 3 3 4 4 5 /************************************************* /6 /* Filter for combining ssao with image*/7 /************************************************* /5 /********************************************************/ 6 /* Filter for combining ssao with image */ 7 /********************************************************/ 8 8 9 9 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3369 r3372 315 315 float3 translatedPos = -oldEyePos + worldPos.xyz + difVec; 316 316 317 317 318 ///////////////// 318 319 //-- reproject into old frame and calculate texture position of sample in old frame … … 381 382 pix.color.z = color.w; 382 383 */ 383 const float3 translatedPos = ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj); 384 const float3 translatedPos = 385 ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj); 384 386 385 387 pix.color.xyz = translatedPos; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3371 r3372 53 53 54 54 // get position exactly between texel centers 55 float2 center = (floor(texCoord * res) + float2(.5f)) * texCoord; 56 //center.x = (floor(texCoord.x * res.x - .5f) + 1.0f) / res.x; 57 //center.y = (floor(texCoord.y * res.y - .5f) + 1.0f) / res.y; 58 //center.y = (floor(texCoord.y * res.y) + .5f) * yOffs; 59 60 /*texelCenterConv.x = tex2Dlod(tex, float4(center + float2( xoffs, yoffs), 0, 0)).y; 61 texelCenterConv.y = tex2Dlod(tex, float4(center + float2( xoffs, -yoffs), 0, 0)).y; 62 texelCenterConv.z = tex2Dlod(tex, float4(center + float2(-xoffs, -yoffs), 0, 0)).y; 63 texelCenterConv.w = tex2Dlod(tex, float4(center + float2(-xoffs, yoffs), 0, 0)).y; 64 65 const float m1 = min(texelCenterConv.x, texelCenterConv.y); 66 const float m2 = min(texelCenterConv.z, texelCenterConv.w); 67 68 const float convergence = min(m1, m2);*/ 69 55 float2 center = (floor(texCoord * res) + float2(.5f)) * invRes; 56 70 57 //const float convergence = tex2Dlod(tex, float4(center, 0, 0)).y; 71 58 const float convergence = tex2Dlod(tex, float4(texCoord, 0, 0)).y; … … 133 120 134 121 if (1 135 && (oldTexCoords.x > 0) && (oldTexCoords.x < 1.0f)136 && (oldTexCoords.y > 0) && (oldTexCoords.y < 1.0f)122 && (oldTexCoords.x > .0f) && (oldTexCoords.x < 1.0f) 123 && (oldTexCoords.y > .0f) && (oldTexCoords.y < 1.0f) 137 124 && (depthDif <= MIN_DEPTH_DIFF) 138 125 ) 139 126 { 140 // pixel valid => retrieve the convergence weight 141 /*float w1 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 142 float w2 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 143 float w3 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0, 0.5f / 768.0f), .0f, .0f)).y; 144 float w4 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0, 0.5f / 768.0f), .0f, .0f)).y; 145 146 w = min(min(w1, w2), min(w3, w4));*/ 127 #if 0 128 idx = floor(oldPixel.z); 129 #else 130 131 // nearest neighbour 132 float2 center; 133 center.x = (floor(oldTexCoords.x * 1024) + .5f) / 1024; 134 center.y = (floor(oldTexCoords.y * 768) + .5f) / 768; 147 135 148 //w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 149 w = oldPixel.y; 150 idx = floor(oldPixel.z); 151 //idx = oldPixel.z; 136 const float4 oldPixelExact = tex2Dlod(oldTex, float4(center, .0f, .0f)); 137 idx = oldPixelExact.z; 138 #endif 139 140 w = oldPixel.y; 152 141 } 153 142 else … … 487 476 float2 offset; 488 477 489 const float2 ssaoOffset = tex2Dlod(samples, float4(( 0.5f + i + oldIdx) / NUM_PRECOMPUTED_SAMPLES, .5f, .0f, .0f)).xy;478 const float2 ssaoOffset = tex2Dlod(samples, float4((.5f + i + floor(oldIdx)) / NUM_PRECOMPUTED_SAMPLES, .5f, .0f, .0f)).xy; 490 479 //const float2 ssaoOffset = dummySamples[i]; 491 480 … … 494 483 //-- (affects performance for some reason!) 495 484 496 if ( 1)//!USE_OPTIMIZATION ||497 //(convergence < SSAO_CONVERGENCE_THRESHOLD))485 if (!USE_OPTIMIZATION || 486 (convergence < SSAO_CONVERGENCE_THRESHOLD)) 498 487 { 499 488 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; … … 521 510 float3 dirSample = samplePos - centerPosition; 522 511 523 const float minDist = 1e-6f;524 512 const float eps = 1e-3f; 525 513 … … 527 515 const float sampleWeight = 1.0f / max(lengthToSample, eps); 528 516 529 dirSample /= max(length(dirSample), minDist); // normalize517 dirSample /= max(length(dirSample), eps); // normalize 530 518 531 519 // angle between current normal and direction to sample controls AO intensity. … … 540 528 541 529 542 //#ifdef PERFORMANCE_TEST 543 #if 1 530 #ifdef PERFORMANCE_TEST 544 531 // check if the samples have been valid in the last frame 545 532 // only mark sample as invalid if in the last / current frame … … 552 539 const float distanceDiff = abs(oldDistance - lengthToSample); 553 540 554 float pixelValid = (oldSamplePos.x > 1e14f) ? 100.0f : .0f; 555 556 if ((cosAngle >= 0) && (pixelValid < 90.0f))// || (cosAngle2 >= 0)) 557 { 558 pixelValid = (distanceDiff > 1e-3f) ? 100.0f : .0f; 559 //pixelValid = (distanceDiff > 1e-3f) ? 5.0f : .0f; 541 float pixelValid = .0f; 542 543 if ((texcoord.x > .0f) && (texcoord.x < 1.0f) && (texcoord.y > .0f) && (texcoord.y < 1.0f)) 544 { 545 if ((oldSamplePos.x > 1e14f))// || ((cosAngle >= 0) && (distanceDiff > 1e-3f))) 546 { 547 pixelValid = 100.0f; 548 } 549 else if ((cosAngle >= 0) && (distanceDiff > 1e-3f)) 550 { 551 pixelValid = 5.0f; 552 } 560 553 } 561 554 … … 742 735 743 736 oldWeight = min(oldWeight, factor * NUM_SAMPLES); 737 744 738 if (newIdx >= factor * NUM_SAMPLES) 745 739 {
Note: See TracChangeset
for help on using the changeset viewer.