Cogs.Core
Static Public Member Functions | Public Attributes | List of all members
Cogs::Core::CameraArrayComponent Class Reference

Multi-view: Render a set of related views into array texture layers. More...

#include <CameraArrayComponent.h>

Inheritance diagram for Cogs::Core::CameraArrayComponent:
Cogs::ComponentModel::Component

Static Public Member Functions

static void registerType ()
 Register the type in the type system.
 
- Static Public Member Functions inherited from Cogs::ComponentModel::Component
static COGSFOUNDATION_API void registerType ()
 Register the Component type in the global type database.
 
static COGSFOUNDATION_API Reflection::TypeId getComponentTypeId (const StringView &name)
 Get the type id of the component type with the given name.
 

Public Attributes

WeakEntityPtr referenceCamera
 Reference camera to pull data from.
 
std::vector< TextureHandlecolorTextures
 The color render texture to output the rendered scene from the camera to.
 
std::vector< TextureHandledepthTextures
 The depth render texture to output the rendered scene from the camera to. Optional.
 
std::vector< glm::mat4 > projections
 One projection matrix per layer.
 
std::vector< glm::mat4 > transforms
 One affine transform matrix per layer.
 
uint32_t samples = 1
 Number of multi-sampling samples, a value of 0 or 1 implies no multi-sampling.
 
float overrideNearValue = 0.05f
 Near-value to use when overrideNearAndFar is enabled.
 
float overrideFarValue = 10.f
 Far-value to use when overrideNearAndFar is enabled.
 
float debugFrustumSqueeze = 0.f
 Debug variable to squeeze the frustum to be smaller than required, as a help to debug culling.
 
bool enableDepth = true
 Rendering should use a depth buffer, either backed by a provided texture or a buffer created by the renderer.
 
bool expectsSRGB = false
 Does the colorTexture expect values in sRGB color space.
 
bool updateReferenceCamera = true
 Update reference camera using the view projection and transform matrices.
 
bool moveCameraBack = true
 Find intersection of frustum edges and Z axis and back camera back, tries to minimize field-of-view of combined frustum.
 
bool updateNearAndFar = true
 When updating the reference camera, also update near and far.
 
bool overrideProjectionNearAndFar = false
 If true, override near and far values embedded in the provided projection matrix with overrideNearValue and overrideFarValue.
 
bool updateViewportResolution = true
 When updating the reference camera, use texture dimension to set camera viewport resolution.
 

Additional Inherited Members

- Public Member Functions inherited from Cogs::ComponentModel::Component
class EntitygetContainer () const
 Get the container currently owning this component instance.
 
void setContainer (class Entity *container)
 Set the container owning this component instance.
 
template<typename ComponentType >
ComponentType * getComponent () const
 
COGSFOUNDATION_API ComponentgetComponent (const Reflection::Name &name) const
 
COGSFOUNDATION_API ComponentgetComponent (const Reflection::TypeId &id) const
 
template<typename ComponentType >
ComponentHandle getComponentHandle () const
 
COGSFOUNDATION_API ComponentHandle getComponentHandle (const Reflection::Name &name) const
 
COGSFOUNDATION_API ComponentHandle getComponentHandle (const Reflection::TypeId &id) const
 
void setActive ()
 Sets the component to the ComponentFlags::Active state.
 
bool isActive () const
 Gets if the component is currently set to the ComponentFlags::Active state.
 
void setChanged ()
 Sets the component to the ComponentFlags::Changed state with carry.
 
void setChangedTransient ()
 Sets the component to the ComponentFlags::Changed state without carry.
 
void setFieldChanged (const Reflection::FieldId fieldId)
 Sets the component to the ComponentFlags::Changed state without carry.
 
template<typename ClassType , typename FieldType >
void setFieldChanged (FieldType ClassType::*field)
 Sets a flag indicating that the given field has changed.
 
void setFieldChangedTransient (const Reflection::FieldId fieldId)
 Sets the component to the ComponentFlags::Changed state without carry.
 
bool hasChanged () const
 
bool hasAnyfieldChanged () const
 Gets if any fields have been changed.
 
bool hasFieldChanged (const Reflection::FieldId fieldId) const
 Gets if the field with the given id on this component instance has changed.
 
template<typename ClassType , typename FieldType >
bool hasFieldChanged (FieldType ClassType::*field) const
 Gets if the given field has changed.
 
void resetCarryChanged ()
 Reset the CarryChanged flag. Called at start of redraw. See ComponentFlags::CarryChanged.
 
void resetChanged ()
 Resets the changed state of the component, respecting any carry state set.
 
template<typename ClassType , typename FieldType >
Reflection::FieldId getFieldId (FieldType ClassType::*field) const
 Gets field ID of the given field.
 
void resetFieldsChanged ()
 Resets the state of all changed field flags.
 
void resetFieldChanged (const Reflection::FieldId fieldId)
 Resets the changed state of the given fieldId.
 
template<typename ClassType , typename FieldType >
void resetFieldChanged (FieldType ClassType::*field)
 Resets the changed state of the given field.
 
constexpr void setFlags (const uint32_t flags)
 Override all flags of the Component, setting the given flags.
 
constexpr void setFlag (const uint32_t flag)
 Set the given flags. Does not override the currently set flags.
 
constexpr void unsetFlag (const uint32_t flag)
 Unset the given flag. Does not remove the status of other than the given flags.
 
constexpr bool isSet (const uint32_t flag) const
 Checks if the given flag is set. Requires exact bit match if test of several bits.
 
constexpr void setTypeId (const Reflection::TypeId typeId)
 Set the Reflection::TypeId of the component.
 
constexpr Reflection::TypeId getTypeId () const
 Get the Reflection::TypeId of the component.
 
COGSFOUNDATION_API const Reflection::TypegetType () const
 Get the full Reflection::Type of the component.
 
constexpr void setIndex (const ComponentIndex index)
 Set the components pool index. For internal use only.
 
constexpr ComponentIndex getIndex () const
 Get the components pool index. For internal use only.
 
constexpr void setGeneration (uint16_t generation)
 Sets the component generation.
 
constexpr uint16_t getGeneration () const
 Gets the component generation.
 
size_t hash (size_t hashValue=Cogs::hash()) const
 Calculates a hash of this component's members.
 

Detailed Description

Multi-view: Render a set of related views into array texture layers.

If the graphics device support multi-view rendering, a single draw sequence will render into all the layers. This avoids issuing all the draw commands for each eye in VR/AR rendering. If multi-view rendering is not available, the behaviour will be emulated behind the scene using multiple draw sequences.

For this to make sense, the views must be related, that is, it is sensible to use identical draw sequences. The referenceCamera represents the commonality between the views and will specify everything except the actual transforms, i.e. culling, render layers etc.

The colorTexture and depthTexture are the array textures that should be rendered into.

The views are specified with the matrices projections and transforms, which should have one element per layer. If updateReferenceCamera is enabled, the referenceCamera position and field of view will be updated so that it will contain the per-layer frusta specified by projections and transform.

The texture arrays should contain either a single Texture2DArray where the number of slices should match the number of views, or multiple Texture2D or RenderBuffer textures matching the number of views.

The transformComponent of the entity anchors the view transform matrices into world space, that is, the transform matrix of the transform component is applied to the provided matrices. That allows you to position and orient the reference space for the matrices within the virtual world space.

Definition at line 40 of file CameraArrayComponent.h.

Member Function Documentation

◆ registerType()

void Cogs::Core::CameraArrayComponent::registerType ( )
static

Member Data Documentation

◆ colorTextures

std::vector<TextureHandle> Cogs::Core::CameraArrayComponent::colorTextures

The color render texture to output the rendered scene from the camera to.

Definition at line 50 of file CameraArrayComponent.h.

Referenced by registerType().

◆ debugFrustumSqueeze

float Cogs::Core::CameraArrayComponent::debugFrustumSqueeze = 0.f

Debug variable to squeeze the frustum to be smaller than required, as a help to debug culling.

Definition at line 71 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ depthTextures

std::vector<TextureHandle> Cogs::Core::CameraArrayComponent::depthTextures

The depth render texture to output the rendered scene from the camera to. Optional.

Definition at line 53 of file CameraArrayComponent.h.

Referenced by registerType().

◆ enableDepth

bool Cogs::Core::CameraArrayComponent::enableDepth = true

Rendering should use a depth buffer, either backed by a provided texture or a buffer created by the renderer.

Definition at line 74 of file CameraArrayComponent.h.

Referenced by registerType().

◆ expectsSRGB

bool Cogs::Core::CameraArrayComponent::expectsSRGB = false

Does the colorTexture expect values in sRGB color space.

Definition at line 77 of file CameraArrayComponent.h.

Referenced by registerType().

◆ moveCameraBack

bool Cogs::Core::CameraArrayComponent::moveCameraBack = true

Find intersection of frustum edges and Z axis and back camera back, tries to minimize field-of-view of combined frustum.

Definition at line 83 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ overrideFarValue

float Cogs::Core::CameraArrayComponent::overrideFarValue = 10.f

Far-value to use when overrideNearAndFar is enabled.

Definition at line 68 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ overrideNearValue

float Cogs::Core::CameraArrayComponent::overrideNearValue = 0.05f

Near-value to use when overrideNearAndFar is enabled.

Definition at line 65 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ overrideProjectionNearAndFar

bool Cogs::Core::CameraArrayComponent::overrideProjectionNearAndFar = false

If true, override near and far values embedded in the provided projection matrix with overrideNearValue and overrideFarValue.

Definition at line 89 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ projections

std::vector<glm::mat4> Cogs::Core::CameraArrayComponent::projections

One projection matrix per layer.

Definition at line 56 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ referenceCamera

WeakEntityPtr Cogs::Core::CameraArrayComponent::referenceCamera

Reference camera to pull data from.

Definition at line 47 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ samples

uint32_t Cogs::Core::CameraArrayComponent::samples = 1

Number of multi-sampling samples, a value of 0 or 1 implies no multi-sampling.

Definition at line 62 of file CameraArrayComponent.h.

Referenced by registerType().

◆ transforms

std::vector<glm::mat4> Cogs::Core::CameraArrayComponent::transforms

One affine transform matrix per layer.

Definition at line 59 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ updateNearAndFar

bool Cogs::Core::CameraArrayComponent::updateNearAndFar = true

When updating the reference camera, also update near and far.

Definition at line 86 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ updateReferenceCamera

bool Cogs::Core::CameraArrayComponent::updateReferenceCamera = true

Update reference camera using the view projection and transform matrices.

Definition at line 80 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ updateViewportResolution

bool Cogs::Core::CameraArrayComponent::updateViewportResolution = true

When updating the reference camera, use texture dimension to set camera viewport resolution.

Definition at line 92 of file CameraArrayComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().


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