Changeset 3372
- Timestamp:
- 05/19/09 19:17:41 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
r3371 r3372 168 168 geom->mMaterial = mat; 169 169 170 static int count = 0;171 if (count ++ < 10)172 170 cout << "creating new geometry with " << numElements << " vertices" << endl; 173 171 … … 206 204 207 205 208 bool ObjConverter::Convert(const string &filename, 209 const std::string &outputFilename) 206 bool ObjConverter::Convert(const string &filename, const std::string &outputFilename) 210 207 { 211 208 mNumShapes = 0; … … 361 358 str.write(reinterpret_cast<char *>(geom->mTexcoords), sizeof(float) * texCoordCount * 2); 362 359 360 361 /////// 362 //-- texture 363 /* 364 #ifdef USE_TEXTURE 365 int texId = 0; 366 #else 367 int texId = -1; 368 #endif 369 370 str.write(reinterpret_cast<char *>(&texId), sizeof(int)); 371 372 bool alphaTestEnabled = false; 373 //bool cullFaceEnabled = false; 374 bool cullFaceEnabled = true; 375 376 str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 377 str.write(reinterpret_cast<char *>(&cullFaceEnabled), sizeof(bool)); 378 379 // material 380 bool hasMaterial = true; 381 //bool hasMaterial = false; 382 str.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 383 384 if (hasMaterial) 385 { 386 SimpleVec ambient, diffuse, spec, emm; 387 388 ambient.x = ambient.y = ambient.z = 0.2f; 389 //diffuse.x = diffuse.y = diffuse.z = 1.0f; 390 diffuse.x = 0.7f; diffuse.y = 0.5f; diffuse.z = 0.2f; 391 spec.x = spec.y = spec.z = .0f; 392 emm = spec; 393 394 // only write rgb part of the material 395 str.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 396 str.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 397 str.write(reinterpret_cast<char *>(&spec), sizeof(SimpleVec)); 398 str.write(reinterpret_cast<char *>(&emm), sizeof(SimpleVec)); 399 } 400 */ 363 401 } 364 402 … … 369 407 ogzstream ofile(filename.c_str()); 370 408 371 if (!ofile.is_open()) return false; 409 if (!ofile.is_open()) 410 return false; 372 411 373 412 … … 409 448 { 410 449 WriteGeometry(ofile, *it); 411 412 int texId = 0; 413 ofile.write(reinterpret_cast<char *>(&texId), sizeof(int)); 414 415 bool alphaTestEnabled = false; 416 //bool cullFaceEnabled = false; 417 bool cullFaceEnabled = true; 418 419 ofile.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 420 ofile.write(reinterpret_cast<char *>(&cullFaceEnabled), sizeof(bool)); 421 422 // material 423 bool hasMaterial = true; 424 ofile.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 425 426 if (hasMaterial) 427 { 428 SimpleVec ambient, diffuse, spec, emm; 429 430 ambient.x = ambient.y = ambient.z = .2f; 431 diffuse.x = diffuse.y = diffuse.z = 1.0f; 432 spec.x = spec.y = spec.z = .0f; 433 emm = spec; 434 435 // only write rgb part of the material 436 ofile.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 437 ofile.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 438 ofile.write(reinterpret_cast<char *>(&spec), sizeof(SimpleVec)); 439 ofile.write(reinterpret_cast<char *>(&emm), sizeof(SimpleVec)); 440 } 441 } 450 } 451 452 int texId = 0; 453 ofile.write(reinterpret_cast<char *>(&texId), sizeof(int)); 454 455 bool alphaTestEnabled = false; 456 //bool cullFaceEnabled = false; 457 bool cullFaceEnabled = true; 458 459 ofile.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 460 ofile.write(reinterpret_cast<char *>(&cullFaceEnabled), sizeof(bool)); 461 462 // material 463 bool hasMaterial = true; 464 ofile.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 465 466 SimpleVec ambient, diffuse, spec, emm; 467 468 ambient.x = ambient.y = ambient.z = 0.2f; 469 diffuse.x = diffuse.y = diffuse.z = 1.0f; 470 spec.x = spec.y = spec.z = .0f; 471 emm = spec; 472 473 // only write rgb part of the material 474 ofile.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 475 ofile.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 476 ofile.write(reinterpret_cast<char *>(&spec), sizeof(SimpleVec)); 477 ofile.write(reinterpret_cast<char *>(&emm), sizeof(SimpleVec)); 478 442 479 443 480 int entityCount = 1; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter2.cpp
r3371 r3372 129 129 for (int j = 0; j < 3; ++ j) 130 130 { 131 //if (tIndices[idx[j]] >= (int)texcoords.size()) 132 //cerr << "error: texcoord indices exceed array size " << texcoords.size() << " " << tIndices[idx[j]] << endl; 131 133 const int tidx = min((int)texcoords.size() - 1, tIndices[idx[j]]); 134 132 135 faceTexcoords.push_back(texcoords[tidx]); 133 136 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
r3371 r3372 1 #include "ObjConverter.h"2 //#include "PlyConverter.h"1 //#include "ObjConverter.h" 2 #include "PlyConverter.h" 3 3 #include <iostream> 4 4 #include <time.h> … … 12 12 13 13 //ObjConverter2 converter; 14 ObjConverter converter;15 //PlyConverter converter;14 //ObjConverter converter; 15 PlyConverter converter; 16 16 17 17 cout << "converting obj to dem format" << endl; … … 60 60 61 61 cout << "conversion successful" << endl; 62 //cout << "press any key" << std::cin.get();62 cout << "press any key" << std::cin.get(); 63 63 64 64 return 0; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env
r3362 r3372 30 30 visibilitySolutionInitialState=500000000 31 31 # renderMode: Frustum Culling, Stop And Wait, CHC, CHC ++ 32 renderMode= 332 renderMode=0 33 33 34 34 ############ … … 71 71 72 72 # the used render method (forward, forward + depth pass, deferred, deferred + depth pass 73 #renderMethod=274 renderMethod=073 renderMethod=2 74 #renderMethod=0 75 75 76 76 #modelPath=data/city/model/ -
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.