Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RPI::View Class Referencefinal

#include <View.h>

Public Types

enum  UsageFlags : uint32_t {
  UsageNone = 0u , UsageCamera = (1u << 0) , UsageShadow = (1u << 1) , UsageReflectiveCubeMap = (1u << 2) ,
  UsageXR = (1u << 3)
}
 

Public Member Functions

 AZ_TYPE_INFO (View, "{C3FFC8DE-83C4-4E29-8216-D55BE0ACE3E4}")
 
 AZ_CLASS_ALLOCATOR (View, AZ::SystemAllocator)
 
void SetDrawListMask (const RHI::DrawListMask &drawListMask)
 
RHI::DrawListMask GetDrawListMask () const
 
void Reset ()
 
RHI::ShaderResourceGroupGetRHIShaderResourceGroup () const
 
Data::Instance< RPI::ShaderResourceGroupGetShaderResourceGroup ()
 
void AddDrawPacket (const RHI::DrawPacket *drawPacket, float depth=0.0f)
 
void AddDrawPacket (const RHI::DrawPacket *drawPacket, const Vector3 &worldPosition)
 Similar to previous AddDrawPacket() but calculates depth from packet position.
 
void AddVisibleObject (const void *userData, float depth=0.0f)
 
void AddVisibleObject (const void *userData, const Vector3 &worldPosition)
 Similar to previous AddVisibleObject() but calculates depth from object position.
 
void AddDrawItem (RHI::DrawListTag drawListTag, const RHI::DrawItemProperties &drawItemProperties)
 Add a draw item to this view with its associated draw list tag.
 
void ApplyFlags (uint32_t flags)
 
void ClearFlags (uint32_t flags)
 Clears and resets the flag positions marked with flag. This means the 'and' flag is set to 1 and the 'or' flag is set to 0.
 
void ClearAllFlags ()
 Clears and resets all the flags. This effectively sets the and flags back to 0xFFFFFFFF and the or flags to 0x00000000;.
 
uint32_t GetAndFlags ()
 Returns the boolean & combination of all flags provided with ApplyFlags() since the last frame.
 
uint32_t GetOrFlags ()
 Returns the boolean | combination of all flags provided with ApplyFlags() since the last frame.
 
void SetWorldToViewMatrix (const AZ::Matrix4x4 &worldToView)
 Sets the worldToView matrix and recalculates the other matrices.
 
void SetCameraTransform (const AZ::Matrix3x4 &cameraTransform)
 Set the viewtoWorld matrix through camera's world transformation (z-up) and recalculates the other matrices.
 
void SetViewToClipMatrix (const AZ::Matrix4x4 &viewToClip)
 Sets the viewToClip matrix and recalculates the other matrices.
 
void SetViewToClipExcludeMatrix (const AZ::Matrix4x4 *viewToClipExclude)
 
void SetStereoscopicViewToClipMatrix (const AZ::Matrix4x4 &viewToClip, bool reverseDepth=true)
 Sets the viewToClip matrix and recalculates the other matrices for stereoscopic projection.
 
void SetClipSpaceOffset (float xOffset, float yOffset)
 Sets a pixel offset on the view, usually used for jittering the camera for anti-aliasing techniques.
 
const AZ::Matrix4x4 & GetWorldToViewMatrix () const
 
const AZ::Matrix4x4 & GetViewToWorldMatrix () const
 Use GetViewToWorldMatrix().GetTranslation() to get the camera's position.
 
const AZ::Matrix4x4 & GetViewToClipMatrix () const
 
const AZ::Matrix4x4 & GetWorldToClipMatrix () const
 
const AZ::Matrix4x4 * GetWorldToClipExcludeMatrix () const
 
const AZ::Matrix4x4 & GetClipToWorldMatrix () const
 
AZ::Matrix3x4 GetWorldToViewMatrixAsMatrix3x4 () const
 
AZ::Matrix3x4 GetViewToWorldMatrixAsMatrix3x4 () const
 
AZ::Transform GetCameraTransform () const
 Get the camera's world transform, converted from the viewToWorld matrix's native y-up to z-up.
 
void FinalizeVisibleObjectList ()
 
void FinalizeDrawListsJob (AZ::Job *parentJob)
 
void FinalizeDrawListsTG (AZ::TaskGraphEvent &finalizeDrawListsTGEvent)
 
bool HasDrawListTag (RHI::DrawListTag drawListTag)
 
RHI::DrawListView GetDrawList (RHI::DrawListTag drawListTag)
 
VisibleObjectListView GetVisibleObjectList ()
 
RHI::DrawItemSortKey GetSortKeyForPosition (const Vector3 &positionInWorld) const
 Helper function to generate a sort key from a given position in world.
 
float CalculateSphereAreaInClipSpace (const AZ::Vector3 &sphereWorldPosition, float sphereRadius) const
 
const AZ::Name & GetName () const
 
const UsageFlags GetUsageFlags ()
 
void SetPassesByDrawList (PassesByDrawList *passes)
 
void UpdateSrg ()
 Update View's SRG values and compile. This should only be called once per frame before execute command lists.
 
void ConnectWorldToViewMatrixChangedHandler (MatrixChangedEvent::Handler &handler)
 Notifies consumers when the world to view matrix has changed.
 
void ConnectWorldToClipMatrixChangedHandler (MatrixChangedEvent::Handler &handler)
 Notifies consumers when the world to clip matrix has changed.
 
void BeginCulling ()
 Prepare for view culling.
 
MaskedOcclusionCullingGetMaskedOcclusionCulling ()
 Returns the masked occlusion culling interface.
 
void OnAddToRenderPipeline ()
 This is called by RenderPipeline when this view is added to the pipeline.
 
void SetShadowPassRenderPipelineId (const RenderPipelineId renderPipelineId)
 Accessors for shadow pass render pipeline id.
 
RenderPipelineId GetShadowPassRenderPipelineId () const
 

Static Public Member Functions

static ViewPtr CreateView (const AZ::Name &name, UsageFlags usage)
 Only use this function to create a new view object. And force using smart pointer to manage view's life time.
 

Detailed Description

Represents a view into a scene, and is the primary interface for adding DrawPackets to the draw queues. It encapsulates the world<->view<->clip transforms and the per-view shader constants. Use View::CreateView() to make new vew Objects to ensure that you have a shared ViewPtr to pass around the code. There are different ways to setup the worldToView/viewToWorld matrices. Only one set function needs to be called: SetWorldToViewMatrix() SetCameraTransform() To have a fully formed set of view transforms you also need to call SetViewToClipMatrix() to set up the projection.

Member Function Documentation

◆ AddDrawPacket()

void AZ::RPI::View::AddDrawPacket ( const RHI::DrawPacket drawPacket,
float  depth = 0.0f 
)

Add a draw packet to this view. DrawPackets need to be added every frame. This function is thread safe. The depth value here is the depth of the object from the perspective of the view.

◆ AddVisibleObject()

void AZ::RPI::View::AddVisibleObject ( const void *  userData,
float  depth = 0.0f 
)

Similar to AddDrawPacket, but the view will not submit any draw items for rendering. It will just maintain a list of visible objects for the current frame, and the caller must get that list, reinterpret the userData, and submit the draw calls.

◆ ApplyFlags()

void AZ::RPI::View::ApplyFlags ( uint32_t  flags)

Applies some flags to the view that are reset each frame. The provided flags are combined with m_andFlags using &, and are combined with m_orFlags using |.

◆ CalculateSphereAreaInClipSpace()

float AZ::RPI::View::CalculateSphereAreaInClipSpace ( const AZ::Vector3 &  sphereWorldPosition,
float  sphereRadius 
) const

Returns the area of the given sphere projected into clip space in terms of percentage coverage of the viewport. Value returned is 1.0f when an area equal to the viewport height squared is covered. Useful for accurate LOD decisions.

◆ FinalizeDrawListsJob()

void AZ::RPI::View::FinalizeDrawListsJob ( AZ::Job *  parentJob)

Finalize draw lists in this view. This function should only be called when all draw packets for current frame are added.

◆ FinalizeVisibleObjectList()

void AZ::RPI::View::FinalizeVisibleObjectList ( )

Finalize visible object lists in this view. This function should only be called when all visible objects for current frame are added, but before FinalizeDrawLists is called.

◆ SetViewToClipExcludeMatrix()

void AZ::RPI::View::SetViewToClipExcludeMatrix ( const AZ::Matrix4x4 *  viewToClipExclude)

Sets the viewToClip exclusion matrix. This is used by culling to exclude items completely contained inside the exclusion frustum. Pass in nullptr to unset.


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