- Timestamp:
- 01/10/06 18:27:20 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r510 r512 62 62 <Tool 63 63 Name="VCCLCompilerTool" 64 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src "64 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";..\src;"$(CG_INC_PATH)"" 65 65 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 66 66 RuntimeLibrary="2" … … 76 76 <Tool 77 77 Name="VCLinkerTool" 78 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib Qt UiTools.lib QtCore4.lib QtDesigner4.lib QtGui4.lib QtAssistantClient.lib QtTest4.lib Qt3Supportd4.lib QAxContainer.lib QAxServerd.lib QtXml4.lib glut32.lib OpenGL32.Lib glu32.lib QAxServer.lib QtDesignerComponents4.lib"79 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL "/>78 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib QtCore4.lib QtGui4.lib Qt3Supportd4.lib QAxContainer.lib glut32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 79 AdditionalLibraryDirectories="..\support\xercesc\lib\;..\support\zlib\lib\;..\support\devil\lib;"$(QTDIR)\lib";..\include;..\src\GL;"$(CG_LIB_PATH)""/> 80 80 <Tool 81 81 Name="VCMIDLTool"/> -
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp
r511 r512 5 5 6 6 void 7 MyBeam::Construct(const AxisAlignedBox3 &box,7 Beam::Construct(const AxisAlignedBox3 &box, 8 8 const AxisAlignedBox3 &dBox) 9 9 { … … 53 53 54 54 int 55 MyBeam::ComputeIntersection(const AxisAlignedBox3 &box)55 Beam::ComputeIntersection(const AxisAlignedBox3 &box) 56 56 { 57 57 int i; -
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h
r511 r512 10 10 class Intersectable; 11 11 12 class MyBeam {12 class Beam { 13 13 14 14 public: … … 40 40 bool SetValid() { return mFlags |= VALID; } 41 41 42 MyBeam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0)42 Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0) 43 43 { 44 44 } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r511 r512 6 6 #include "Viewcell.h" 7 7 #include "Beam.h" 8 9 8 #include <GL/glext.h> 9 #include <Cg/cg.h> 10 #include <Cg/cgGL.h> 11 12 static CGcontext sCgContext = NULL; 13 static CGprogram sCgFragmentProgram = NULL; 14 15 static CGparameter sCgKdParam = NULL; 16 static CGparameter sCgModelViewProjParam = NULL; 17 18 19 static CGprofile sCgFragmentProfile = CG_PROFILE_FP30; 20 21 GLuint depthMap; 22 const int depthMapSize = 512; 10 23 11 24 GlRendererWidget *rendererWidget = NULL; … … 119 132 wglGetProcAddress("glGetOcclusionQueryuivNV"); 120 133 121 // second depth buffer texture 122 GLuint shadowMap; 123 const int shadowMapSize=512; 124 125 126 glGenTextures(1, &shadowMap); 127 glBindTexture(GL_TEXTURE_2D, shadowMap); 128 129 glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, shadowMapSize, 130 shadowMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); 134 // initialise second depth buffer texture 135 glGenTextures(1, &depthMap); 136 glBindTexture(GL_TEXTURE_2D, depthMap); 137 138 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, depthMapSize, 139 depthMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL); 131 140 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 132 141 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 133 142 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 134 143 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 144 145 // cg initialization 146 sCgContext = cgCreateContext(); 147 148 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext, 149 CG_SOURCE, "dual_depth.cg", 150 sCgFragmentProfile, 151 NULL, 152 NULL); 135 153 } 136 154 … … 547 565 548 566 549 void 550 GlRendererBuffer::SampleBeamContributions( 551 Intersectable *sourceObject, 552 MyBeam &beam, 553 const int desiredSamples, 554 BeamSampleStatistics &stat 555 ) 556 { 557 // assumes that the beam is constructed and contains kd-tree nodes 558 // and viewcells which it intersects 559 560 561 562 563 // Get the number of viewpoints to be sampled 564 // Now it is a sqrt but in general a wiser decision could be made. 565 // The less viewpoints the better for rendering performance, since less passes 566 // over the beam is needed. 567 // The viewpoints could actually be generated outside of the bounding box which 568 // would distribute the 'efective viewpoints' of the object surface and thus 569 // with a few viewpoints better sample the vipoint space.... 570 571 int viewPointSamples = sqrt((float)desiredSamples); 572 573 // the number of direction samples per pass is given by the number of viewpoints 574 int directionalSamples = desiredSamples/viewPointSamples; 575 int i; 576 for (i=0; i < viewPointSamples; i++) { 577 Vector3 viewPoint = beam.mBox.GetRandomPoint(); 578 // perhaps the viewpoint should be shifted back a little bit so that it always lies 579 // inside the source object 580 // 'ideally' the viewpoints would be distributed on the soureObject surface, but this 581 // would require more complicated sampling (perhaps hierarchical rejection sampling of 582 // the object surface is an option here - only the mesh faces which are inside the box 583 // are considered as candidates) 584 SampleViewpointContributions( 585 sourceObject, 586 beam, 587 directionalSamples, 588 stat 589 ); 590 } 591 592 593 // note: 594 // this routine would be called only if the number of desired samples is sufficiently 595 // large - for other rss tree cells the cpu based sampling is perhaps more efficient 596 // distributing the work between cpu and gpu would also allow us to place more sophisticated 597 // sample distributions (silhouette ones) using the cpu and the jittered once on the GPU 598 // in order that thios scheme is working well the gpu render buffer should run in a separate 599 // thread than the cpu sampler, which would not be such a big problem.... 600 } 601 602 603 void 604 GlRendererBuffer::SampleViewpointContributions( 605 Intersectable *sourceObject, 606 MyBeam &beam, 567 void GlRendererBuffer::SampleBeamContributions(Intersectable *sourceObject, 568 Beam &beam, 607 569 const int desiredSamples, 608 BeamSampleStatistics &stat 609 ) 610 { 611 // 1. setup the view port to match the desired samples 612 // 2. setup the projection matrix and view matrix to match the viewpoint + beam.mDirBox 613 614 // 3. reset z-buffer to 0 and render the source object for the beam using 615 // glDepthFunc(GL_GREATER) 616 // and glCullFace(Enabled) and glFrontFace(GL_CW) 617 // remember the ray origin depth buffer somewhere? 618 619 // 4. set back to normal rendering and clear the ray termination depth buffer 620 // 5. render all objects inside the beam using id based false color 621 // (objects can be compiled to a gl list now so that subsequent rendering for 622 // this beam is fast - the same hold for step 3) 623 624 625 // 6. Now we have a two depth buffers defining the ray origin and termination 626 // only rays which have non-zero entry in the origin buffer are valid since 627 // they realy start on the object surface (this can also be tagged by setting a 628 // stencil buffer bit at step 3) 629 630 // 7. Use occlusion queries for all viewcell meshes associated with the beam -> 631 // a fragment passes if the corresponding stencil fragment is set and its depth is 632 // between origin and termination buffer 633 634 // 8. The number of visible pixels is the number of sample rays which see the source 635 // object from the corresponding viewcell -> rember these values for later update 636 // of the viewcell pvs - or update immediatelly? 637 638 // In general it is not neccessary to rember to extract all the rays cast. I hope it 639 // would be sufficient to gain only the intergral statistics about the new contributions 640 // and so the rss tree would actually store no new rays (only the initial ones) 641 // the subdivision of the tree would only be driven by the statistics (the glrender could 642 // evaluate the contribution entropy for example) 643 // However might be an option to extract/store only those the rays which made a contribution 644 // (new viewcell has been discovered) or relative contribution greater than a threashold... 645 646 647 } 570 BeamSampleStatistics &stat) 571 { 572 // TODO: should be out of here 573 cgGLBindProgram(sCgFragmentProgram); 574 cgGLEnableProfile(sCgFragmentProfile); 575 576 // assumes that the beam is constructed and contains kd-tree nodes 577 // and viewcells which it intersects 578 579 580 581 582 // Get the number of viewpoints to be sampled 583 // Now it is a sqrt but in general a wiser decision could be made. 584 // The less viewpoints the better for rendering performance, since less passes 585 // over the beam is needed. 586 // The viewpoints could actually be generated outside of the bounding box which 587 // would distribute the 'efective viewpoints' of the object surface and thus 588 // with a few viewpoints better sample the vipoint space.... 589 590 int viewPointSamples = sqrt((float)desiredSamples); 591 592 // the number of direction samples per pass is given by the number of viewpoints 593 int directionalSamples = desiredSamples/viewPointSamples; 594 595 for (int i = 0; i < viewPointSamples; ++ i) 596 { 597 Vector3 viewPoint = beam.mBox.GetRandomPoint(); 598 599 // perhaps the viewpoint should be shifted back a little bit so that it always lies 600 // inside the source object 601 // 'ideally' the viewpoints would be distributed on the soureObject surface, but this 602 // would require more complicated sampling (perhaps hierarchical rejection sampling of 603 // the object surface is an option here - only the mesh faces which are inside the box 604 // are considered as candidates) 605 606 SampleViewpointContributions(sourceObject, 607 beam, 608 directionalSamples, 609 stat); 610 } 611 612 613 // note: 614 // this routine would be called only if the number of desired samples is sufficiently 615 // large - for other rss tree cells the cpu based sampling is perhaps more efficient 616 // distributing the work between cpu and gpu would also allow us to place more sophisticated 617 // sample distributions (silhouette ones) using the cpu and the jittered once on the GPU 618 // in order that thios scheme is working well the gpu render buffer should run in a separate 619 // thread than the cpu sampler, which would not be such a big problem.... 620 621 cgGLDisableProfile(sCgFragmentProfile); 622 } 623 624 625 void GlRendererBuffer::SampleViewpointContributions(Intersectable *sourceObject, 626 Beam &beam, 627 const int desiredSamples, 628 BeamSampleStatistics &stat) 629 { 630 // 1. setup the view port to match the desired samples 631 // 2. setup the projection matrix and view matrix to match the viewpoint + beam.mDirBox 632 633 // 3. reset z-buffer to 0 and render the source object for the beam using 634 // glDepthFunc(GL_GREATER) 635 // and glCullFace(Enabled) and glFrontFace(GL_CW) 636 // save result to depth buffer? 637 638 // bind ray origin depth buffer 639 glClear(GL_DEPTH); 640 glBindTexture(GL_TEXTURE_2D, depthMap); 641 glEnable(GL_TEXTURE_2D); 642 643 // compare with second depth buffer: should be done in pixel shader 644 /*glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); 645 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_GREATER); 646 glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY); 647 */ 648 649 650 // 4. set back to normal rendering and clear the ray termination depth buffer 651 // 5. render all objects inside the beam using id based false color 652 // (objects can be compiled to a gl list now so that subsequent rendering for 653 // this beam is fast - the same hold for step 3) 654 655 656 // 6. Now we have a two depth buffers defining the ray origin and termination 657 // only rays which have non-zero entry in the origin buffer are valid since 658 // they realy start on the object surface (this can also be tagged by setting a 659 // stencil buffer bit at step 3) 660 661 // 7. Use occlusion queries for all viewcell meshes associated with the beam -> 662 // a fragment passes if the corresponding stencil fragment is set and its depth is 663 // between origin and termination buffer 664 665 // 8. The number of visible pixels is the number of sample rays which see the source 666 // object from the corresponding viewcell -> rember these values for later update 667 // of the viewcell pvs - or update immediatelly? 668 669 // In general it is not neccessary to rember to extract all the rays cast. I hope it 670 // would be sufficient to gain only the intergral statistics about the new contributions 671 // and so the rss tree would actually store no new rays (only the initial ones) 672 // the subdivision of the tree would only be driven by the statistics (the glrender could 673 // evaluate the contribution entropy for example) 674 // However might be an option to extract/store only those the rays which made a contribution 675 // (new viewcell has been discovered) or relative contribution greater than a threashold ... 676 677 } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r511 r512 17 17 class Intersectable; 18 18 class Material; 19 class MyBeam;19 class Beam; 20 20 21 21 struct PvsRenderStatistics { … … 159 159 void SampleBeamContributions( 160 160 Intersectable *sourceObject, 161 MyBeam &beam,161 Beam &beam, 162 162 const int samples, 163 163 BeamSampleStatistics &stat … … 167 167 SampleViewpointContributions( 168 168 Intersectable *sourceObject, 169 MyBeam &beam,169 Beam &beam, 170 170 const int desiredSamples, 171 171 BeamSampleStatistics &stat -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r511 r512 968 968 int 969 969 KdTree::CastBeam( 970 MyBeam &beam970 Beam &beam 971 971 ) 972 972 { -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h
r511 r512 16 16 class Intersectable; 17 17 //class KdViewCell; 18 class MyBeam;18 class Beam; 19 19 20 20 // -------------------------------------------------------------- … … 289 289 int 290 290 CastBeam( 291 MyBeam &beam291 Beam &beam 292 292 ); 293 293 -
trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h
r511 r512 420 420 HaltonSequence halton; 421 421 422 MyBeam mBeam;422 Beam mBeam; 423 423 424 424 RssTreeLeaf(RssTreeInterior *p,
Note: See TracChangeset
for help on using the changeset viewer.