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

This feature processor handles static and dynamic non-skinned meshes. More...

#include <MeshFeatureProcessor.h>

Inherits AZ::Render::MeshFeatureProcessorInterface.

Public Types

using FlagRegistry = RHI::TagBitRegistry< RPI::Cullable::FlagType >
 
- Public Types inherited from AZ::Render::MeshFeatureProcessorInterface
using MeshHandle = StableDynamicArrayHandle< ModelDataInstanceInterface >
 
using DispatchArgumentsSetupCB = AZStd::function< void(uint32_t, uint32_t, uint32_t, const RHI::DrawItem *, RHI::DispatchDirect &)>
 

Public Member Functions

 AZ_RTTI (AZ::Render::MeshFeatureProcessor, "{6E3DFA1D-22C7-4738-A3AE-1E10AB88B29B}", AZ::Render::MeshFeatureProcessorInterface)
 
 AZ_CONSOLEFUNC (MeshFeatureProcessor, ReportShaderOptionFlags, AZ::ConsoleFunctorFlags::Null, "Report currently used shader option flags.")
 
void Activate () override
 Creates pools, buffers, and buffer views.
 
void Deactivate () override
 Releases GPU resources.
 
void Simulate (const FeatureProcessor::SimulatePacket &packet) override
 Updates GPU buffers with latest data from render proxies.
 
void OnEndCulling (const RenderPacket &packet) override
 Updates ViewSrgs with per-view instance data for visible instances.
 
void OnBeginPrepareRender () override
 
void OnEndPrepareRender () override
 
TransformServiceFeatureProcessorInterface::ObjectId GetObjectId (const MeshHandle &meshHandle) const override
 Returns the object id for a mesh handle.
 
MeshHandle AcquireMesh (const MeshHandleDescriptor &descriptor) override
 Acquire a mesh handle for a model configured using the descriptor.
 
bool ReleaseMesh (MeshHandle &meshHandle) override
 Releases the mesh handle.
 
MeshHandle CloneMesh (const MeshHandle &meshHandle) override
 Creates a new instance and handle of a mesh using an existing MeshId. Currently, this will reset the new mesh to default materials.
 
void PrintDrawPacketInfo (const MeshHandle &meshHandle) override
 Print out info about the mesh draw packet.
 
void SetDrawItemEnabled (const MeshHandle &meshHandle, RHI::DrawListTag drawListTag, bool enabled) override
 Enables/Disables the mesh's DrawItem for the given drawListTag.
 
Data::Instance< RPI::ModelGetModel (const MeshHandle &meshHandle) const override
 Gets the underlying RPI::Model instance for a meshHandle. May be null if the model has not loaded.
 
Data::Asset< RPI::ModelAssetGetModelAsset (const MeshHandle &meshHandle) const override
 Gets the underlying RPI::ModelAsset for a meshHandle.
 
const RPI::MeshDrawPacketLods & GetDrawPackets (const MeshHandle &meshHandle) const override
 
const AZStd::vector< Data::Instance< RPI::ShaderResourceGroup > > & GetObjectSrgs (const MeshHandle &meshHandle) const override
 
void QueueObjectSrgForCompile (const MeshHandle &meshHandle) const override
 Queues the object srg for compile.
 
void SetCustomMaterials (const MeshHandle &meshHandle, const Data::Instance< RPI::Material > &material) override
 
void SetCustomMaterials (const MeshHandle &meshHandle, const CustomMaterialMap &materials) override
 Sets the CustomMaterialMap for a meshHandle.
 
const CustomMaterialMap & GetCustomMaterials (const MeshHandle &meshHandle) const override
 Gets the CustomMaterialMap for a meshHandle.
 
AZStd::unique_ptr< StreamBufferViewsBuilderInterfaceCreateStreamBufferViewsBuilder (const MeshHandle &meshHandle) const override
 
DispatchDrawItemList BuildDispatchDrawItemList (const MeshHandle &meshHandle, const uint32_t lodIndex, const uint32_t meshIndex, const RHI::DrawListMask drawListTagsFilter, const RHI::DrawFilterMask materialPipelineFilter, DispatchArgumentsSetupCB dispatchArgumentsSetupCB) const override
 
void SetTransform (const MeshHandle &meshHandle, const AZ::Transform &transform, const AZ::Vector3 &nonUniformScale=AZ::Vector3::CreateOne()) override
 
Transform GetTransform (const MeshHandle &meshHandle) override
 Gets the transform for a given mesh handle.
 
Vector3 GetNonUniformScale (const MeshHandle &meshHandle) override
 Gets the non-uniform scale for a given mesh handle.
 
void SetLocalAabb (const MeshHandle &meshHandle, const AZ::Aabb &localAabb) override
 Sets the local space bbox for a given mesh handle. You don't need to call this for static models, only skinned/animated models.
 
AZ::Aabb GetLocalAabb (const MeshHandle &meshHandle) const override
 Gets the local space bbox for a given mesh handle. Unless SetLocalAabb has been called before, this will be the bbox of the model asset.
 
void SetSortKey (const MeshHandle &meshHandle, RHI::DrawItemSortKey sortKey) override
 Sets the sort key for a given mesh handle.
 
RHI::DrawItemSortKey GetSortKey (const MeshHandle &meshHandle) const override
 Gets the sort key for a given mesh handle.
 
void SetLightingChannelMask (const MeshHandle &meshHandle, uint32_t lightingChannelMask) override
 Sets the lighting channel mask for a given mesh handle.
 
uint32_t GetLightingChannelMask (const MeshHandle &meshHandle) const override
 Gets the lighting channel mask for a given mesh handle.
 
void SetMeshLodConfiguration (const MeshHandle &meshHandle, const RPI::Cullable::LodConfiguration &meshLodConfig) override
 Sets LOD mesh configurations to be used in the Mesh Feature Processor.
 
RPI::Cullable::LodConfiguration GetMeshLodConfiguration (const MeshHandle &meshHandle) const override
 Gets the LOD mesh configurations being used in the Mesh Feature Processor.
 
void SetExcludeFromReflectionCubeMaps (const MeshHandle &meshHandle, bool excludeFromReflectionCubeMaps) override
 Sets the option to exclude this mesh from baked reflection probe cubemaps.
 
bool GetExcludeFromReflectionCubeMaps (const MeshHandle &meshHandle) const override
 Gets the if this mesh is excluded from baked reflection probe cubemaps.
 
void SetIsAlwaysDynamic (const MeshHandle &meshHandle, bool isAlwaysDynamic) override
 Sets a mesh to be considered to be always moving even if the transform hasn't changed. This is useful for meshes that are skinned or have vertex animation.
 
bool GetIsAlwaysDynamic (const MeshHandle &meshHandle) const override
 Gets if a mesh is considered to always be moving.
 
void SetRayTracingEnabled (const MeshHandle &meshHandle, bool enabled) override
 Sets the option to exclude this mesh from raytracing.
 
bool GetRayTracingEnabled (const MeshHandle &meshHandle) const override
 Gets whether this mesh is excluded from raytracing.
 
void SetVisible (const MeshHandle &meshHandle, bool visible) override
 Sets the mesh as visible or hidden. When the mesh is hidden it will not be rendered by the feature processor.
 
bool GetVisible (const MeshHandle &meshHandle) const override
 
void SetUseForwardPassIblSpecular (const MeshHandle &meshHandle, bool useForwardPassIblSpecular) override
 Sets the mesh to render IBL specular in the forward pass.
 
void SetRayTracingDirty (const MeshHandle &meshHandle) override
 Set a flag that the ray tracing data needs to be updated, usually after material changes.
 
RHI::Ptr< FlagRegistryGetShaderOptionFlagRegistry ()
 
void UpdateMeshReflectionProbes ()
 
void ReportShaderOptionFlags (const AZ::ConsoleCommandContainer &arguments)
 
RayTracingFeatureProcessorGetRayTracingFeatureProcessor () const
 
ReflectionProbeFeatureProcessorGetReflectionProbeFeatureProcessor () const
 
TransformServiceFeatureProcessorGetTransformServiceFeatureProcessor () const
 
RHI::DrawListTag GetTransparentDrawListTag () const
 
MeshInstanceManagerGetMeshInstanceManager ()
 
bool IsMeshInstancingEnabled () const
 
- Public Member Functions inherited from AZ::Render::MeshFeatureProcessorInterface
 AZ_RTTI (AZ::Render::MeshFeatureProcessorInterface, "{975D7F0C-2E7E-4819-94D0-D3C4E2024721}", AZ::RPI::FeatureProcessor)
 
virtual void SetTransform (const MeshHandle &meshHandle, const Transform &transform, const Vector3 &nonUniformScale=Vector3::CreateOne())=0
 Sets the transform for a given mesh handle.
 
- Public Member Functions inherited from AZ::RPI::FeatureProcessor
 AZ_RTTI (FeatureProcessor, "{B8027170-C65C-4237-964D-B557FC9D7575}")
 
 AZ_CLASS_ALLOCATOR (FeatureProcessor, AZ::SystemAllocator)
 
SceneGetParentScene () const
 
virtual void ApplyRenderPipelineChange (RenderPipeline *pipeline)
 
virtual void AddRenderPasses (RenderPipeline *pipeline)
 
virtual void PrepareViews (const PrepareViewsPacket &, AZStd::vector< AZStd::pair< PipelineViewTag, ViewPtr > > &)
 
virtual void Simulate (const SimulatePacket &)
 
virtual void Render (const RenderPacket &)
 
virtual void OnRenderEnd ()
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Additional Inherited Members

- Protected Member Functions inherited from AZ::RPI::FeatureProcessor
void EnableSceneNotification ()
 
void DisableSceneNotification ()
 

Detailed Description

This feature processor handles static and dynamic non-skinned meshes.

Member Function Documentation

◆ AcquireMesh()

MeshHandle AZ::Render::MeshFeatureProcessor::AcquireMesh ( const MeshHandleDescriptor descriptor)
overridevirtual

Acquire a mesh handle for a model configured using the descriptor.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ Activate()

void AZ::Render::MeshFeatureProcessor::Activate ( )
overridevirtual

Creates pools, buffers, and buffer views.

Reimplemented from AZ::RPI::FeatureProcessor.

◆ BuildDispatchDrawItemList()

DispatchDrawItemList AZ::Render::MeshFeatureProcessor::BuildDispatchDrawItemList ( const MeshHandle meshHandle,
const uint32_t  lodIndex,
const uint32_t  meshIndex,
const RHI::DrawListMask  drawListTagsFilter,
const RHI::DrawFilterMask  materialPipelineFilter,
DispatchArgumentsSetupCB  dispatchArgumentsSetupCB 
) const
overridevirtual

DisptachItems will be created for the DrawItems that match both the @drawListTagsFilter and @materialPipelineFilter. Also, only DrawItems whose PipelineState is of Compute type will be considered.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ CloneMesh()

MeshHandle AZ::Render::MeshFeatureProcessor::CloneMesh ( const MeshHandle meshHandle)
overridevirtual

Creates a new instance and handle of a mesh using an existing MeshId. Currently, this will reset the new mesh to default materials.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ CreateStreamBufferViewsBuilder()

AZStd::unique_ptr< StreamBufferViewsBuilderInterface > AZ::Render::MeshFeatureProcessor::CreateStreamBufferViewsBuilder ( const MeshHandle meshHandle) const
overridevirtual

A helper function, typically called by another FeatureProcessor, when Compute or RayTracing shaders need to bind Mesh Input Streams like "POSITION", "NORMAL", "UV1" etc as regular AZ::RHI::BufferViews. This function instantiates a concrete Builder-like object that helps creating the RHI::BufferViews.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ Deactivate()

void AZ::Render::MeshFeatureProcessor::Deactivate ( )
overridevirtual

Releases GPU resources.

Reimplemented from AZ::RPI::FeatureProcessor.

◆ GetCustomMaterials()

const CustomMaterialMap & AZ::Render::MeshFeatureProcessor::GetCustomMaterials ( const MeshHandle meshHandle) const
overridevirtual

Gets the CustomMaterialMap for a meshHandle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetDrawPackets()

const RPI::MeshDrawPacketLods & AZ::Render::MeshFeatureProcessor::GetDrawPackets ( const MeshHandle meshHandle) const
overridevirtual

This function provides insight into what materials, shaders, etc. are actively being used to render the model. Useful for custom feature processors that work in tandem with the MeshFeatureProcessor.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetExcludeFromReflectionCubeMaps()

bool AZ::Render::MeshFeatureProcessor::GetExcludeFromReflectionCubeMaps ( const MeshHandle meshHandle) const
overridevirtual

Gets the if this mesh is excluded from baked reflection probe cubemaps.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetIsAlwaysDynamic()

bool AZ::Render::MeshFeatureProcessor::GetIsAlwaysDynamic ( const MeshHandle meshHandle) const
overridevirtual

Gets if a mesh is considered to always be moving.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetLightingChannelMask()

uint32_t AZ::Render::MeshFeatureProcessor::GetLightingChannelMask ( const MeshHandle meshHandle) const
overridevirtual

Gets the lighting channel mask for a given mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetLocalAabb()

AZ::Aabb AZ::Render::MeshFeatureProcessor::GetLocalAabb ( const MeshHandle meshHandle) const
overridevirtual

Gets the local space bbox for a given mesh handle. Unless SetLocalAabb has been called before, this will be the bbox of the model asset.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetMeshLodConfiguration()

RPI::Cullable::LodConfiguration AZ::Render::MeshFeatureProcessor::GetMeshLodConfiguration ( const MeshHandle meshHandle) const
overridevirtual

Gets the LOD mesh configurations being used in the Mesh Feature Processor.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetModel()

Data::Instance< RPI::Model > AZ::Render::MeshFeatureProcessor::GetModel ( const MeshHandle meshHandle) const
overridevirtual

Gets the underlying RPI::Model instance for a meshHandle. May be null if the model has not loaded.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetModelAsset()

Data::Asset< RPI::ModelAsset > AZ::Render::MeshFeatureProcessor::GetModelAsset ( const MeshHandle meshHandle) const
overridevirtual

Gets the underlying RPI::ModelAsset for a meshHandle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetNonUniformScale()

Vector3 AZ::Render::MeshFeatureProcessor::GetNonUniformScale ( const MeshHandle meshHandle)
overridevirtual

Gets the non-uniform scale for a given mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetObjectId()

TransformServiceFeatureProcessorInterface::ObjectId AZ::Render::MeshFeatureProcessor::GetObjectId ( const MeshHandle meshHandle) const
overridevirtual

Returns the object id for a mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetObjectSrgs()

const AZStd::vector< Data::Instance< RPI::ShaderResourceGroup > > & AZ::Render::MeshFeatureProcessor::GetObjectSrgs ( const MeshHandle meshHandle) const
overridevirtual

Gets the ObjectSrgs for a meshHandle. Updating the ObjectSrgs should be followed by a call to QueueObjectSrgForCompile, instead of compiling the srgs directly. This way, if the srgs have already been queued for compile, they will not be queued twice in the same frame. The ObjectSrgs should not be updated during Simulate, or it will create a race between updating the data and the call to Compile Cases where there may be multiple ObjectSrgs: if a model has multiple submeshes and those submeshes use different materials with different object SRGs.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetRayTracingEnabled()

bool AZ::Render::MeshFeatureProcessor::GetRayTracingEnabled ( const MeshHandle meshHandle) const
overridevirtual

Gets whether this mesh is excluded from raytracing.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetSortKey()

RHI::DrawItemSortKey AZ::Render::MeshFeatureProcessor::GetSortKey ( const MeshHandle meshHandle) const
overridevirtual

Gets the sort key for a given mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetTransform()

Transform AZ::Render::MeshFeatureProcessor::GetTransform ( const MeshHandle meshHandle)
overridevirtual

Gets the transform for a given mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ GetVisible()

bool AZ::Render::MeshFeatureProcessor::GetVisible ( const MeshHandle meshHandle) const
overridevirtual

Returns the visibility state of the mesh. This only refers to whether or not the mesh has been explicitly hidden, and is not related to view frustum visibility.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ OnEndCulling()

void AZ::Render::MeshFeatureProcessor::OnEndCulling ( const RenderPacket packet)
overridevirtual

Updates ViewSrgs with per-view instance data for visible instances.

Reimplemented from AZ::RPI::FeatureProcessor.

◆ PrintDrawPacketInfo()

void AZ::Render::MeshFeatureProcessor::PrintDrawPacketInfo ( const MeshHandle meshHandle)
overridevirtual

Print out info about the mesh draw packet.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ QueueObjectSrgForCompile()

void AZ::Render::MeshFeatureProcessor::QueueObjectSrgForCompile ( const MeshHandle meshHandle) const
overridevirtual

Queues the object srg for compile.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ ReleaseMesh()

bool AZ::Render::MeshFeatureProcessor::ReleaseMesh ( MeshHandle meshHandle)
overridevirtual

Releases the mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetCustomMaterials() [1/2]

void AZ::Render::MeshFeatureProcessor::SetCustomMaterials ( const MeshHandle meshHandle,
const CustomMaterialMap &  materials 
)
overridevirtual

Sets the CustomMaterialMap for a meshHandle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetCustomMaterials() [2/2]

void AZ::Render::MeshFeatureProcessor::SetCustomMaterials ( const MeshHandle meshHandle,
const Data::Instance< RPI::Material > &  material 
)
overridevirtual

Sets the CustomMaterialMap for a meshHandle, using just a single material for the DefaultCustomMaterialId. Note if there is already a CustomMaterialMap, this will replace the entire map with just a single material.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetDrawItemEnabled()

void AZ::Render::MeshFeatureProcessor::SetDrawItemEnabled ( const MeshHandle meshHandle,
RHI::DrawListTag  drawListTag,
bool  enabled 
)
overridevirtual

Enables/Disables the mesh's DrawItem for the given drawListTag.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetExcludeFromReflectionCubeMaps()

void AZ::Render::MeshFeatureProcessor::SetExcludeFromReflectionCubeMaps ( const MeshHandle meshHandle,
bool  excludeFromReflectionCubeMaps 
)
overridevirtual

Sets the option to exclude this mesh from baked reflection probe cubemaps.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetIsAlwaysDynamic()

void AZ::Render::MeshFeatureProcessor::SetIsAlwaysDynamic ( const MeshHandle meshHandle,
bool  isAlwaysDynamic 
)
overridevirtual

Sets a mesh to be considered to be always moving even if the transform hasn't changed. This is useful for meshes that are skinned or have vertex animation.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetLightingChannelMask()

void AZ::Render::MeshFeatureProcessor::SetLightingChannelMask ( const MeshHandle meshHandle,
uint32_t  lightingChannelMask 
)
overridevirtual

Sets the lighting channel mask for a given mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetLocalAabb()

void AZ::Render::MeshFeatureProcessor::SetLocalAabb ( const MeshHandle meshHandle,
const AZ::Aabb &  localAabb 
)
overridevirtual

Sets the local space bbox for a given mesh handle. You don't need to call this for static models, only skinned/animated models.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetMeshLodConfiguration()

void AZ::Render::MeshFeatureProcessor::SetMeshLodConfiguration ( const MeshHandle meshHandle,
const RPI::Cullable::LodConfiguration meshLodConfig 
)
overridevirtual

Sets LOD mesh configurations to be used in the Mesh Feature Processor.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetRayTracingDirty()

void AZ::Render::MeshFeatureProcessor::SetRayTracingDirty ( const MeshHandle meshHandle)
overridevirtual

Set a flag that the ray tracing data needs to be updated, usually after material changes.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetRayTracingEnabled()

void AZ::Render::MeshFeatureProcessor::SetRayTracingEnabled ( const MeshHandle meshHandle,
bool  enabled 
)
overridevirtual

Sets the option to exclude this mesh from raytracing.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetSortKey()

void AZ::Render::MeshFeatureProcessor::SetSortKey ( const MeshHandle meshHandle,
RHI::DrawItemSortKey  sortKey 
)
overridevirtual

Sets the sort key for a given mesh handle.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetUseForwardPassIblSpecular()

void AZ::Render::MeshFeatureProcessor::SetUseForwardPassIblSpecular ( const MeshHandle meshHandle,
bool  useForwardPassIblSpecular 
)
overridevirtual

Sets the mesh to render IBL specular in the forward pass.

Implements AZ::Render::MeshFeatureProcessorInterface.

◆ SetVisible()

void AZ::Render::MeshFeatureProcessor::SetVisible ( const MeshHandle meshHandle,
bool  visible 
)
overridevirtual

Sets the mesh as visible or hidden. When the mesh is hidden it will not be rendered by the feature processor.

Implements AZ::Render::MeshFeatureProcessorInterface.


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