Changeset 507 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/07/06 10:50:29 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp
r506 r507 40 40 } 41 41 } 42 43 mBox = box; 44 mDirBox = dBox; 45 46 SetValid(); 42 47 } 43 48 -
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h
r506 r507 12 12 13 13 public: 14 enum {STORE_KD_NODES=1, STORE_OBJECTS=2 };14 enum {STORE_KD_NODES=1, STORE_OBJECTS=2, VALID=4}; 15 15 int mFlags; 16 16 17 17 // list of nodes intersected by the frustum 18 18 vector<KdNode *> mKdNodes; 19 // lits of objects intersected by the fru m19 // lits of objects intersected by the frustum 20 20 vector<Intersectable *> mObjects; 21 22 21 23 22 // spatial box … … 28 27 29 28 vector<Plane3> mPlanes; 30 31 Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS) 29 30 bool IsValid() { return mFlags & VALID; } 31 bool SetValid() { return mFlags |= VALID; } 32 33 Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS),mKdNodes(0), mObjects(0) 32 34 { 33 35 } … … 36 38 const AxisAlignedBox3 &dBox); 37 39 38 40 39 41 int 40 42 ComputeIntersection(const AxisAlignedBox3 &box); -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r504 r507 5 5 #include "Pvs.h" 6 6 #include "Viewcell.h" 7 #include "Beam.cpp" 7 8 8 9 #include <GL/glext.h> … … 529 530 530 531 } 532 533 534 void 535 GlRendererBuffer::SampleBeamContributions( 536 Intersectable *sourceObject, 537 Beam &beam, 538 const int desiredSamples, 539 BeamSampleStatistics &stat 540 ) 541 { 542 // assumes that the beam is constructed and contains kd-tree nodes 543 // and viewcells which it intersects 544 545 546 547 548 // Get the number of viewpoints to be sampled 549 // Now it is a sqrt but in general a wiser decision could be made. 550 // The less viewpoints the better for rendering performance, since less passes 551 // over the beam is needed. 552 // The viewpoints could actually be generated outside of the bounding box which 553 // would distribute the 'efective viewpoints' of the object surface and thus 554 // with a few viewpoints better sample the vipoint space.... 555 556 int viewPointSamples = sqrt((float)desiredSamples); 557 558 // the number of direction samples per pass is given by the number of viewpoints 559 int directionalSamples = desiredSamples/viewPointSamples; 560 int i; 561 for (i=0; i < viewPointSamples; i++) { 562 Vector3 viewPoint = beam.mBox.GetRandomPoint(); 563 // perhaps the viewpoint should be shifted back a little bit so that it always lies 564 // inside the source object 565 // 'ideally' the viewpoints would be distributed on the soureObject surface, but this 566 // would require more complicated sampling (perhaps hierarchical rejection sampling of 567 // the object surface is an option here - only the mesh faces which are inside the box 568 // are considered as candidates) 569 SampleViewpointContributions( 570 sourceObject, 571 beam, 572 directionalSamples, 573 stat 574 ); 575 } 576 577 578 // note: 579 // this routine would be called only if the number of desired samples is sufficiently 580 // large - for other rss tree cells the cpu based sampling is perhaps more efficient 581 // distributing the work between cpu and gpu would also allow us to place more sophisticated 582 // sample distributions (silhouette ones) using the cpu and the jittered once on the GPU 583 // in order that thios scheme is working well the gpu render buffer should run in a separate 584 // thread than the cpu sampler, which would not be such a big problem.... 585 } 586 587 588 void 589 GlRendererBuffer::SampleViewpointContributions( 590 Intersectable *sourceObject, 591 Beam &beam, 592 const int desiredSamples, 593 BeamSampleStatistics &stat 594 ) 595 { 596 // 1. setup the view port to match the desired samples 597 // 2. setup the projection matrix and view matrix to match the viewpoint + beam.mDirBox 598 599 // 3. reset z-buffer to 0 and render the source object for the beam using 600 // glDepthFunc(GL_GREATER) 601 // and glCullFace(Enabled) and glFrontFace(GL_CW) 602 // remember the ray origin depth buffer somewhere? 603 604 // 4. set back to normal rendering and clear the ray termination depth buffer 605 // 5. render all objects inside the beam using id based false color 606 // (objects can be compiled to a gl list now so that subsequent rendering for 607 // this beam is fast - the same hold for step 3) 608 609 610 // 6. Now we have a two depth buffers defining the ray origin and termination 611 // only rays which have non-zero entry in the origin buffer are valid since 612 // they realy start on the object surface (this can also be tagged by setting a 613 // stencil buffer bit at step 3) 614 615 // 7. Use occlusion queries for all viewcell meshes associated with the beam -> 616 // a fragment passes if the corresponding stencil fragment is set and its depth is 617 // between origin and termination buffer 618 619 // 8. The number of visible pixels is the number of sample rays which see the source 620 // object from the corresponding viewcell -> rember these values for later update 621 // of the viewcell pvs - or update immediatelly? 622 623 // In general it is not neccessary to rember to extract all the rays cast. I hope it 624 // would be sufficient to gain only the intergral statistics about the new contributions 625 // and so the rss tree would actually store no new rays (only the initial ones) 626 // the subdivision of the tree would only be driven by the statistics (the glrender could 627 // evaluate the contribution entropy for example) 628 // However might be an option to extract/store only those the rays which made a contribution 629 // (new viewcell has been discovered) or relative contribution greater than a threashold... 630 631 632 } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r504 r507 17 17 class Intersectable; 18 18 class Material; 19 class Beam; 19 20 20 21 struct PvsRenderStatistics { … … 129 130 void 130 131 ClearErrorBuffer(); 131 132 132 133 133 134 134 virtual int GetWidth() const { return width(); } 135 135 virtual int GetHeight() const { return height(); } 136 137 138 139 // the values need for rss tree update computed already inside the glrendererbuffer 140 // not all of them need to be computed 141 struct BeamSampleStatistics { 142 143 enum {COMPUTE_PVS_SIZE, COMPUTE_RAY_CONTRIBUTIONS, COMPUTE_PVS_ENTROPY}; 144 int flags; 145 146 BeamSampleStatistics():flags(COMPUTE_RAY_CONTRIBUTIONS) {} 147 148 float pvsSize; 149 float rays; 150 float rayContributions; 151 float pvsEntropy; 152 float rayLengthEntropy; 153 float importance; 154 155 float weightedRayContribution; 156 }; 157 158 159 void SampleBeamContributions( 160 Intersectable *sourceObject, 161 Beam &beam, 162 const int samples, 163 BeamSampleStatistics &stat 164 ); 165 166 void 167 SampleViewpointContributions( 168 Intersectable *sourceObject, 169 Beam &beam, 170 const int desiredSamples, 171 BeamSampleStatistics &stat 172 ); 136 173 137 174 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r505 r507 941 941 KdTree::GetRandomLeaf(const bool onlyUnmailed) 942 942 { 943 943 stack<KdNode *> nodeStack; 944 944 nodeStack.push(mRoot); 945 946 945 946 int mask = rand(); 947 947 948 948 while (!nodeStack.empty()) { … … 967 967 968 968 int 969 CastBeam( 970 Beam &beam 971 ) 972 { 973 974 975 return 0; 976 } 969 KdTree::CastBeam( 970 Beam &beam 971 ) 972 { 973 stack<KdNode *> nodeStack; 974 nodeStack.push(mRoot); 975 976 while (!nodeStack.empty()) { 977 KdNode *node = nodeStack.top(); 978 nodeStack.pop(); 979 980 int side = beam.ComputeIntersection(GetBox(node)); 981 switch (side) { 982 case -1: 983 beam.mKdNodes.push_back(node); 984 break; 985 case 0: 986 if (node->IsLeaf()) 987 beam.mKdNodes.push_back(node); 988 else { 989 KdInterior *interior = (KdInterior *)node; 990 KdNode *first = interior->mBack; 991 KdNode *second = interior->mFront; 992 993 if (interior->mAxis < 3) { 994 // spatial split -> decide on the order of the nodes 995 if (beam.mPlanes[0].mNormal[interior->mAxis] > 0) 996 swap(first, second); 997 } 998 999 nodeStack.push(first); 1000 nodeStack.push(second); 1001 } 1002 break; 1003 // default: cull 1004 } 1005 } 1006 1007 return beam.mKdNodes.size(); 1008 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
r505 r507 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.0) on: pá 6. I 14:52:1920063 # Generated by qmake (2.00a) (Qt 4.1.0) on: so 7. I 10:49:27 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.cpp
r500 r507 2003 2003 return; 2004 2004 2005 2005 2006 int nrays = leaf->rays.size(); 2006 2007 … … 2008 2009 AxisAlignedBox3 box = GetBBox(leaf); 2009 2010 AxisAlignedBox3 dirBox = GetDirBBox(leaf); 2011 2010 2012 2011 2013 AxisAlignedBox3 sBox(box); -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h
r492 r507 22 22 #include "AxisAlignedBox3.h" 23 23 #include "Halton.h" 24 24 #include "beam.h" 25 25 26 26 #define USE_KDNODE_VECTORS 1 … … 419 419 420 420 HaltonSequence halton; 421 422 Beam mBeam; 421 423 422 424 RssTreeLeaf(RssTreeInterior *p, -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r504 r507 15 15 filename ../data/atlanta/atlanta2.x3d 16 16 # filename ../data/soda/soda.dat 17 #filename ../data/soda/soda5.dat17 filename ../data/soda/soda5.dat 18 18 } 19 19
Note: See TracChangeset
for help on using the changeset viewer.