Changeset 3242
- Timestamp:
- 01/02/09 17:29:48 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 6 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3238 r3242 503 503 </File> 504 504 <File 505 RelativePath=".\src\Pvs.h" 506 > 507 </File> 508 <File 505 509 RelativePath=".\src\RenderQueue.h" 506 510 > … … 540 544 <File 541 545 RelativePath=".\src\Transform3.h" 546 > 547 </File> 548 <File 549 RelativePath=".\src\ViewCellsTree.h" 550 > 551 </File> 552 <File 553 RelativePath=".\src\VisibilitySolutionLoader.h" 542 554 > 543 555 </File> … … 639 651 </File> 640 652 <File 653 RelativePath=".\src\Pvs.cpp" 654 > 655 </File> 656 <File 641 657 RelativePath=".\src\RenderQueue.cpp" 642 658 > … … 730 746 <File 731 747 RelativePath=".\src\Transform3.cpp" 748 > 749 </File> 750 <File 751 RelativePath=".\src\ViewCellsTree.cpp" 752 > 753 </File> 754 <File 755 RelativePath=".\src\VisibilitySolutionLoader.cpp" 732 756 > 733 757 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
r3241 r3242 246 246 247 247 // update bvh bounding boxes with loaded geometry 248 UpdateNodeBox(mRoot); 248 UpdateBvh(mRoot); 249 250 cout << "bvh: " << mRoot->first << " " << mRoot->last << " bb: " << mRoot->box << endl; 249 251 250 252 cout << "writing scene" << endl; … … 331 333 default: 332 334 sscanf(str + 1, "%f %f %f", &x, &y, &z); 333 //const float scale = 5e-3f;334 const float scale = 0.1f;335 const float scale = 1.0f; 336 //const float scale = 0.1f; 335 337 tempVertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 336 338 //cout <<"v " << x << " " << y << " "<< z << " "; … … 395 397 396 398 sscanf(str + 1, "%f %f %f", &x, &y, &z); 397 const float scale = 0.1f;399 const float scale = 1.0f; 398 400 vertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 399 401 break; … … 558 560 vector<TexCoord> _texCoords; 559 561 562 CHCDemoEngine::AxisAlignedBox3 testBox; 563 testBox.Initialize(); 564 565 for (int i = 0; i < vertices.size(); ++ i) 566 { 567 testBox.Include(vertices[i]); 568 } 569 570 cout << "testbox: " << testBox << endl; 571 560 572 mGeometry.reserve(mBvhLeaves.size()); 561 573 … … 580 592 LoadShape(_vertices, _normals, _texCoords); 581 593 582 node->geometry = mGeometry.back(); 594 // we store geometry in our bvh => change first and last pointer 595 // fromt triangles to geometry 596 node->first = (int)mGeometry.size() - 1; 597 node->last = (int)mGeometry.size() - 1; 583 598 584 599 _vertices.clear(); … … 639 654 leaf->box.Initialize(); 640 655 641 Geometry *geom = leaf->geometry;656 Geometry *geom = mGeometry[leaf->first]; 642 657 643 658 for (size_t i = 0; i < geom->mVertexCount; ++ i) … … 842 857 int nodeType; 843 858 844 if ( !node->IsLeaf())859 if (node->IsLeaf()) 845 860 nodeType = TYPE_LEAF; 846 861 else … … 856 871 857 872 stream.write(reinterpret_cast<char *>(&bMin), sizeof(CHCDemoEngine::Vector3)); 858 stream.write(reinterpret_cast<char *>(&bM in), sizeof(CHCDemoEngine::Vector3));859 } 860 861 862 void VisibilitySolutionConverter::Update NodeBox(BvhNode *node)873 stream.write(reinterpret_cast<char *>(&bMax), sizeof(CHCDemoEngine::Vector3)); 874 } 875 876 877 void VisibilitySolutionConverter::UpdateBvh(BvhNode *node) 863 878 { 864 879 if (!node->IsLeaf()) 865 880 { 866 881 BvhInterior *interior = (BvhInterior *)node; 882 883 UpdateBvh(interior->front); 884 UpdateBvh(interior->back); 885 886 interior->first = min(interior->front->first, interior->back->first); 887 interior->last = max(interior->front->last, interior->back->last); 888 867 889 node->box = Union(interior->front->box, interior->back->box); 868 869 UpdateNodeBox(interior->front);870 UpdateNodeBox(interior->back);871 890 } 872 891 else 873 892 { 874 893 UpdateLeafBox((BvhLeaf *)node); 894 //cout << "bb: " << node->box << endl; 875 895 } 876 896 } … … 883 903 884 904 if (!stream.is_open()) return NULL; 885 886 cout << "loading bvh" << endl;887 905 888 906 WriteNextNode(stream, mRoot); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h
r3241 r3242 68 68 struct BvhLeaf: public BvhNode 69 69 { 70 Geometry *geometry; 71 72 BvhLeaf(): BvhNode(), geometry(NULL) {} 70 BvhLeaf(): BvhNode() {} 73 71 }; 74 72 … … 141 139 142 140 void UpdateLeafBox(BvhLeaf *leaf); 143 144 void UpdateNodeBox(BvhNode *node); 141 /** Prepare bvh for exporting. 142 */ 143 void UpdateBvh(BvhNode *node); 145 144 146 145 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/main.cpp
r3238 r3242 23 23 } 24 24 25 //std::cin.get();26 25 cout << "conversion successful" << endl; 26 27 std::cin.get(); 27 28 28 29 return 0; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3238 r3242 7 7 # misc stuff 8 8 9 filename= city9 filename=vienna_full_hp 10 10 useLODs=1 11 11 # shadow map size … … 61 61 62 62 # the used render method (forward, forward + depth pass, deferred, deferred + depth pass 63 renderMethod=2 63 #renderMethod=2 64 renderMethod=0 64 65 65 66 #modelPath=data/city/model/ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r3239 r3242 82 82 bvh->mNumNodes = 3; 83 83 84 cout << "*******************\nbox: " << root->mBox << " area: " << root->mArea << endl; 85 84 86 tQueue.push(root); 85 87 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3235 r3242 302 302 mSavedFrameNumber(-1), 303 303 mSavedFrameSuffix(""), 304 mMaxDistance(1e6f) 304 mMaxDistance(1e6f), 305 mTempCohFactor(.0f), 306 mUseToneMapping(false), 307 mUseAntiAliasing(false), 308 mUseDepthOfField(false) 305 309 { 306 310 /////////// … … 537 541 538 542 void DeferredRenderer::Render(FrameBufferObject *fbo, 539 float tempCohFactor,540 543 DirectionalLight *light, 541 bool useToneMapping,542 bool useAntiAliasing,543 544 ShadowMap *shadowMap 544 545 ) … … 562 563 { 563 564 case SSAO: 564 ComputeSsao(fbo, tempCohFactor);565 ComputeSsao(fbo, mTempCohFactor); 565 566 CombineSsao(fbo); 566 567 break; 567 568 case GI: 568 ComputeGlobIllum(fbo, tempCohFactor);569 ComputeGlobIllum(fbo, mTempCohFactor); 569 570 CombineIllum(fbo); 570 571 break; … … 574 575 } 575 576 576 /// do depth of field 577 DepthOfField(fbo); 578 579 if (useToneMapping) 577 /// depth of field 578 if (mUseDepthOfField) 579 { 580 DepthOfField(fbo); 581 } 582 583 if (mUseToneMapping) 580 584 { 581 585 float imageKey, whiteLum, middleGrey; … … 593 597 // multisampling is difficult / costly with deferred shading 594 598 // at least do some edge blurring 595 if ( useAntiAliasing) AntiAliasing(fbo, light, displayAfterAA);599 if (mUseAntiAliasing) AntiAliasing(fbo, light, displayAfterAA); 596 600 597 601 /// store the current frame … … 599 603 600 604 // if it hasn't been done yet => just output the latest buffer 601 if (! useAntiAliasing || !displayAfterAA)605 if (!mUseAntiAliasing || !displayAfterAA) 602 606 Output(fbo); 603 607 … … 1266 1270 ) 1267 1271 { 1268 // light source not visible1272 // light source visible? 1269 1273 if (!mSunVisiblePixels) return; 1270 1274 … … 1437 1441 1438 1442 1439 void DeferredRenderer::SetSortSamples(bool sortSamples)1443 /*void DeferredRenderer::SetSortSamples(bool sortSamples) 1440 1444 { 1441 1445 mSortSamples = sortSamples; 1442 } 1446 }*/ 1443 1447 1444 1448 … … 1452 1456 { 1453 1457 mMaxDistance = maxDist; 1458 } 1459 1460 1461 void DeferredRenderer::SetUseToneMapping(bool toneMapping) 1462 { 1463 mUseToneMapping = toneMapping; 1464 } 1465 1466 1467 void DeferredRenderer::SetUseAntiAliasing(bool antiAliasing) 1468 { 1469 mUseAntiAliasing = antiAliasing; 1470 } 1471 1472 1473 void DeferredRenderer::SetUseDepthOfField(bool dof) 1474 { 1475 mUseDepthOfField = dof; 1476 } 1477 1478 1479 void DeferredRenderer::SetTemporalCoherenceFactorForSsao(float factor) 1480 { 1481 mTempCohFactor = factor; 1454 1482 } 1455 1483 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3235 r3242 36 36 and a buffer holding the difference of the pixel positions from the last frame. 37 37 38 Set useToneMapping to true if tone mapping should be applied39 Set useAntiAliasing true if some basic edge antialiasing should be performed40 38 If a shadowMap is specified that is not NULL, the shadow mapped shading algorithm is applied. 41 39 */ 40 void Render(FrameBufferObject *fbo, 41 DirectionalLight *light, 42 ShadowMap *shadowMap = NULL 43 ); 44 45 46 enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT}; 47 /** Use ssao or ssao + color bleeding 48 */ 49 enum SHADING_METHOD {DEFAULT, SSAO, GI}; 50 /** Set the samplig method for the indirect illumination 51 */ 52 void SetSamplingMethod(SAMPLING_METHOD s); 53 /** Set the shading method (SSAO, SSAO + color bleeding 54 */ 55 void SetShadingMethod(SHADING_METHOD s); 56 /** Sort the samples in order to provide faster texture accesses. 57 */ 58 //void SetSortSamples(bool sortSamples); 59 /** Sets ssao sample intensity. 60 */ 61 void SetSampleIntensity(float sampleIntensity); 62 /** Sets ssao kernel radius. 63 */ 64 void SetKernelRadius(float kernelRadius); 65 /** Sets ssao filter radius. 66 */ 67 void SetSsaoFilterRadius(float radius); 68 /** Passes the number of pixels that are visible from the sun. 69 */ 70 void SetSunVisiblePixels(int visiblePixels); 71 /** If true temporal coherence is used for ssao 72 */ 73 void SetUseTemporalCoherence(bool temporal); 74 /** if set to something other than -1 the current frame is stored on disc 75 using the specified frame number 76 */ 77 void SetSaveFrame(const std::string &suffix, int frameNumber); 78 /** Sets the maximal visible distance. 79 */ 80 void SetMaxDistance(float maxDist); 81 /** Enables / disables toneMapping 82 */ 83 void SetUseToneMapping(bool toneMapping); 84 85 /** Enable antiAliasing if some basic edge antialiasing should be performed 86 */ 87 void SetUseAntiAliasing(bool antiAliasing); 88 /** Enables / disables depth of field. 89 */ 90 void SetUseDepthOfField(bool dof); 91 /** 42 92 The temporal coherence factor is the maximal number of ssao samples that are accumulated 43 93 without losing any prior sample information. … … 46 96 1000 samples a flickering cannot be seen. 47 97 */ 48 void Render(FrameBufferObject *fbo, 49 float tempCohFactor, 50 DirectionalLight *light, 51 bool useToneMapping, 52 bool useAntiAliasing, 53 ShadowMap *shadowMap = NULL 54 ); 55 56 57 enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT}; 58 /** Use ssao or ssao + color bleeding 59 */ 60 enum SHADING_METHOD {DEFAULT, SSAO, GI}; 61 /** Set the samplig method for the indirect illumination 62 */ 63 void SetSamplingMethod(SAMPLING_METHOD s); 64 /** Set the shading method (SSAO, SSAO + color bleeding 65 */ 66 void SetShadingMethod(SHADING_METHOD s); 67 /** Sort the samples so texture access is faster 68 */ 69 void SetSortSamples(bool sortSamples); 70 /** Sets ssao sample intensity. 71 */ 72 void SetSampleIntensity(float sampleIntensity); 73 /** Sets ssao kernel radius. 74 */ 75 void SetKernelRadius(float kernelRadius); 76 /** Sets ssao filter radius. 77 */ 78 void SetSsaoFilterRadius(float radius); 79 /** Sets the number of visible pixels of the sun 80 */ 81 void SetSunVisiblePixels(int visiblePixels); 82 /** If true tem poral coherence is used for ssao 83 */ 84 void SetUseTemporalCoherence(bool temporal); 85 /** if set to something other than -1 the current frame is stored on disc 86 using the specified frame number 87 */ 88 void SetSaveFrame(const std::string &suffix, int frameNumber); 89 90 void SetMaxDistance(float maxDist); 98 void SetTemporalCoherenceFactorForSsao(float factor); 91 99 92 100 … … 116 124 117 125 void CombineSsao(FrameBufferObject *fbo); 126 118 127 void CombineIllum(FrameBufferObject *fbo); 119 128 /** Does some basic antialiasing (searches for edges using a edge detector, … … 210 219 211 220 float mMaxDistance; 221 222 float mTempCohFactor; 223 bool mUseToneMapping; 224 bool mUseAntiAliasing; 225 bool mUseDepthOfField; 212 226 }; 213 227 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3238 r3242 381 381 #endif 382 382 383 cout << "=== reading environment file ===" << endl << endl;384 383 385 384 int returnCode = 0; … … 582 581 583 582 584 int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects);583 /* int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects); 585 584 586 585 for (int i = (int)dynamicObjects.size() - cityEntities; i < (int)dynamicObjects.size(); ++ i) 587 586 dynamicObjects[i]->GetTransform()->SetMatrix(transl); 588 587 */ 589 588 590 589 /////////// … … 1295 1294 deferredShader->SetSsaoFilterRadius(ssaoFilterRadius); 1296 1295 deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 1297 deferredShader->SetSortSamples(sortSamples); 1296 //deferredShader->SetSortSamples(sortSamples); 1297 deferredShader->SetTemporalCoherenceFactorForSsao(ssaoTempCohFactor); 1298 deferredShader->SetUseToneMapping(useHDR); 1299 deferredShader->SetUseAntiAliasing(useAntiAliasing); 1300 1298 1301 1299 1302 if (recordFrames && replayPath) … … 1307 1310 1308 1311 ShadowMap *sm = showShadowMap ? shadowMap : NULL; 1309 deferredShader->Render(fbo, ssaoTempCohFactor, light, useHDR, useAntiAliasing, sm);1312 deferredShader->Render(fbo, light, sm); 1310 1313 } 1311 1314
Note: See TracChangeset
for help on using the changeset viewer.