Ignore:
Timestamp:
01/07/06 10:50:29 (19 years ago)
Author:
bittner
Message:

Preparation for hw based sampling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r504 r507  
    55#include "Pvs.h" 
    66#include "Viewcell.h" 
     7#include "Beam.cpp" 
    78 
    89#include <GL/glext.h> 
     
    529530   
    530531} 
     532 
     533 
     534void 
     535GlRendererBuffer::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 
     588void 
     589GlRendererBuffer::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} 
Note: See TracChangeset for help on using the changeset viewer.