OGRE: Ogre::VctVoxelizer Class Reference

| OGRE 2.2.4 Object-Oriented Graphics Rendering Engine

Classes | Public Types | Public Member Functions | List of all members
Ogre::VctVoxelizer Class Reference

The voxelizer consists in several stages. More...

`#include <OgreVctVoxelizer.h>`

Inheritance diagram for Ogre::VctVoxelizer:
[legend]

## Public Types
enum | DebugVisualizationMode { DebugVisualizationAlbedo, DebugVisualizationNormal, DebugVisualizationEmissive, DebugVisualizationNone }

## Public Member Functions
| VctVoxelizer (IdType id, RenderSystem *renderSystem, HlmsManager *hlmsManager, bool correctAreaLightShadows)
| ~VctVoxelizer ()
void | addItem (Item *item, bool bCompressed, uint32 indexCountSplit=0u)
void | autoCalculateRegion (void)
| Does nothing if VctVoxelizer::setRegionToVoxelize( false, ... ) was called. More...
void | build (SceneManager *sceneManager)
void | dividideOctants (uint32 numOctantsX, uint32 numOctantsY, uint32 numOctantsZ)
TextureGpu * | getAlbedoVox (void)
VctVoxelizer::DebugVisualizationMode | getDebugVisualizationMode (void) const
TextureGpu * | getEmissiveVox (void)
HlmsManager * | getHlmsManager (void)
IdType | getId () const
| Get the unique id of this object. More...
TextureGpu * | getNormalVox (void)
RenderSystem * | getRenderSystem (void)
TextureGpuManager * | getTextureGpuManager (void)
Vector3 | getVoxelCellSize (void) const
Vector3 | getVoxelOrigin (void) const
Vector3 | getVoxelResolution (void) const
Vector3 | getVoxelSize (void) const
bool | operator() (const IdObject &left, const IdObject &right)
bool | operator() (const IdObject *left, const IdObject *right)
void | removeAllItems (void)
| Removes all items added via VctVoxelizer::addItem. More...
void | removeItem (Item *item)
| Removes an item added via VctVoxelizer::addItem. More...
void | setDebugVisualization (VctVoxelizer::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

enum Ogre::VctVoxelizer::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

## ◆ addItem()

void Ogre::VctVoxelizer::addItem | ( | Item * | item,
|  | bool | bCompressed,
|  | uint32 | indexCountSplit = `0u`
| ) |  |

Parameters

  item |
  bCompressed | True 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.
  indexCountSplit | 0 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 | ( | void |  | ) |

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::VctVoxelizer::getAlbedoVox | ( | void |  | ) |
| inline

## ◆ getDebugVisualizationMode()

VctVoxelizer::DebugVisualizationMode Ogre::VctVoxelizer::getDebugVisualizationMode | ( | void |  | ) | const

## ◆ getEmissiveVox()

TextureGpu* Ogre::VctVoxelizer::getEmissiveVox | ( | void |  | ) |
| inline

## ◆ getHlmsManager()

HlmsManager* Ogre::VctVoxelizer::getHlmsManager | ( | void |  | ) |

## ◆ getId()

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

Get the unique id of this object.

## ◆ getNormalVox()

TextureGpu* Ogre::VctVoxelizer::getNormalVox | ( | void |  | ) |
| inline

## ◆ getRenderSystem()

RenderSystem* Ogre::VctVoxelizer::getRenderSystem | ( | void |  | ) |

## ◆ getTextureGpuManager()

TextureGpuManager* Ogre::VctVoxelizer::getTextureGpuManager | ( | void |  | ) |

## ◆ getVoxelCellSize()

Vector3 Ogre::VctVoxelizer::getVoxelCellSize | ( | void |  | ) | const

## ◆ getVoxelOrigin()

Vector3 Ogre::VctVoxelizer::getVoxelOrigin | ( | void |  | ) | const

## ◆ getVoxelResolution()

Vector3 Ogre::VctVoxelizer::getVoxelResolution | ( | void |  | ) | const

## ◆ getVoxelSize()

Vector3 Ogre::VctVoxelizer::getVoxelSize | ( | void |  | ) | const

## ◆ 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 | ( | void |  | ) |

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

  item | Item to remove

## ◆ setDebugVisualization()

void Ogre::VctVoxelizer::setDebugVisualization | ( | VctVoxelizer::DebugVisualizationMode | mode,
|  | SceneManager * | sceneManager
| ) |  |

## ◆ setRegionToVoxelize()

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

Call this function before VctVoxelizer::autoCalculateRegion.

Parameters

  autoRegion | True to autocalculate region to cover all the added items False to use 'regionToVoxelize' instead
  regionToVoxelize | When autoRegion = false, use this to manually provide the region When autoRegion = true, it is ignored as it will be overwritten by autoCalculateRegion
  maxRegion | Maximum 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:

- OgreVctVoxelizer.h