Changeset 512 for trunk


Ignore:
Timestamp:
01/10/06 18:27:20 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj

    r510 r512  
    6262                        <Tool 
    6363                                Name="VCCLCompilerTool" 
    64                                 AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;..\src" 
     64                                AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;..\include;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;&quot;$(QTDIR)\include&quot;;&quot;$(QTDIR)\include\QtOpenGl&quot;;..\src;&quot;$(CG_INC_PATH)&quot;" 
    6565                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 
    6666                                RuntimeLibrary="2" 
     
    7676                        <Tool 
    7777                                Name="VCLinkerTool" 
    78                                 AdditionalDependencies="xerces-c_2.lib zdll.lib zziplib.lib devil.lib qtmain.lib QtOpenGL4.lib QtUiTools.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;&quot;$(QTDIR)\lib&quot;;..\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;&quot;$(QTDIR)\lib&quot;;..\include;..\src\GL;&quot;$(CG_LIB_PATH)&quot;"/> 
    8080                        <Tool 
    8181                                Name="VCMIDLTool"/> 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp

    r511 r512  
    55 
    66void 
    7 MyBeam::Construct(const  AxisAlignedBox3 &box, 
     7Beam::Construct(const  AxisAlignedBox3 &box, 
    88                                const  AxisAlignedBox3 &dBox) 
    99{ 
     
    5353 
    5454int 
    55 MyBeam::ComputeIntersection(const AxisAlignedBox3 &box) 
     55Beam::ComputeIntersection(const AxisAlignedBox3 &box) 
    5656{ 
    5757  int i; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h

    r511 r512  
    1010class Intersectable; 
    1111 
    12 class MyBeam { 
     12class Beam { 
    1313   
    1414public:                  
     
    4040  bool SetValid() { return mFlags |= VALID; } 
    4141 
    42   MyBeam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0) 
     42  Beam():mFlags(STORE_KD_NODES+STORE_OBJECTS), mKdNodes(0), mObjects(0) 
    4343  { 
    4444  } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r511 r512  
    66#include "Viewcell.h" 
    77#include "Beam.h" 
    8  
    98#include <GL/glext.h> 
     9#include <Cg/cg.h> 
     10#include <Cg/cgGL.h> 
     11 
     12static CGcontext sCgContext = NULL; 
     13static CGprogram sCgFragmentProgram = NULL; 
     14 
     15static CGparameter sCgKdParam = NULL; 
     16static CGparameter sCgModelViewProjParam = NULL; 
     17 
     18 
     19static CGprofile sCgFragmentProfile = CG_PROFILE_FP30; 
     20 
     21GLuint depthMap; 
     22const int depthMapSize = 512; 
    1023 
    1124GlRendererWidget *rendererWidget = NULL; 
     
    119132        wglGetProcAddress("glGetOcclusionQueryuivNV"); 
    120133 
    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); 
    131140  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
    132141  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
    133142  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 
    134143  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); 
    135153} 
    136154 
     
    547565 
    548566 
    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, 
     567void GlRendererBuffer::SampleBeamContributions(Intersectable *sourceObject, 
     568                                                                                           Beam &beam, 
    607569                                                                                           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 
     625void 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  
    1717class Intersectable; 
    1818class Material; 
    19 class MyBeam; 
     19class Beam; 
    2020 
    2121struct PvsRenderStatistics { 
     
    159159  void SampleBeamContributions( 
    160160                                                           Intersectable *sourceObject, 
    161                                                            MyBeam &beam, 
     161                                                           Beam &beam, 
    162162                                                           const int samples, 
    163163                                                           BeamSampleStatistics &stat 
     
    167167  SampleViewpointContributions( 
    168168                                                           Intersectable *sourceObject, 
    169                                                            MyBeam &beam, 
     169                                                           Beam &beam, 
    170170                                                           const int desiredSamples, 
    171171                                                           BeamSampleStatistics &stat 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp

    r511 r512  
    968968int 
    969969KdTree::CastBeam( 
    970                                  MyBeam &beam 
     970                                 Beam &beam 
    971971                                 ) 
    972972{ 
  • trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.h

    r511 r512  
    1616class Intersectable; 
    1717//class KdViewCell; 
    18 class MyBeam; 
     18class Beam; 
    1919 
    2020// -------------------------------------------------------------- 
     
    289289  int 
    290290  CastBeam( 
    291                    MyBeam &beam 
     291                   Beam &beam 
    292292                   ); 
    293293   
  • trunk/VUT/GtpVisibilityPreprocessor/src/RssTree.h

    r511 r512  
    420420  HaltonSequence halton; 
    421421 
    422   MyBeam mBeam; 
     422  Beam mBeam; 
    423423   
    424424  RssTreeLeaf(RssTreeInterior *p, 
Note: See TracChangeset for help on using the changeset viewer.