OGRE-Next  2.3
Object-Oriented Graphics Rendering Engine
Ogre::VctVoxelizer Class Reference

The voxelizer consists in several stages. More...

#include <OgreVctVoxelizer.h>

+ Inheritance diagram for Ogre::VctVoxelizer:

Public Types

enum  DebugVisualizationMode { DebugVisualizationAlbedo , DebugVisualizationNormal , DebugVisualizationEmissive , DebugVisualizationNone }
 

Public Member Functions

 VctVoxelizer (IdType id, RenderSystem *renderSystem, HlmsManager *hlmsManager, bool correctAreaLightShadows)
 
 ~VctVoxelizer ()
 
void _setNeedsAllMipmaps (bool bNeedsAllMipmaps)
 
void addItem (Item *item, bool bCompressed, uint32 indexCountSplit=0u)
 
void autoCalculateRegion ()
 Does nothing if VctVoxelizer::setRegionToVoxelize( false, ... ) was called. More...
 
void build (SceneManager *sceneManager)
 
void dividideOctants (uint32 numOctantsX, uint32 numOctantsY, uint32 numOctantsZ)
 
TextureGpugetAlbedoVox ()
 
VctVoxelizerSourceBase::DebugVisualizationMode getDebugVisualizationMode () const
 
TextureGpugetEmissiveVox ()
 
HlmsManagergetHlmsManager ()
 
IdType getId () const
 Get the unique id of this object. More...
 
TextureGpugetNormalVox ()
 
RenderSystemgetRenderSystem ()
 
TextureGpuManagergetTextureGpuManager ()
 
Vector3 getVoxelCellSize () const
 
Vector3 getVoxelOrigin () const
 
Vector3 getVoxelResolution () const
 
Vector3 getVoxelSize () const
 
bool operator() (const IdObject &left, const IdObject &right)
 
bool operator() (const IdObject *left, const IdObject *right)
 
void removeAllItems ()
 Removes all items added via VctVoxelizer::addItem. More...
 
void removeItem (Item *item)
 Removes an item added via VctVoxelizer::addItem. More...
 
void setDebugVisualization (VctVoxelizerSourceBase::DebugVisualizationMode mode, SceneManager *sceneManager)
 
void setRegionToVoxelize (bool autoRegion, const Aabb &regionToVoxelize, const Aabb &maxRegion=Aabb::BOX_INFINITE)
 Call this function before VctVoxelizer::autoCalculateRegion. More...
 
void setResolution (uint32 width, uint32 height, uint32 depth)
 Changes resolution. More...
 

Detailed Description

The voxelizer consists in several stages.

The main ones that requre explanation are:

  1. Download the vertex buffers to CPU, then upload it again to GPU in an homogeneous format our compute shader understands. We do the same with the index buffer, except we perform GPU -> GPU copies. We can't use the buffers directly because in many APIs we can't bind the index buffer as an UAV easily. This step is handled by VctVoxelizer::buildMeshBuffers. Not implemented yet: when rebuilding the voxelized scene, this step can be skipped if no meshes were added since the last change (and the buffers weren't freed to save memory)
  2. Iterate through every Item and convert the datablocks to the simplified version our compute shader uses. VctMaterial handles this; done in VctVoxelizer::placeItemsInBuckets.
  3. During step 2, we also group the items into buckets. Each bucket can be batched together to dispatch a single compute shader execution; because they share all the same settings (and we haven't run out of material buffer space)
  4. The items grouped in buckets may be split into 8 instance buffers; in order to cull each octant of the voxel; thus avoiding having all voxels try to check for all instances (performance optimization).

Member Enumeration Documentation

◆ DebugVisualizationMode

Enumerator
DebugVisualizationAlbedo 
DebugVisualizationNormal 
DebugVisualizationEmissive 
DebugVisualizationNone 

Constructor & Destructor Documentation

◆ VctVoxelizer()

Ogre::VctVoxelizer::VctVoxelizer ( IdType  id,
RenderSystem renderSystem,
HlmsManager hlmsManager,
bool  correctAreaLightShadows 
)

◆ ~VctVoxelizer()

Ogre::VctVoxelizer::~VctVoxelizer ( )

Member Function Documentation

◆ _setNeedsAllMipmaps()

void Ogre::VctVoxelizer::_setNeedsAllMipmaps ( bool  bNeedsAllMipmaps)
inline

◆ addItem()

void Ogre::VctVoxelizer::addItem ( Item item,
bool  bCompressed,
uint32  indexCountSplit = 0u 
)
Parameters
item
bCompressedTrue if we should compress: position to 16-bit SNORM normal to 16-bit SNORM uv as 16-bit Half False if we should use everything as 32-bit float If multiple Items using the same Mesh are added and one of them asks to not use compression, then not using compression takes precedence.
indexCountSplit0 to use mDefaultIndexCountSplit. Use a different value to override This value is ignored if the mesh had already been added.

Use std::numeric_limits<uint32>::max to avoid partitioning at all.

◆ autoCalculateRegion()

void Ogre::VctVoxelizer::autoCalculateRegion ( )

Does nothing if VctVoxelizer::setRegionToVoxelize( false, ... ) was called.

◆ build()

void Ogre::VctVoxelizer::build ( SceneManager sceneManager)

◆ dividideOctants()

void Ogre::VctVoxelizer::dividideOctants ( uint32  numOctantsX,
uint32  numOctantsY,
uint32  numOctantsZ 
)

◆ getAlbedoVox()

TextureGpu* Ogre::VctVoxelizerSourceBase::getAlbedoVox ( )
inlineinherited

◆ getDebugVisualizationMode()

VctVoxelizerSourceBase::DebugVisualizationMode Ogre::VctVoxelizerSourceBase::getDebugVisualizationMode ( ) const
inherited

◆ getEmissiveVox()

TextureGpu* Ogre::VctVoxelizerSourceBase::getEmissiveVox ( )
inlineinherited

◆ getHlmsManager()

HlmsManager* Ogre::VctVoxelizerSourceBase::getHlmsManager ( )
inherited

◆ getId()

IdType Ogre::IdObject::getId ( ) const
inlineinherited

Get the unique id of this object.

◆ getNormalVox()

TextureGpu* Ogre::VctVoxelizerSourceBase::getNormalVox ( )
inlineinherited

◆ getRenderSystem()

RenderSystem* Ogre::VctVoxelizerSourceBase::getRenderSystem ( )
inherited

◆ getTextureGpuManager()

TextureGpuManager* Ogre::VctVoxelizerSourceBase::getTextureGpuManager ( )
inherited

◆ getVoxelCellSize()

Vector3 Ogre::VctVoxelizerSourceBase::getVoxelCellSize ( ) const
inherited

◆ getVoxelOrigin()

Vector3 Ogre::VctVoxelizerSourceBase::getVoxelOrigin ( ) const
inherited

◆ getVoxelResolution()

Vector3 Ogre::VctVoxelizerSourceBase::getVoxelResolution ( ) const
inherited

◆ getVoxelSize()

Vector3 Ogre::VctVoxelizerSourceBase::getVoxelSize ( ) const
inherited

◆ operator()() [1/2]

bool Ogre::IdObject::operator() ( const IdObject left,
const IdObject right 
)
inlineinherited

◆ operator()() [2/2]

bool Ogre::IdObject::operator() ( const IdObject left,
const IdObject right 
)
inlineinherited

◆ removeAllItems()

void Ogre::VctVoxelizer::removeAllItems ( )

Removes all items added via VctVoxelizer::addItem.

◆ removeItem()

void Ogre::VctVoxelizer::removeItem ( Item item)

Removes an item added via VctVoxelizer::addItem.

Remarks
Once the last item that shares the same mesh is removed, the entry about that mesh is also removed. That means informations such as 'compressed' setting is forgot.

Will throw if Item is not found.

Parameters
itemItem to remove

◆ setDebugVisualization()

void Ogre::VctVoxelizerSourceBase::setDebugVisualization ( VctVoxelizerSourceBase::DebugVisualizationMode  mode,
SceneManager sceneManager 
)
inherited

◆ setRegionToVoxelize()

void Ogre::VctVoxelizer::setRegionToVoxelize ( bool  autoRegion,
const Aabb regionToVoxelize,
const Aabb maxRegion = Aabb::BOX_INFINITE 
)

Call this function before VctVoxelizer::autoCalculateRegion.

Parameters
autoRegionTrue to autocalculate region to cover all the added items False to use 'regionToVoxelize' instead
regionToVoxelizeWhen autoRegion = false, use this to manually provide the region When autoRegion = true, it is ignored as it will be overwritten by autoCalculateRegion
maxRegionMaximum size of the regions are allowed to cover (mostly useful when autoRegion = true)

◆ setResolution()

void Ogre::VctVoxelizer::setResolution ( uint32  width,
uint32  height,
uint32  depth 
)

Changes resolution.

Note that after calling this, you will need to call VctVoxelizer::build again, and VctLighting::build again.

Parameters
width
height
depth

The documentation for this class was generated from the following file: