| Support Forum G3D Web Page |
Sparse Voxel Octree: (compressed) 3D Analog of a GBuffer.
More...
Inherits G3D::ReferenceCountedObject.
Public Types | |
| typedef GBuffer::Field | Field |
| typedef GBuffer::Specification | Specification |
| CS_POSITION is used for octree-space position, so. More... | |
Public Member Functions | |
| void | bindReadUniformsFragmentBuffer (Args &args) const |
| void | bindWriteUniformsFragmentBuffer (Args &args) const |
| const Box & | bounds () const |
| Bounds on the elements that were voxelized, not on the octtree itself. More... | |
| void | build (RenderDevice *, bool multiPass=false, bool dummyPass=false, int curPass=0) |
| Build octree from fragment data. More... | |
| const shared_ptr< Camera > | camera () const |
| If null, there is no clipping frustum. More... | |
| void | clearFragmentCounter () |
| void | complete (RenderDevice *, const G3D::String &downSampleShader=G3D::String("SVO_downsampleValues.glc")) |
| Build the actual oct-tree. More... | |
| void | connectToShader (Args &args, Access access, int maxTreeDepth, int level) const |
| void | debugPrintIndexBuffer () |
| void | debugPrintRootIndexBuffer () |
| void | filter (RenderDevice *, const G3D::String &downSampleShader=G3D::String("SVO_downsampleValues.glc")) |
| Filter octree data. More... | |
| int | fineVoxelResolution () const |
| Number of voxels along each edge at the finest resolution. More... | |
| shared_ptr< Framebuffer > | framebuffer () const |
| The framebuffer bound during rendering by Surface::renderIntoSVO. More... | |
| shared_ptr< BufferTexture > | getChildIndexBuffer () |
| shared_ptr< GBuffer > | getGBuffer () |
| shared_ptr< BufferTexture > | getNeighborsIndexBuffer () |
| int | getNumSurfaceLayers () |
| size_t | getTopDenseTreeNumNodes (int depth=(6 - 1)) |
| shared_ptr< GBuffer > | getTopMipMapGBuffer () |
| void | init (RenderDevice *rd, size_t svoPoolSize, int maxTreeDepth, size_t fragmentPoolSize) |
| void | loadFromDisk (const std::string &fileName) |
| int | maxDepth () |
| const String & | name () const |
| void | postBuild (RenderDevice *) |
| void | preBuild (RenderDevice *, bool multiPass=false, bool dummyPass=false) |
| void | prepare (RenderDevice *rd, const shared_ptr< Camera > &camera, const Box &wsBounds, float timeOffset, float velocityStartTimeOffset, size_t svoPoolSize, int maxTreeDepth, size_t fragmentPoolSize) |
| Bind and clear the data structure. More... | |
| void | prepare (RenderDevice *rd, const shared_ptr< Camera > &camera, const Box &wsBounds, float timeOffset, float velocityStartTimeOffset) |
| void | printDebugBuild () |
| void | renderRaycasting (RenderDevice *rd, shared_ptr< Texture > m_colorBuffer0, int level, float raycastingConeFactor) |
| void | saveToDisk (const std::string &fileName) |
| void | setCurSvoId (int id) |
| void | setOrthogonalProjection (RenderDevice *rd) const |
| Bind the camera and projection matrices for generating the SVO. More... | |
| const Specification & | specification () const |
| CFrame | svoToWorldMatrix () const |
| void | visualizeFragments (RenderDevice *rd) const |
| Draw the raw fragments as points for debugging purposes. More... | |
| void | visualizeNodes (RenderDevice *rd, int level) const |
| float | voxelSideLength () const |
| Length of each side of a voxel. More... | |
| CFrame | worldToSVOMatrix () const |
| const String & | writeDeclarationsFragmentBuffer () const |
Static Public Member Functions | |
| static shared_ptr< SVO > | create (const Specification &spec=Specification(), const String &name="SVO", bool usebricks=false) |
| Requires a floating point WS_POSITION field. More... | |
Public Attributes | |
| size_t | m_levelsNumNodes [16+1] |
| Vector2 | projectionOffset |
| float | projectionScale |
Protected Member Functions | |
| SVO (const Specification &spec, const String &name, bool usebricks) | |
| void | connectOctreeToShader (Args &args, Access access, int maxTreeDepth, int level=-1) const |
| void | copyScaleVal (RenderDevice *rd, shared_ptr< BufferTexture > &srcBuffer, shared_ptr< BufferTexture > &dstBuffer, int srcIndex, int dstIndex, int mulFactor, int divFactor) |
| void | fillBuffer (shared_ptr< GLPixelTransferBuffer > buffer, uint numVal, uint val) |
| uint64 | getBufferGPUAddress (const shared_ptr< BufferTexture > &buff) const |
| void | updateDispatchIndirectBuffer (RenderDevice *rd, shared_ptr< BufferTexture > &dispatchIndirectBuffer, shared_ptr< BufferTexture > &startIndexBuffer, shared_ptr< BufferTexture > &endIndexBuffer, int startLevel, int endLevel, Vector2int32 workGroupSize) |
Static Protected Member Functions | |
| template<class T , class ... ArgTypes> | |
| static shared_ptr< T > | createShared (ArgTypes &&... args) |
| Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
| int | BUFFER_WIDTH |
| We pack all of the material data into 2D textures, which are really just 1D wrapped at this width. More... | |
| Box | m_bounds |
| int | m_brickBorderSize |
| int | m_brickNumLevels |
| Vector3int16 | m_brickRes |
| Vector3int16 | m_brickResWithBorder |
| shared_ptr< Camera > | m_camera |
| shared_ptr< BufferTexture > | m_childIndex |
| int | m_curSvoId |
| shared_ptr< BufferTexture > | m_dispatchIndirectBuffer |
| The arguments for an indirect compute call to process the m_fragmentBuffer. More... | |
| shared_ptr< BufferTexture > | m_dispatchIndirectLevelBuffer |
| The arguments for an indirect compute call to process the next level of a tree. More... | |
| shared_ptr< BufferTexture > | m_drawIndirectBuffer |
| The arguments for an indirect draw call to visualize the octree. More... | |
| shared_ptr< Framebuffer > | m_dummyFramebuffer |
| Used to force the fragment rasterization resolution. More... | |
| shared_ptr< GBuffer > | m_fragmentBuffer |
| Storage for voxel fragments produced by Surface::renderIntoSVO before the tree is built. More... | |
| shared_ptr< BufferTexture > | m_fragmentCount |
| Number of allocated elements in m_fragmentBuffer. More... | |
| shared_ptr< BufferTexture > | m_fragmentsDrawIndirectBuffer |
| The arguments for an indirect draw call to visualize the m_fragmentBuffer. More... | |
| size_t | m_fragVoxelMemSize |
| shared_ptr< GBuffer > | m_gbuffer |
| The underlying output is stored in a gbuffer. More... | |
| bool | m_initOK |
| shared_ptr< BufferTexture > | m_levelIndexBuffer |
| m_levelIndexBuffer[0] is the number of allocated nodes. More... | |
| shared_ptr< BufferTexture > | m_levelSizeBuffer |
| NEW: Allocated size for each mip level. More... | |
| shared_ptr< BufferTexture > | m_levelStartIndexBuffer |
| NEW: Offset for the allocation of each level. More... | |
| int | m_max2DTextureSize |
| int | m_max3DTextureSize |
| Vector3int32 | m_maxComputeGridDims |
| int | m_maxTreeDepth |
| const String | m_name |
| shared_ptr< BufferTexture > | m_neighborsIndex |
| shared_ptr< BufferTexture > | m_numberOfAllocatedNodes |
| The number of nodes already allocated in m_childIndex (NOT the index of the next node, which is this * 8) More... | |
| int | m_numSurfaceLayers |
| int | m_octreeBias |
| uint | m_octreePoolNumNodes |
| shared_ptr< BufferTexture > | m_parentIndex |
| shared_ptr< BufferTexture > | m_prevNodeCountBuffer |
| NEW. More... | |
| shared_ptr< Profiler > | m_profiler |
| Performance profiler. More... | |
| shared_ptr< BufferTexture > | m_rootIndex |
R32I pointers to children of nodes. More... | |
| const Specification | m_specification |
| size_t | m_svoVoxelMemSize |
| Sampler | m_textureSampler |
| float | m_timeOffset |
| shared_ptr< GBuffer > | m_topMipMapGBuffer |
| GBuffer containing octree top mipMAp. More... | |
| int | m_topMipMapMaxLevel |
| int | m_topMipMapNumLevels |
| int | m_topMipMapRes |
| bool | m_useBricks |
| bool | m_useNeighborPointers |
| bool | m_useTopMipMap |
| shared_ptr< Shader > | m_visualizeNodes |
| String | m_writeDeclarationsFragmentBuffer |
Sparse Voxel Octree: (compressed) 3D Analog of a GBuffer.
The algorithm operates in three passes:
The octree always fills a cube (it is sparse, so very little space is lost if the aspect ratio is more extreme)
| typedef GBuffer::Field G3D::SVO::Field |
CS_POSITION is used for octree-space position, so.
|
protected |
| void G3D::SVO::bindReadUniformsFragmentBuffer | ( | Args & | args | ) | const |
| void G3D::SVO::bindWriteUniformsFragmentBuffer | ( | Args & | args | ) | const |
|
inline |
Bounds on the elements that were voxelized, not on the octtree itself.
| void G3D::SVO::build | ( | RenderDevice * | , |
| bool | multiPass = false, |
||
| bool | dummyPass = false, |
||
| int | curPass = 0 |
||
| ) |
Build octree from fragment data.
Multipass mode require a dummy pre-pass in order to allocate per-level memory.
|
inline |
If null, there is no clipping frustum.
| void G3D::SVO::clearFragmentCounter | ( | ) |
| void G3D::SVO::complete | ( | RenderDevice * | , |
| const G3D::String & | downSampleShader = G3D::String("SVO_downsampleValues.glc") |
||
| ) |
Build the actual oct-tree.
Call after Surface::renderIntoSVO().
|
protected |
|
protected |
|
static |
Requires a floating point WS_POSITION field.
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
| void G3D::SVO::debugPrintIndexBuffer | ( | ) |
| void G3D::SVO::debugPrintRootIndexBuffer | ( | ) |
|
protected |
| void G3D::SVO::filter | ( | RenderDevice * | , |
| const G3D::String & | downSampleShader = G3D::String("SVO_downsampleValues.glc") |
||
| ) |
Filter octree data.
|
inline |
Number of voxels along each edge at the finest resolution.
Referenced by voxelSideLength().
|
inline |
The framebuffer bound during rendering by Surface::renderIntoSVO.
It is not actually rendered into, however
|
protected |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void G3D::SVO::init | ( | RenderDevice * | rd, |
| size_t | svoPoolSize, | ||
| int | maxTreeDepth, | ||
| size_t | fragmentPoolSize | ||
| ) |
| void G3D::SVO::loadFromDisk | ( | const std::string & | fileName | ) |
|
inline |
|
inline |
| void G3D::SVO::postBuild | ( | RenderDevice * | ) |
| void G3D::SVO::preBuild | ( | RenderDevice * | , |
| bool | multiPass = false, |
||
| bool | dummyPass = false |
||
| ) |
| void G3D::SVO::prepare | ( | RenderDevice * | rd, |
| const shared_ptr< Camera > & | camera, | ||
| const Box & | wsBounds, | ||
| float | timeOffset, | ||
| float | velocityStartTimeOffset, | ||
| size_t | svoPoolSize, | ||
| int | maxTreeDepth, | ||
| size_t | fragmentPoolSize | ||
| ) |
Bind and clear the data structure.
Call before Surface::renderIntoSVO()
| camera | The voxelization is clipped to the camera's frustum if the camera is non-null |
| wsBounds | The world-space bounds of the voxelization. For example, camera->frustum(viewport)->boundingBox(1000) |
| maxTreeDepth | |
| fragmentPoolSize | Maximum number of fragments expected from Surface::renderIntoSVO. Proportional to the area of the scene. There can be many fragments within a single voxel that will later be collapsed. |
| void G3D::SVO::prepare | ( | RenderDevice * | rd, |
| const shared_ptr< Camera > & | camera, | ||
| const Box & | wsBounds, | ||
| float | timeOffset, | ||
| float | velocityStartTimeOffset | ||
| ) |
| void G3D::SVO::printDebugBuild | ( | ) |
| void G3D::SVO::renderRaycasting | ( | RenderDevice * | rd, |
| shared_ptr< Texture > | m_colorBuffer0, | ||
| int | level, | ||
| float | raycastingConeFactor | ||
| ) |
| void G3D::SVO::saveToDisk | ( | const std::string & | fileName | ) |
|
inline |
| void G3D::SVO::setOrthogonalProjection | ( | RenderDevice * | rd | ) | const |
Bind the camera and projection matrices for generating the SVO.
Used by Surface::renderIntoSVO
|
inline |
| CFrame G3D::SVO::svoToWorldMatrix | ( | ) | const |
|
protected |
| void G3D::SVO::visualizeFragments | ( | RenderDevice * | rd | ) | const |
Draw the raw fragments as points for debugging purposes.
| void G3D::SVO::visualizeNodes | ( | RenderDevice * | rd, |
| int | level | ||
| ) | const |
|
inline |
Length of each side of a voxel.
| CFrame G3D::SVO::worldToSVOMatrix | ( | ) | const |
|
inline |
|
protected |
We pack all of the material data into 2D textures, which are really just 1D wrapped at this width.
|
protected |
Referenced by bounds(), and voxelSideLength().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by getChildIndexBuffer().
|
protected |
Referenced by setCurSvoId().
|
protected |
The arguments for an indirect compute call to process the m_fragmentBuffer.
|
protected |
The arguments for an indirect compute call to process the next level of a tree.
The fourth element is the number of threads desired.
|
protected |
The arguments for an indirect draw call to visualize the octree.
|
protected |
Used to force the fragment rasterization resolution.
Not actually written to.
Referenced by framebuffer().
|
protected |
Storage for voxel fragments produced by Surface::renderIntoSVO before the tree is built.
The size of this buffer is proportional to the surface area of the scene.
|
protected |
Number of allocated elements in m_fragmentBuffer.
|
protected |
The arguments for an indirect draw call to visualize the m_fragmentBuffer.
|
protected |
|
protected |
The underlying output is stored in a gbuffer.
Referenced by getGBuffer().
|
protected |
|
protected |
m_levelIndexBuffer[0] is the number of allocated nodes.
m_levelIndexBuffer[i] is the offset into m_childIndex of the first node for level (i - 1) of the tree.
|
protected |
NEW: Allocated size for each mip level.
| size_t G3D::SVO::m_levelsNumNodes[16+1] |
|
protected |
NEW: Offset for the allocation of each level.
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by fineVoxelResolution(), and maxDepth().
|
protected |
Referenced by getNeighborsIndexBuffer().
|
protected |
The number of nodes already allocated in m_childIndex (NOT the index of the next node, which is this * 8)
|
protected |
Referenced by getNumSurfaceLayers().
|
protected |
Referenced by fineVoxelResolution().
|
protected |
|
protected |
|
protected |
NEW.
|
protected |
Performance profiler.
|
protected |
R32I pointers to children of nodes.
Each node is a 2^3 block.
|
protected |
Referenced by specification().
|
protected |
|
protected |
|
protected |
|
protected |
GBuffer containing octree top mipMAp.
Referenced by getTopMipMapGBuffer().
|
protected |
Referenced by getTopDenseTreeNumNodes().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Referenced by writeDeclarationsFragmentBuffer().
| Vector2 G3D::SVO::projectionOffset |
| float G3D::SVO::projectionScale |
1.8.15