Open 3D Engine Atom Gem API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Public Types | Public Member Functions | Static Public Member Functions | List of all members
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) }
 

Public Member Functions

 AZ_TYPE_INFO (View, "{C3FFC8DE-83C4-4E29-8216-D55BE0ACE3E4}")
 
 AZ_CLASS_ALLOCATOR (View, AZ::SystemAllocator, 0)
 
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, Vector3 worldPosition)
 Similar to previous AddDrawPacket() but calculates depth from packet position.
 
void AddDrawItem (RHI::DrawListTag drawListTag, const RHI::DrawItemProperties &drawItemProperties)
 Add a draw item to this view with its associated draw list tag.
 
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 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 & 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 FinalizeDrawListsJob (AZ::Job *parentJob)
 
void FinalizeDrawListsTG (AZ::TaskGraphEvent &finalizeDrawListsTGEvent)
 
bool HasDrawListTag (RHI::DrawListTag drawListTag)
 
RHI::DrawListView GetDrawList (RHI::DrawListTag drawListTag)
 
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.
 
MaskedOcclusionCulling * GetMaskedOcclusionCulling ()
 Returns the masked occlusion culling interface.
 
void OnAddToRenderPipeline ()
 This is called by RenderPipeline when this view is added to the pipeline.
 

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.

◆ 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.


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