Merge pull request #6818 from windbagjacket/development
Adding ray tracing toggle to mesh component UI
This commit is contained in:
@@ -176,6 +176,7 @@ namespace AZ
|
||||
|
||||
void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) override;
|
||||
void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) override;
|
||||
bool GetRayTracingEnabled(const MeshHandle& meshHandle) const override;
|
||||
void SetVisible(const MeshHandle& meshHandle, bool visible) override;
|
||||
void SetUseForwardPassIblSpecular(const MeshHandle& meshHandle, bool useForwardPassIblSpecular) override;
|
||||
|
||||
|
||||
+2
@@ -105,6 +105,8 @@ namespace AZ
|
||||
virtual void SetExcludeFromReflectionCubeMaps(const MeshHandle& meshHandle, bool excludeFromReflectionCubeMaps) = 0;
|
||||
//! Sets the option to exclude this mesh from raytracing
|
||||
virtual void SetRayTracingEnabled(const MeshHandle& meshHandle, bool rayTracingEnabled) = 0;
|
||||
//! Gets whether this mesh is excluded from raytracing
|
||||
virtual bool GetRayTracingEnabled(const MeshHandle& meshHandle) const = 0;
|
||||
//! Sets the mesh as visible or hidden. When the mesh is hidden it will not be rendered by the feature processor.
|
||||
virtual void SetVisible(const MeshHandle& meshHandle, bool visible) = 0;
|
||||
//! Sets the mesh to render IBL specular in the forward pass.
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace UnitTest
|
||||
MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Render::MaterialAssignmentMap&));
|
||||
MOCK_METHOD2(AcquireMesh, MeshHandle (const AZ::Render::MeshHandleDescriptor&, const AZ::Data::Instance<AZ::RPI::Material>&));
|
||||
MOCK_METHOD2(SetRayTracingEnabled, void (const MeshHandle&, bool));
|
||||
MOCK_CONST_METHOD1(GetRayTracingEnabled, bool(const MeshHandle&));
|
||||
MOCK_METHOD2(SetVisible, void (const MeshHandle&, bool));
|
||||
MOCK_METHOD2(SetUseForwardPassIblSpecular, void (const MeshHandle&, bool));
|
||||
};
|
||||
|
||||
@@ -435,6 +435,19 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
bool MeshFeatureProcessor::GetRayTracingEnabled(const MeshHandle& meshHandle) const
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
{
|
||||
return meshHandle->m_descriptor.m_isRayTracingEnabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Invalid mesh handle");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void MeshFeatureProcessor::SetVisible(const MeshHandle& meshHandle, bool visible)
|
||||
{
|
||||
if (meshHandle.IsValid())
|
||||
|
||||
+3
@@ -51,6 +51,9 @@ namespace AZ
|
||||
virtual void SetVisibility(bool visible) = 0;
|
||||
virtual bool GetVisibility() const = 0;
|
||||
|
||||
virtual void SetRayTracingEnabled(bool enabled) = 0;
|
||||
virtual bool GetRayTracingEnabled() const = 0;
|
||||
|
||||
virtual AZ::Aabb GetWorldBounds() = 0;
|
||||
|
||||
virtual AZ::Aabb GetLocalBounds() = 0;
|
||||
|
||||
@@ -79,6 +79,9 @@ namespace AZ
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_useForwardPassIblSpecular, "Use Forward Pass IBL Specular",
|
||||
"Renders IBL specular reflections in the forward pass, using only the most influential probe (based on the position of the entity) and the global IBL cubemap. Can reduce rendering costs, but only recommended for static objects that are affected by at most one reflection probe.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
|
||||
->DataElement(AZ::Edit::UIHandlers::CheckBox, &MeshComponentConfig::m_isRayTracingEnabled, "Use ray tracing",
|
||||
"Includes this mesh in ray tracing calculations.")
|
||||
->Attribute(AZ::Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
|
||||
->DataElement(AZ::Edit::UIHandlers::ComboBox, &MeshComponentConfig::m_lodType, "Lod Type", "Lod Method.")
|
||||
->EnumAttribute(RPI::Cullable::LodType::Default, "Default")
|
||||
->EnumAttribute(RPI::Cullable::LodType::ScreenCoverage, "Screen Coverage")
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace AZ
|
||||
->Field("SortKey", &MeshComponentConfig::m_sortKey)
|
||||
->Field("ExcludeFromReflectionCubeMaps", &MeshComponentConfig::m_excludeFromReflectionCubeMaps)
|
||||
->Field("UseForwardPassIBLSpecular", &MeshComponentConfig::m_useForwardPassIblSpecular)
|
||||
->Field("IsRayTracingEnabled", &MeshComponentConfig::m_isRayTracingEnabled)
|
||||
->Field("LodType", &MeshComponentConfig::m_lodType)
|
||||
->Field("LodOverride", &MeshComponentConfig::m_lodOverride)
|
||||
->Field("MinimumScreenCoverage", &MeshComponentConfig::m_minimumScreenCoverage)
|
||||
@@ -181,6 +182,8 @@ namespace AZ
|
||||
->Event("GetMinimumScreenCoverage", &MeshComponentRequestBus::Events::GetMinimumScreenCoverage)
|
||||
->Event("SetQualityDecayRate", &MeshComponentRequestBus::Events::SetQualityDecayRate)
|
||||
->Event("GetQualityDecayRate", &MeshComponentRequestBus::Events::GetQualityDecayRate)
|
||||
->Event("SetRayTracingEnabled", &MeshComponentRequestBus::Events::SetRayTracingEnabled)
|
||||
->Event("GetRayTracingEnabled", &MeshComponentRequestBus::Events::GetRayTracingEnabled)
|
||||
->VirtualProperty("ModelAssetId", "GetModelAssetId", "SetModelAssetId")
|
||||
->VirtualProperty("ModelAssetPath", "GetModelAssetPath", "SetModelAssetPath")
|
||||
->VirtualProperty("SortKey", "GetSortKey", "SetSortKey")
|
||||
@@ -188,6 +191,7 @@ namespace AZ
|
||||
->VirtualProperty("LodOverride", "GetLodOverride", "SetLodOverride")
|
||||
->VirtualProperty("MinimumScreenCoverage", "GetMinimumScreenCoverage", "SetMinimumScreenCoverage")
|
||||
->VirtualProperty("QualityDecayRate", "GetQualityDecayRate", "SetQualityDecayRate")
|
||||
->VirtualProperty("RayTracingEnabled", "GetRayTracingEnabled", "SetRayTracingEnabled")
|
||||
;
|
||||
|
||||
behaviorContext->EBus<MeshComponentNotificationBus>("MeshComponentNotificationBus")
|
||||
@@ -382,6 +386,7 @@ namespace AZ
|
||||
meshDescriptor.m_modelAsset = m_configuration.m_modelAsset;
|
||||
meshDescriptor.m_useForwardPassIblSpecular = m_configuration.m_useForwardPassIblSpecular;
|
||||
meshDescriptor.m_requiresCloneCallback = RequiresCloning;
|
||||
meshDescriptor.m_isRayTracingEnabled = m_configuration.m_isRayTracingEnabled;
|
||||
m_meshHandle = m_meshFeatureProcessor->AcquireMesh(meshDescriptor, materials);
|
||||
m_meshFeatureProcessor->ConnectModelChangeEventHandler(m_meshHandle, m_changeEventHandler);
|
||||
|
||||
@@ -392,7 +397,7 @@ namespace AZ
|
||||
m_meshFeatureProcessor->SetMeshLodConfiguration(m_meshHandle, GetMeshLodConfiguration());
|
||||
m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps);
|
||||
m_meshFeatureProcessor->SetVisible(m_meshHandle, m_isVisible);
|
||||
|
||||
m_meshFeatureProcessor->SetRayTracingEnabled(m_meshHandle, meshDescriptor.m_isRayTracingEnabled);
|
||||
// [GFX TODO] This should happen automatically. m_changeEventHandler should be passed to AcquireMesh
|
||||
// If the model instance or asset already exists, announce a model change to let others know it's loaded.
|
||||
HandleModelChange(m_meshFeatureProcessor->GetModel(m_meshHandle));
|
||||
@@ -559,6 +564,25 @@ namespace AZ
|
||||
return m_isVisible;
|
||||
}
|
||||
|
||||
void MeshComponentController::SetRayTracingEnabled(bool enabled)
|
||||
{
|
||||
if (m_meshHandle.IsValid() && m_meshFeatureProcessor)
|
||||
{
|
||||
m_meshFeatureProcessor->SetRayTracingEnabled(m_meshHandle, enabled);
|
||||
m_configuration.m_isRayTracingEnabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
bool MeshComponentController::GetRayTracingEnabled() const
|
||||
{
|
||||
if (m_meshHandle.IsValid() && m_meshFeatureProcessor)
|
||||
{
|
||||
return m_meshFeatureProcessor->GetRayTracingEnabled(m_meshHandle);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Aabb MeshComponentController::GetWorldBounds()
|
||||
{
|
||||
if (const AZ::Aabb localBounds = GetLocalBounds(); localBounds.IsValid())
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace AZ
|
||||
RHI::DrawItemSortKey m_sortKey = 0;
|
||||
bool m_excludeFromReflectionCubeMaps = false;
|
||||
bool m_useForwardPassIblSpecular = false;
|
||||
|
||||
bool m_isRayTracingEnabled = true;
|
||||
RPI::Cullable::LodType m_lodType = RPI::Cullable::LodType::Default;
|
||||
RPI::Cullable::LodOverride m_lodOverride = aznumeric_cast<RPI::Cullable::LodOverride>(0);
|
||||
float m_minimumScreenCoverage = 1.0f / 1080.0f;
|
||||
@@ -116,6 +116,9 @@ namespace AZ
|
||||
void SetVisibility(bool visible) override;
|
||||
bool GetVisibility() const override;
|
||||
|
||||
void SetRayTracingEnabled(bool enabled) override;
|
||||
bool GetRayTracingEnabled() const override;
|
||||
|
||||
// BoundsRequestBus and MeshComponentRequestBus overrides ...
|
||||
AZ::Aabb GetWorldBounds() override;
|
||||
AZ::Aabb GetLocalBounds() override;
|
||||
|
||||
@@ -379,6 +379,24 @@ namespace AZ::Render
|
||||
return IsVisible();
|
||||
}
|
||||
|
||||
void AtomActorInstance::SetRayTracingEnabled(bool enabled)
|
||||
{
|
||||
if (m_meshHandle->IsValid() && m_meshFeatureProcessor)
|
||||
{
|
||||
m_meshFeatureProcessor->SetRayTracingEnabled(*m_meshHandle, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
bool AtomActorInstance::GetRayTracingEnabled() const
|
||||
{
|
||||
if (m_meshHandle->IsValid() && m_meshFeatureProcessor)
|
||||
{
|
||||
return m_meshFeatureProcessor->GetRayTracingEnabled(*m_meshHandle);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::u32 AtomActorInstance::GetJointCount()
|
||||
{
|
||||
return aznumeric_caster(m_actorInstance->GetActor()->GetSkeleton()->GetNumNodes());
|
||||
|
||||
@@ -152,6 +152,8 @@ namespace AZ
|
||||
float GetQualityDecayRate() const override;
|
||||
void SetVisibility(bool visible) override;
|
||||
bool GetVisibility() const override;
|
||||
void SetRayTracingEnabled(bool enabled) override;
|
||||
bool GetRayTracingEnabled() const override;
|
||||
// GetWorldBounds/GetLocalBounds already overridden by BoundsRequestBus::Handler
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -444,6 +444,15 @@ namespace UnitTest
|
||||
m_GetVisibilityOutput = visibility;
|
||||
}
|
||||
|
||||
void SetRayTracingEnabled([[maybe_unused]] bool enabled) override
|
||||
{
|
||||
}
|
||||
|
||||
bool GetRayTracingEnabled() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::Data::AssetId m_assetIdOutput;
|
||||
void SetModelAssetId(AZ::Data::AssetId modelAssetId) override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user