From 2fb2813b485f624cef957c68310e47e3597c51bc Mon Sep 17 00:00:00 2001 From: greerdv Date: Wed, 14 Apr 2021 14:05:59 +0100 Subject: [PATCH 01/27] updating atom mesh component to support non-uniform scale component --- Code/Framework/AzCore/AzCore/Math/Aabb.cpp | 31 ++++++++++++++- Code/Framework/AzCore/AzCore/Math/Aabb.h | 10 ++++- Code/Framework/AzCore/AzCore/Math/Aabb.inl | 8 ++++ .../Atom/Feature/Mesh/MeshFeatureProcessor.h | 4 +- .../Mesh/MeshFeatureProcessorInterface.h | 8 ++-- .../ReflectionProbeFeatureProcessor.h | 2 +- ...ReflectionProbeFeatureProcessorInterface.h | 2 +- .../TransformServiceFeatureProcessor.h | 4 +- ...ransformServiceFeatureProcessorInterface.h | 8 ++-- .../Code/Mocks/MockMeshFeatureProcessor.h | 4 +- .../Code/Source/AuxGeom/AuxGeomDrawQueue.cpp | 2 +- .../DiffuseProbeGridRayTracingPass.cpp | 8 ++-- .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 18 ++++----- .../RayTracingAccelerationStructurePass.cpp | 2 +- .../RayTracing/RayTracingFeatureProcessor.cpp | 6 +-- .../RayTracing/RayTracingFeatureProcessor.h | 4 +- .../ReflectionProbe/ReflectionProbe.cpp | 8 ++-- .../Source/ReflectionProbe/ReflectionProbe.h | 2 +- .../ReflectionProbeFeatureProcessor.cpp | 8 ++-- .../TransformServiceFeatureProcessor.cpp | 8 ++-- .../RHI/RayTracingAccelerationStructure.h | 6 +-- .../RHI/RayTracingAccelerationStructure.cpp | 6 +-- .../DX12/Code/Source/RHI/RayTracingTlas.cpp | 3 +- .../Vulkan/Code/Source/RHI/RayTracingTlas.cpp | 4 +- .../Include/Atom/RPI.Public/Model/Model.h | 4 +- .../Code/Source/RPI.Public/Model/Model.cpp | 6 +-- .../Code/Source/Mesh/EditorMeshComponent.cpp | 5 ++- .../Source/Mesh/MeshComponentController.cpp | 38 ++++++++++++++++--- .../Source/Mesh/MeshComponentController.h | 10 +++++ .../ReflectionProbeComponentController.cpp | 2 +- .../Code/Source/AtomActorInstance.cpp | 5 ++- .../Editor/EditorBlastMeshDataComponent.cpp | 4 +- .../Code/Source/Family/ActorRenderManager.cpp | 6 +-- .../Code/Tests/ActorRenderManagerTest.cpp | 2 +- .../Rendering/Atom/WhiteBoxAtomRenderMesh.cpp | 2 +- 35 files changed, 166 insertions(+), 84 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.cpp b/Code/Framework/AzCore/AzCore/Math/Aabb.cpp index 94e138d88d..48e51cce48 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.cpp @@ -146,8 +146,8 @@ namespace AZ ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Method("GetTranslated", &Aabb::GetTranslated) ->Method("GetSurfaceArea", &Aabb::GetSurfaceArea) - ->Method("GetTransformedObb", &Aabb::GetTransformedObb) - ->Method("GetTransformedAabb", &Aabb::GetTransformedAabb) + ->Method("GetTransformedObb", static_cast(&Aabb::GetTransformedObb)) + ->Method("GetTransformedAabb", static_cast(&Aabb::GetTransformedAabb)) ->Method("ApplyTransform", &Aabb::ApplyTransform) ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) ->Method("Clone", [](const Aabb& rhs) -> Aabb { return rhs; }) @@ -195,6 +195,20 @@ namespace AZ } + Obb Aabb::GetTransformedObb(const Matrix3x4& matrix3x4) const + { + Matrix3x4 matrixNoScale = matrix3x4; + const AZ::Vector3 scale = matrixNoScale.ExtractScale(); + const AZ::Quaternion rotation = AZ::Quaternion::CreateFromMatrix3x4(matrixNoScale); + + return Obb::CreateFromPositionRotationAndHalfLengths( + matrix3x4 * GetCenter(), + rotation, + 0.5f * scale * GetExtents() + ); + } + + void Aabb::ApplyTransform(const Transform& transform) { Vector3 a, b, axisCoeffs; @@ -224,4 +238,17 @@ namespace AZ m_min = newMin; m_max = newMax; } + + + void Aabb::ApplyMatrix3x4(const Matrix3x4& matrix3x4) + { + const AZ::Vector3 extents = GetExtents(); + const AZ::Vector3 center = GetCenter(); + AZ::Vector3 newHalfExtents( + 0.5f * matrix3x4.GetRowAsVector3(0).GetAbs().Dot(extents), + 0.5f * matrix3x4.GetRowAsVector3(1).GetAbs().Dot(extents), + 0.5f * matrix3x4.GetRowAsVector3(2).GetAbs().Dot(extents)); + m_min = center - newHalfExtents; + m_max = center + newHalfExtents; + } } diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.h b/Code/Framework/AzCore/AzCore/Math/Aabb.h index 0aebd099f4..474ac2e2ee 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.h +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.h @@ -129,12 +129,20 @@ namespace AZ void ApplyTransform(const Transform& transform); + void ApplyMatrix3x4(const Matrix3x4& matrix3x4); + //! Transforms an Aabb and returns the resulting Obb. - class Obb GetTransformedObb(const Transform& transform) const; + Obb GetTransformedObb(const Transform& transform) const; + + //! Transforms an Aabb and returns the resulting Obb. + Obb GetTransformedObb(const Matrix3x4& matrix3x4) const; //! Returns a new AABB containing the transformed AABB. Aabb GetTransformedAabb(const Transform& transform) const; + //! Returns a new AABB containing the transformed AABB. + Aabb GetTransformedAabb(const Matrix3x4& matrix3x4) const; + //! Checks if this aabb is equal to another within a floating point tolerance. bool IsClose(const Aabb& rhs, float tolerance = Constants::Tolerance) const; diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.inl b/Code/Framework/AzCore/AzCore/Math/Aabb.inl index 5e6a5ae188..94ad3e3e7d 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.inl +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.inl @@ -300,6 +300,14 @@ namespace AZ } + AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Matrix3x4& matrix3x4) const + { + Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max); + aabb.ApplyMatrix3x4(matrix3x4); + return aabb; + } + + AZ_MATH_INLINE bool Aabb::IsClose(const Aabb& rhs, float tolerance) const { return m_min.IsClose(rhs.m_min, tolerance) && m_max.IsClose(rhs.m_max, tolerance); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index a595471813..cc26ff862a 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -144,8 +144,8 @@ namespace AZ const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const override; void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) override; - void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) override; - Transform GetTransform(const MeshHandle& meshHandle) override; + void SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) override; + Matrix3x4 GetMatrix3x4(const MeshHandle& meshHandle) override; void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index 77e3467fb9..ef8084d534 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -61,10 +61,10 @@ namespace AZ virtual const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const = 0; //! Connects a handler to any changes to an RPI::Model. Changes include loading and reloading. virtual void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) = 0; - //! Sets the transform for a given mesh handle. - virtual void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) = 0; - //! Gets the transform for a given mesh handle. - virtual Transform GetTransform(const MeshHandle& meshHandle) = 0; + //! Sets the Matrix3x4 for a given mesh handle. + virtual void SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) = 0; + //! Gets the Matrix3x4 for a given mesh handle. + virtual Matrix3x4 GetMatrix3x4(const MeshHandle& meshHandle) = 0; //! Sets the sort key for a given mesh handle. virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h index a89875aaa6..610bb40369 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h @@ -37,7 +37,7 @@ namespace AZ void SetProbeOuterExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& outerExtents) override; void SetProbeInnerExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& innerExtents) override; void SetProbeCubeMap(const ReflectionProbeHandle& probe, Data::Instance& cubeMapImage) override; - void SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform) override; + void SetProbeMatrix3x4(const ReflectionProbeHandle& probe, const AZ::Matrix3x4& matrix3x4) override; void BakeProbe(const ReflectionProbeHandle& probe, BuildCubeMapCallback callback) override; void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) override; bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const override { return (probe.get() != nullptr); } diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h index 8b277e97c8..3053d9d44f 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h @@ -48,7 +48,7 @@ namespace AZ virtual void SetProbeOuterExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& outerExtents) = 0; virtual void SetProbeInnerExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& innerExtents) = 0; virtual void SetProbeCubeMap(const ReflectionProbeHandle& handle, Data::Instance& cubeMapImage) = 0; - virtual void SetProbeTransform(const ReflectionProbeHandle& handle, const AZ::Transform& transform) = 0; + virtual void SetProbeMatrix3x4(const ReflectionProbeHandle& handle, const AZ::Matrix3x4& matrix3x4) = 0; virtual void BakeProbe(const ReflectionProbeHandle& handle, BuildCubeMapCallback callback) = 0; virtual void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) = 0; virtual bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const = 0; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h index 2344f745f8..d6338d6b0c 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h @@ -50,8 +50,8 @@ namespace AZ // TransformServiceFeatureProcessorInterface overrides ... ObjectId ReserveObjectId() override; void ReleaseObjectId(ObjectId& id) override; - void SetTransformForId(ObjectId id, const AZ::Transform& transform) override; - AZ::Transform GetTransformForId(ObjectId id) const override; + void SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& matrix3x4) override; + AZ::Matrix3x4 GetMatrix3x4ForId(ObjectId id) const override; private: diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h index 0b17a9a5a0..b75257c485 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h @@ -34,10 +34,10 @@ namespace AZ //! Releases an object ID to be used by others. The passed in handle is invalidated. virtual void ReleaseObjectId(ObjectId& id) = 0; - //! Sets the transform for a given id. Id must be one reserved earlier. - virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform) = 0; - //! Gets the transform for a given id. Id must be one reserved earlier. - virtual AZ::Transform GetTransformForId(ObjectId) const = 0; + //! Sets the Matrix3x4 for a given id. Id must be one reserved earlier. + virtual void SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& transform) = 0; + //! Gets the Matrix3x4 for a given id. Id must be one reserved earlier. + virtual AZ::Matrix3x4 GetMatrix3x4ForId(ObjectId) const = 0; }; } diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index 6fc1ac0e30..b6428754b5 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -31,11 +31,11 @@ namespace UnitTest MOCK_CONST_METHOD1(GetModel, AZStd::intrusive_ptr(const MeshHandle&)); MOCK_CONST_METHOD1(GetMaterialAssignmentMap, const AZ::Render::MaterialAssignmentMap&(const MeshHandle&)); MOCK_METHOD2(ConnectModelChangeEventHandler, void(const MeshHandle&, ModelChangedEvent::Handler&)); - MOCK_METHOD2(SetTransform, void(const MeshHandle&, const AZ::Transform&)); + MOCK_METHOD2(SetMatrix3x4, void(const MeshHandle&, const AZ::Matrix3x4&)); MOCK_METHOD2(SetExcludeFromReflectionCubeMaps, void(const MeshHandle&, bool)); MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Data::Instance&)); MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Render::MaterialAssignmentMap&)); - MOCK_METHOD1(GetTransform, AZ::Transform (const MeshHandle&)); + MOCK_METHOD1(GetMatrix3x4, AZ::Matrix3x4 (const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); diff --git a/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp b/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp index fd4b5b28d1..c412746676 100644 --- a/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/AuxGeom/AuxGeomDrawQueue.cpp @@ -504,7 +504,7 @@ namespace AZ box.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull); box.m_color = color; box.m_scale = localMatrix3x4.ExtractScale() * extents; - box.m_position = localMatrix3x4.GetTranslation() + center; + box.m_position = matrix3x4 * center; box.m_rotationMatrix = Matrix3x3::CreateFromMatrix3x4(localMatrix3x4); box.m_pointSize = m_pointSize; box.m_viewProjOverrideIndex = viewProjOverrideIndex; diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseProbeGrid/DiffuseProbeGridRayTracingPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseProbeGrid/DiffuseProbeGridRayTracingPass.cpp index f6eeaf2971..f5e4f29cea 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseProbeGrid/DiffuseProbeGridRayTracingPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseProbeGrid/DiffuseProbeGridRayTracingPass.cpp @@ -186,10 +186,10 @@ namespace AZ // set irradiance color and worldInverseTranspose constants Vector4 color(subMesh.m_irradianceColor.GetR(), subMesh.m_irradianceColor.GetG(), subMesh.m_irradianceColor.GetB(), 1.0f); - AZ::Transform meshTransform = transformFeatureProcessor->GetTransformForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first)); - AZ::Transform noScaleTransform = meshTransform; - noScaleTransform.ExtractScale(); - AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromTransform(noScaleTransform); + AZ::Matrix3x4 meshMatrix3x4 = transformFeatureProcessor->GetMatrix3x4ForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first)); + AZ::Matrix3x4 noScaleMatrix3x4 = meshMatrix3x4; + noScaleMatrix3x4.ExtractScale(); + AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromMatrix3x4(noScaleMatrix3x4); rotationMatrix = rotationMatrix.GetInverseFull().GetTranspose(); m_closestHitData[m_meshCount].m_materialColor = color; diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 1f5b8ecc65..40873ccea0 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -256,7 +256,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform) + void MeshFeatureProcessor::SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) { if (meshHandle.IsValid()) { @@ -264,26 +264,26 @@ namespace AZ meshData.m_cullBoundsNeedsUpdate = true; meshData.m_objectSrgNeedsUpdate = true; - m_transformService->SetTransformForId(meshHandle->m_objectId, transform); + m_transformService->SetMatrix3x4ForId(meshHandle->m_objectId, matrix3x4); // ray tracing data needs to be updated with the new transform if (m_rayTracingFeatureProcessor) { - m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform); + m_rayTracingFeatureProcessor->SetMeshMatrix3x4(meshHandle->m_objectId, matrix3x4); } } } - Transform MeshFeatureProcessor::GetTransform(const MeshHandle& meshHandle) + Matrix3x4 MeshFeatureProcessor::GetMatrix3x4(const MeshHandle& meshHandle) { if (meshHandle.IsValid()) { - return m_transformService->GetTransformForId(meshHandle->m_objectId); + return m_transformService->GetMatrix3x4ForId(meshHandle->m_objectId); } else { AZ_Assert(false, "Invalid mesh handle"); - return Transform::CreateIdentity(); + return Matrix3x4::CreateIdentity(); } } @@ -841,7 +841,7 @@ namespace AZ AZ_Assert(m_cullBoundsNeedsUpdate, "This function only needs to be called if the culling bounds need to be rebuilt"); AZ_Assert(m_model, "The model has not finished loading yet"); - Transform localToWorld = transformService->GetTransformForId(m_objectId); + Matrix3x4 localToWorld = transformService->GetMatrix3x4ForId(m_objectId); Vector3 center; float radius; @@ -919,11 +919,11 @@ namespace AZ // retrieve the list of probes that contain the centerpoint of the mesh TransformServiceFeatureProcessor* transformServiceFeatureProcessor = m_scene->GetFeatureProcessor(); - Transform transform = transformServiceFeatureProcessor->GetTransformForId(m_objectId); + Matrix3x4 matrix3x4 = transformServiceFeatureProcessor->GetMatrix3x4ForId(m_objectId); ReflectionProbeFeatureProcessor* reflectionProbeFeatureProcessor = m_scene->GetFeatureProcessor(); ReflectionProbeFeatureProcessor::ReflectionProbeVector reflectionProbes; - reflectionProbeFeatureProcessor->FindReflectionProbes(transform.GetTranslation(), reflectionProbes); + reflectionProbeFeatureProcessor->FindReflectionProbes(matrix3x4.GetTranslation(), reflectionProbes); if (!reflectionProbes.empty() && reflectionProbes[0]) { diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp index f874f87b4a..7e39f968fd 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp @@ -83,7 +83,7 @@ namespace AZ ->InstanceID(blasIndex) ->HitGroupIndex(blasIndex) ->Blas(rayTracingSubMesh.m_blas) - ->Transform(rayTracingMesh.second.m_transform) + ->Matrix3x4(rayTracingMesh.second.m_matrix3x4) ; } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index abced377a0..1e7fc464df 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -97,7 +97,7 @@ namespace AZ } // set initial transform - mesh.m_transform = m_transformServiceFeatureProcessor->GetTransformForId(objectId); + mesh.m_matrix3x4 = m_transformServiceFeatureProcessor->GetMatrix3x4ForId(objectId); m_revision++; m_subMeshCount += aznumeric_cast(subMeshes.size()); @@ -119,7 +119,7 @@ namespace AZ } } - void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, AZ::Transform transform) + void RayTracingFeatureProcessor::SetMeshMatrix3x4(const ObjectId objectId, const AZ::Matrix3x4 matrix3x4) { if (!m_rayTracingEnabled) { @@ -129,7 +129,7 @@ namespace AZ MeshMap::iterator itMesh = m_meshes.find(objectId.GetIndex()); if (itMesh != m_meshes.end()) { - itMesh->second.m_transform = transform; + itMesh->second.m_matrix3x4 = matrix3x4; m_revision++; } } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h index 09a4a6f63c..af5bfd0d51 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h @@ -66,7 +66,7 @@ namespace AZ SubMeshVector m_subMeshes; // mesh transform - AZ::Transform m_transform = AZ::Transform::CreateIdentity(); + AZ::Matrix3x4 m_matrix3x4 = AZ::Matrix3x4::CreateIdentity(); // flag indicating if the Blas objects in the sub-meshes are built bool m_blasBuilt = false; @@ -85,7 +85,7 @@ namespace AZ //! Sets the ray tracing mesh transform //! This will cause an update to the RayTracing acceleration structure on the next frame - void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform); + void SetMeshMatrix3x4(const ObjectId objectId, const AZ::Matrix3x4 matrix3x4); //! Retrieves ray tracing data for all meshes in the scene const MeshMap& GetMeshes() const { return m_meshes; } diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp index 51303436ee..f56902ebde 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp @@ -70,7 +70,7 @@ namespace AZ m_visualizationMeshHandle = m_meshFeatureProcessor->AcquireMesh(m_visualizationModelAsset); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_visualizationMeshHandle, true); m_meshFeatureProcessor->SetRayTracingEnabled(m_visualizationMeshHandle, false); - m_meshFeatureProcessor->SetTransform(m_visualizationMeshHandle, AZ::Transform::CreateIdentity()); + m_meshFeatureProcessor->SetMatrix3x4(m_visualizationMeshHandle, AZ::Matrix3x4::CreateIdentity()); // We have to pre-load this asset before creating a Material instance because the InstanceDatabase will attempt a blocking load which could deadlock, // particularly when slices are involved. @@ -206,10 +206,10 @@ namespace AZ } - void ReflectionProbe::SetTransform(const AZ::Transform& transform) + void ReflectionProbe::SetMatrix3x4(const AZ::Matrix3x4& matrix3x4) { - m_position = transform.GetTranslation(); - m_meshFeatureProcessor->SetTransform(m_visualizationMeshHandle, transform); + m_position = matrix3x4.GetTranslation(); + m_meshFeatureProcessor->SetMatrix3x4(m_visualizationMeshHandle, matrix3x4); m_outerAabbWs = Aabb::CreateCenterHalfExtents(m_position, m_outerExtents / 2.0f); m_innerAabbWs = Aabb::CreateCenterHalfExtents(m_position, m_innerExtents / 2.0f); m_updateSrg = true; diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h index 22645a4ed3..6b23afb1fc 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h @@ -76,7 +76,7 @@ namespace AZ void Simulate(uint32_t probeIndex); const Vector3& GetPosition() const { return m_position; } - void SetTransform(const AZ::Transform& transform); + void SetMatrix3x4(const AZ::Matrix3x4& matrix3x4); const AZ::Vector3& GetOuterExtents() const { return m_outerExtents; } void SetOuterExtents(const AZ::Vector3& outerExtents); diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp index 80719564b1..8631e334b4 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp @@ -223,7 +223,7 @@ namespace AZ { AZStd::shared_ptr reflectionProbe = AZStd::make_shared(); reflectionProbe->Init(GetParentScene(), &m_reflectionRenderData); - reflectionProbe->SetTransform(transform); + reflectionProbe->SetMatrix3x4(AZ::Matrix3x4::CreateFromTransform(transform)); reflectionProbe->SetUseParallaxCorrection(useParallaxCorrection); m_reflectionProbes.push_back(reflectionProbe); m_probeSortRequired = true; @@ -264,10 +264,10 @@ namespace AZ probe->SetCubeMapImage(cubeMapImage); } - void ReflectionProbeFeatureProcessor::SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform) + void ReflectionProbeFeatureProcessor::SetProbeMatrix3x4(const ReflectionProbeHandle& probe, const AZ::Matrix3x4& matrix3x4) { - AZ_Assert(probe.get(), "SetProbeTransform called with an invalid handle"); - probe->SetTransform(transform); + AZ_Assert(probe.get(), "SetProbeMatrix3x4 called with an invalid handle"); + probe->SetMatrix3x4(matrix3x4); m_probeSortRequired = true; } diff --git a/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp index a4f255185a..a3a91ca620 100644 --- a/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp @@ -210,14 +210,12 @@ namespace AZ } } - void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform) + void TransformServiceFeatureProcessor::SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& matrix3x4) { AZ_Error("TransformServiceFeatureProcessor", m_isWriteable, "Transform data cannot be written to during this phase"); AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle."); if (id.IsValid()) { - AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(transform); - matrix3x4.StoreToRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); // Inverse transpose to take the non-uniform scale out of the transform for usage with normals. @@ -226,10 +224,10 @@ namespace AZ } } - AZ::Transform TransformServiceFeatureProcessor::GetTransformForId(ObjectId id) const + AZ::Matrix3x4 TransformServiceFeatureProcessor::GetMatrix3x4ForId(ObjectId id) const { AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle."); - return AZ::Transform::CreateFromMatrix3x4( Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform) ); + return AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); } } } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h index 09ba2b1d59..0225673efd 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h @@ -12,7 +12,7 @@ #pragma once #include -#include +#include #include #include #include @@ -110,7 +110,7 @@ namespace AZ { uint32_t m_instanceID = 0; uint32_t m_hitGroupIndex = 0; - AZ::Transform m_transform = AZ::Transform::CreateIdentity(); + AZ::Matrix3x4 m_matrix3x4 = AZ::Matrix3x4::CreateIdentity(); RHI::Ptr m_blas; }; using RayTracingTlasInstanceVector = AZStd::vector; @@ -153,7 +153,7 @@ namespace AZ RayTracingTlasDescriptor* Instance(); RayTracingTlasDescriptor* InstanceID(uint32_t instanceID); RayTracingTlasDescriptor* HitGroupIndex(uint32_t hitGroupIndex); - RayTracingTlasDescriptor* Transform(const AZ::Transform& transform); + RayTracingTlasDescriptor* Matrix3x4(const AZ::Matrix3x4& matrix3x4); RayTracingTlasDescriptor* Blas(RHI::Ptr& blas); RayTracingTlasDescriptor* InstancesBuffer(RHI::Ptr& tlasInstances); RayTracingTlasDescriptor* NumInstances(uint32_t numInstancesInBuffer); diff --git a/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp b/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp index 37e5b316d6..dadaeee5d4 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp @@ -78,10 +78,10 @@ namespace AZ return this; } - RayTracingTlasDescriptor* RayTracingTlasDescriptor::Transform(const AZ::Transform& transform) + RayTracingTlasDescriptor* RayTracingTlasDescriptor::Matrix3x4(const AZ::Matrix3x4& matrix3x4) { - AZ_Assert(m_buildContext, "Transform property can only be added to an Instance entry"); - m_buildContext->m_transform = transform; + AZ_Assert(m_buildContext, "Matrix3x4 property can only be added to an Instance entry"); + m_buildContext->m_matrix3x4 = matrix3x4; return this; } diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp index 77d8d38e42..8c01b798a6 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp @@ -89,8 +89,7 @@ namespace AZ mappedData[i].InstanceID = instance.m_instanceID; mappedData[i].InstanceContributionToHitGroupIndex = instance.m_hitGroupIndex; // convert transform to row-major 3x4 - AZ::Matrix3x4 matrix34 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); - matrix34.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]); + instance.m_matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]); mappedData[i].AccelerationStructure = static_cast(blas->GetBuffers().m_blasBuffer.get())->GetMemoryView().GetGpuAddress(); // [GFX TODO][ATOM-5270] Add ray tracing TLAS instance mask support mappedData[i].InstanceMask = 0x1; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp index 9720fecb6d..161104060e 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp @@ -92,9 +92,7 @@ namespace AZ mappedData[i].instanceCustomIndex = instance.m_instanceID; mappedData[i].instanceShaderBindingTableRecordOffset = instance.m_hitGroupIndex; - // convert transform to row-major 3x4 - AZ::Matrix3x4 matrix34 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); - matrix34.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]); + instance.m_matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]); RayTracingBlas* blas = static_cast(instance.m_blas.get()); VkAccelerationStructureDeviceAddressInfoKHR addressInfo = {}; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h index 5cd464962b..ada429ee05 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h @@ -72,11 +72,13 @@ namespace AZ //! [GFX TODO][ATOM-4343 Bake mesh spatial during AP processing] //! //! @param modelTransform a transform that puts the model into the ray's coordinate space + //! @param nonUniformScale Non-uniform scale applied in the model's local frame. //! @param rayStart position where the ray starts //! @param dir direction where the ray ends (does not have to be unit length) //! @param distanceFactor if an intersection is detected, this will be set such that distanceFactor * dir.length == distance to intersection //! @return true if the ray intersects the mesh - bool RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor) const; + bool RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, + const AZ::Vector3& dir, float& distanceFactor) const; //! Get available UV names from the model and its lods. const AZStd::unordered_set& GetUvNames() const; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 84c10cb272..ad56b6e33a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -164,15 +164,15 @@ namespace AZ return false; } - bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor) const + bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor) const { AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender); const AZ::Transform inverseTM = modelTransform.GetInverse(); - const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart); + const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / nonUniformScale; // Instead of just rotating 'dir' we need it to be scaled too, so that 'distanceFactor' will be in the target units rather than object local units. const AZ::Vector3 rayDest = rayStart + dir; - const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest); + const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / nonUniformScale; const AZ::Vector3 rayDirLocal = rayDestLocal - raySrcLocal; return LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp index 0afe96588f..86a3c12557 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/EditorMeshComponent.cpp @@ -137,7 +137,10 @@ namespace AZ AZ::Transform transform = AZ::Transform::CreateIdentity(); AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformBus::Events::GetWorldTM); - return m_controller.GetModel()->RayIntersection(transform, src, dir, distance); + AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne(); + AZ::NonUniformScaleRequestBus::EventResult(nonUniformScale, GetEntityId(), &AZ::NonUniformScaleRequests::GetScale); + + return m_controller.GetModel()->RayIntersection(transform, nonUniformScale, src, dir, distance); } bool EditorMeshComponent::SupportsEditorRayIntersect() diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index db64d26a54..1404db717f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -180,6 +180,11 @@ namespace AZ m_meshFeatureProcessor = RPI::Scene::GetFeatureProcessorForEntity(m_entityId); AZ_Error("MeshComponentController", m_meshFeatureProcessor, "Unable to find a MeshFeatureProcessorInterface on the entityId."); + m_cachedNonUniformScale = AZ::Vector3::CreateOne(); + AZ::NonUniformScaleRequestBus::EventResult(m_cachedNonUniformScale, m_entityId, &AZ::NonUniformScaleRequests::GetScale); + AZ::NonUniformScaleRequestBus::Event(m_entityId, &AZ::NonUniformScaleRequests::RegisterScaleChangedEvent, + m_nonUniformScaleChangedHandler); + MeshComponentRequestBus::Handler::BusConnect(m_entityId); TransformNotificationBus::Handler::BusConnect(m_entityId); MaterialReceiverRequestBus::Handler::BusConnect(m_entityId); @@ -216,11 +221,24 @@ namespace AZ return m_configuration; } - void MeshComponentController::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world) + void MeshComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, [[maybe_unused]] const AZ::Transform& world) + { + UpdateOverallMatrix(); + } + + void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3 & nonUniformScale) + { + m_cachedNonUniformScale = nonUniformScale; + UpdateOverallMatrix(); + } + + void MeshComponentController::UpdateOverallMatrix() { if (m_meshFeatureProcessor) { - m_meshFeatureProcessor->SetTransform(m_meshHandle, world); + Matrix3x4 world = Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()); + world.MultiplyByScale(m_cachedNonUniformScale); + m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, world); } } @@ -266,8 +284,8 @@ namespace AZ m_meshHandle = m_meshFeatureProcessor->AcquireMesh(m_configuration.m_modelAsset, materials); m_meshFeatureProcessor->ConnectModelChangeEventHandler(m_meshHandle, m_changeEventHandler); - const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : Transform::Identity(); - m_meshFeatureProcessor->SetTransform(m_meshHandle, transform); + const AZ::Matrix3x4& matrix3x4 = m_transformInterface ? Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()) : Matrix3x4::Identity(); + m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, matrix3x4); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); @@ -403,7 +421,17 @@ namespace AZ Aabb MeshComponentController::GetLocalBounds() { const Data::Instance model = GetModel(); - return model ? model->GetAabb() : Aabb::CreateNull(); + if (model) + { + Aabb aabb = model->GetAabb(); + aabb.SetMin(aabb.GetMin() * m_cachedNonUniformScale); + aabb.SetMax(aabb.GetMax() * m_cachedNonUniformScale); + return aabb; + } + else + { + return Aabb::CreateNull(); + } } } // namespace Render } // namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 184756d931..68c7ed8063 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -14,6 +14,7 @@ #include #include +#include #include @@ -120,17 +121,26 @@ namespace AZ void UnregisterModel(); void RefreshModelRegistration(); + void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); + void UpdateOverallMatrix(); + Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr; Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle; TransformInterface* m_transformInterface = nullptr; AZ::EntityId m_entityId; bool m_isVisible = true; MeshComponentConfig m_configuration; + AZ::Vector3 m_cachedNonUniformScale = AZ::Vector3::CreateOne(); MeshFeatureProcessorInterface::ModelChangedEvent::Handler m_changeEventHandler { [&](Data::Instance model) { HandleModelChange(model); } }; + + AZ::NonUniformScaleChangedEvent::Handler m_nonUniformScaleChangedHandler + { + [&](const AZ::Vector3& nonUniformScale) { HandleNonUniformScaleChange(nonUniformScale); } + }; }; } // namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp index 005e9a6ff5..57aaa6a83f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp @@ -199,7 +199,7 @@ namespace AZ return; } - m_featureProcessor->SetProbeTransform(m_handle, world); + m_featureProcessor->SetProbeMatrix3x4(m_handle, Matrix3x4::CreateFromTransform(world)); } void ReflectionProbeComponentController::OnShapeChanged(ShapeChangeReasons changeReason) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index b0d52e0776..fd98dfe666 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -187,8 +187,9 @@ namespace AZ void AtomActorInstance::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world) { - // The mesh transform is used to determine where the actor instance is actually rendered - m_meshFeatureProcessor->SetTransform(*m_meshHandle, world); // handle validity is checked internally. + // The mesh Matrix3x4 is used to determine where the actor instance is actually rendered + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(world); + m_meshFeatureProcessor->SetMatrix3x4(*m_meshHandle, matrix3x4); // handle validity is checked internally. if (m_skinnedMeshRenderProxy.IsValid()) { diff --git a/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp b/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp index d2aa81900b..5fd9c678dc 100644 --- a/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp +++ b/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp @@ -193,7 +193,7 @@ namespace Blast AZ::Transform transform = AZ::Transform::Identity(); AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformInterface::GetWorldTM); - m_meshFeatureProcessor->SetTransform(m_meshHandle, transform); + m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(transform)); } } @@ -232,7 +232,7 @@ namespace Blast { if (m_meshFeatureProcessor) { - m_meshFeatureProcessor->SetTransform(m_meshHandle, world); + m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(world)); } } } // namespace Blast diff --git a/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp b/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp index deb6362ee3..d057e5a619 100644 --- a/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp +++ b/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp @@ -74,10 +74,10 @@ namespace Blast { if (m_chunkActors[chunkId]) { - auto transform = m_chunkActors[chunkId]->GetWorldBody()->GetTransform(); + auto matrix3x4 = AZ::Matrix3x4::CreateFromTransform(m_chunkActors[chunkId]->GetWorldBody()->GetTransform()); // Multiply by scale because the transform on the world body does not store scale - transform.MultiplyByScale(m_scale); - m_meshFeatureProcessor->SetTransform(m_chunkMeshHandles[chunkId], transform); + matrix3x4.MultiplyByScale(m_scale); + m_meshFeatureProcessor->SetMatrix3x4(m_chunkMeshHandles[chunkId], matrix3x4); } } } diff --git a/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp b/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp index 4036023397..0a7cd229a3 100644 --- a/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp +++ b/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp @@ -114,7 +114,7 @@ namespace Blast // ActorRenderManager::SyncMeshes { - EXPECT_CALL(*m_mockMeshFeatureProcessor, SetTransform(_, _)) + EXPECT_CALL(*m_mockMeshFeatureProcessor, SetMatrix3x4(_, _)) .Times(aznumeric_cast(m_actorFactory->m_mockActors[0]->GetChunkIndices().size())); actorRenderManager->SyncMeshes(); } diff --git a/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp b/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp index 9aa29cb288..9c3428ad63 100644 --- a/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp +++ b/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp @@ -248,7 +248,7 @@ namespace WhiteBox void AtomRenderMesh::UpdateTransform(const AZ::Transform& worldFromLocal) { - m_meshFeatureProcessor->SetTransform(m_meshHandle, worldFromLocal); + m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(worldFromLocal)); } void AtomRenderMesh::UpdateMaterial([[maybe_unused]] const WhiteBoxMaterial& material) From 217009de2b8752da208a1c53eaf1062d722f7000 Mon Sep 17 00:00:00 2001 From: greerdv Date: Wed, 14 Apr 2021 18:25:38 +0100 Subject: [PATCH 02/27] adding tests for transforming Aabb with Matrix3x4 and fixing bug in implementation --- Code/Framework/AzCore/AzCore/Math/Aabb.cpp | 2 +- .../Framework/AzCore/Tests/Math/AabbTests.cpp | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.cpp b/Code/Framework/AzCore/AzCore/Math/Aabb.cpp index 48e51cce48..3f7cb4ecf5 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.cpp @@ -243,7 +243,7 @@ namespace AZ void Aabb::ApplyMatrix3x4(const Matrix3x4& matrix3x4) { const AZ::Vector3 extents = GetExtents(); - const AZ::Vector3 center = GetCenter(); + const AZ::Vector3 center = matrix3x4 * GetCenter(); AZ::Vector3 newHalfExtents( 0.5f * matrix3x4.GetRowAsVector3(0).GetAbs().Dot(extents), 0.5f * matrix3x4.GetRowAsVector3(1).GetAbs().Dot(extents), diff --git a/Code/Framework/AzCore/Tests/Math/AabbTests.cpp b/Code/Framework/AzCore/Tests/Math/AabbTests.cpp index 20a4d2ed85..6b7317f5b3 100644 --- a/Code/Framework/AzCore/Tests/Math/AabbTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/AabbTests.cpp @@ -15,6 +15,7 @@ #include #include #include +#include using namespace AZ; @@ -385,4 +386,64 @@ namespace UnitTest EXPECT_TRUE(aabb.GetMin().IsClose(transAabb.GetMin())); EXPECT_TRUE(aabb.GetMax().IsClose(transAabb.GetMax())); } + + TEST(MATH_AabbTransform, GetTransformedObbMatrix3x4) + { + Vector3 min(-1.0f, -2.0f, -3.0f); + Vector3 max(4.0f, 3.0f, 2.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Quaternion rotation(0.46f, 0.26f, 0.58f, 0.62f); + Vector3 translation(5.0f, 7.0f, 9.0f); + + Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation); + + matrix3x4.MultiplyByScale(Vector3(0.5f, 1.5f, 2.0f)); + + Obb obb = aabb.GetTransformedObb(matrix3x4); + + EXPECT_THAT(obb.GetRotation(), IsClose(rotation)); + EXPECT_THAT(obb.GetHalfLengths(), IsClose(Vector3(1.25f, 3.75f, 5.0f))); + EXPECT_THAT(obb.GetPosition(), IsClose(Vector3(3.928f, 7.9156f, 9.3708f))); + } + + TEST(MATH_AabbTransform, GetTransformedAabbMatrix3x4) + { + Vector3 min(2.0f, 3.0f, 5.0f); + Vector3 max(6.0f, 5.0f, 11.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Quaternion rotation(0.34f, 0.46f, 0.58f, 0.58f); + Vector3 translation(-3.0f, -4.0f, -5.0f); + + Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation); + + matrix3x4.MultiplyByScale(Vector3(1.2f, 0.8f, 2.0f)); + + Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4); + + EXPECT_THAT(transformedAabb.GetMin(), IsClose(Vector3(4.1488f, -0.01216f, -0.31904f))); + EXPECT_THAT(transformedAabb.GetMax(), IsClose(Vector3(16.3216f, 6.54272f, 5.98112f))); + } + + TEST(MATH_AabbTransform, GetTransformedObbFitsInsideTransformedAabb) + { + Vector3 min(4.0f, 3.0f, 1.0f); + Vector3 max(7.0f, 6.0f, 8.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Quaternion rotation(0.40f, 0.40f, 0.64f, 0.52f); + Vector3 translation(-2.0f, 4.0f, -3.0f); + + Matrix3x4 matrix3x4 = Matrix3x4::CreateFromQuaternionAndTranslation(rotation, translation); + + matrix3x4.MultiplyByScale(Vector3(2.2f, 0.6f, 1.4f)); + + Aabb transformedAabb = aabb.GetTransformedAabb(matrix3x4); + Obb transformedObb = aabb.GetTransformedObb(matrix3x4); + Aabb aabbContainingTransformedObb = Aabb::CreateFromObb(transformedObb); + + EXPECT_THAT(transformedAabb.GetMin(), IsClose(aabbContainingTransformedObb.GetMin())); + EXPECT_THAT(transformedAabb.GetMax(), IsClose(aabbContainingTransformedObb.GetMax())); + } } From 79a34f87b03aebcdd10a02dbb7424b629a0fe9f0 Mon Sep 17 00:00:00 2001 From: greerdv Date: Thu, 15 Apr 2021 08:28:50 +0100 Subject: [PATCH 03/27] fixing merge conflicts --- .../temp/128x128_RGBA8.tga.streamingimage | Bin 0 -> 28066 bytes .../RayTracingAccelerationStructurePass.cpp | 2 +- .../RayTracing/RayTracingFeatureProcessor.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/TestAssets/temp/128x128_RGBA8.tga.streamingimage diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/TestAssets/temp/128x128_RGBA8.tga.streamingimage b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/TestAssets/temp/128x128_RGBA8.tga.streamingimage new file mode 100644 index 0000000000000000000000000000000000000000..b867b7cfb19ea2f70157e69cd9534fd8bfb04002 GIT binary patch literal 28066 zcmeHw3tUvy+Www_jG0lKM3T}r0q0=BDqi7`=Dv~mQ43nCrM-=cf zB48sNjRQ{PWiZ4M%QDSUw7?RRDKCtmj)o%_9p?YMdpYVsJ$?PNb2{G_zkWZ@Gi%T6 zz1H)-&-<>m-n9?Mah%ipf+1`2d!%I!bJ^sa^oYLfy(uHV%TVEczi2)X?Y zdpzG13{KTgS=#*4mR*gV*1q=r7fBJz9v$H`?0DLYWXsF>+O&6{Z}V-_LR_!mBCMm% zw7+{xb6%I|yR-;6F8qh&xb*Y7?M|OJzO;Dt^>?PHI?oKkV}-vUI1zEj=WV!%lRM{B zXMCM>ZH#P0(?4F>UbpMJcR#`Hhj9D<@ym)R!MwQdzu#N+LhlXo!#^GE>!uBVBtsE@ z$M4|x=Wmrr@A#bKMn0DMqRQv{qIS`76GyFCyS{AZqqB$Xe?BPEPq6IZd%d6DJ92H| z`cI$gwE2loCM-Mg@WMGILF2j7nEUHT?ii}S#^f(M z`M>BpTttN546nNgB7`i$?Xmigjw#}&D~CVdbLHQE+#hi@D;A$W$VI&Ryid;EzqG&l zZ(RoplJ_i~8UEOdeYQ0F&wQvfRuyi#vMKj28W(<|Df3$E&+T?D{ITf2ooxL%ZXMoj z+V=Nae~#-TYT{!?-$jej39&x^$-9IbwA`~35z{|)PMts8H#_>xmlqfLt{#_uBC*tt zKQ1Er_{XVt?>ILyV%93t%!bvAp4v7s<-IG4`gezZyE>foy7dE7NB;U8!S())12?kf ziY@4&8MecH(;^=J_`7v09ynyvjHFSXXxcs^DP+W>>GpS=`n_SB9)9xD5%0TE5-~I6L|MKr((2%9k3ts*}lcqYbch>GI z$HmArxQG{jX*qcpGZJzmzwWf^v({g|M}8IVQJ!-8E)N|3-sbXNcYH43Mh=suPWXKW zifrYshAX_s=T7(d-1#1#KX8xF@1LRE{rUg+-{(fYvwXvYvz#tBr0$Pgz1AiA#pUxR zhVcga;F}9a6rUdY-iB>K2|w)|@{j$|vmSrxkIr@@Hv5dadKVMy%0&pjy?*x279q@b z4A;HOoh?DI==;!-pnIn6Xt{UVey@&5@6{1F;5|Aby+0l4de4ra<+pdlO4FogH$ z2wHx7M=;E+5x)hoIe>N;&&qvuY|K~(_iLspnKL~t%-e6HTkR+Ge3fgkP zzu4#biJm8HE#n>%0LKg#Od)J9;M|13Gi6*9aw56CkaH6RN7-W}K@1n%xLy+ExV{}X z=4bm`l4$<-l+BzAem^j#T`G^|DQ0JSp5>|fu6Q81Tv^MWcfp@_JpZKpI_RYF&GxTR`duy_ISWh;|B=?v^WP_);BZob>Ao{@jK8XcxLH|9^7KzT;KxEuS;-L)rmITCf_`do4Cs5CLZ|6n4`x#i-H{2 z_wA5!w6e2kX8`M~>)4_p8-;J}@TA-dz%X%A+f%wAXSTf|Mxx=5~7i zc~hEoVlMb+uM6$B@b;omHwwvKf)@<9*glkJyR@lCO)l2;z1otF045-K(xtsfz(=7C>;J|Q;ZhaWvFwv3h+PL`#{W& z(>+ANAtQQO%L=&h1IQkF2$qH}_9YxPq>0Cc;Wd85cX&{6RB2Tk?qIn2d4|FFZFs_S zj92yD3b3XTiXUkr~^gN1|0?pt~geB2m`Yn(uTWWPr zyQn{F27U_mqJTX-Ca|BfZ(gw_5B94_X)%kSFJ9Xh9$|W-Z2WK64`$yP9Ub=V${qNi zI^~=z^{>MEoTP{I0bA)a$G~q_&T1=?`E@9%TXW`f#;;K(4(U+>ev84UXE*RI4jaJu zF2ML(i+T&E4R4Cs0sh-gbr}kNg)_&1|1$#wqh>^hpq-nmVEiwSD-0)o6C)4ID)sad z98Rj^@%$;lQ9Ho5C8_OHYM&nkJ-7`gMS|}tmms=ciT3yju#fJdksrk!lbdZ1-*b9lQ{=WZMabI`eQV~z%%Z(qsBBc-~Lk9YGH+_rR0`tj${3&!`l zn|!;0@3NF8S9<;mtI@~%!IC8H#m_}g_3GwgH5N&RJq8TE&Cl=kAbwwcmhsR0RVIF8 zL<#)=bCLIqp5V7o94{w4K=e^uK`8P6?o`IVbkWmONe@=cV*JN0inckU@tqz^{x6xH zvFf8Z1@wRMYrMZt@3Y8z2Kd$_D!_MVNzCD-gW-ylTHTD1SNFpIQ^`IR>So=90amhy z)WUGmlUm)2Pg?gjKiV$UW#}o7lxDN;S&?;EGukP>fPUShf|R3yn^#njKH~c(R{|>w> zm*;<^u9s>T+-gfGjezvkAS^PNgd*M6L;UxI8u}GF0&G>$0*{B)B_Xah?ZaJ1D zBm8}9TFDI30~&9uu~586NA@s4rWK_33sj`{;fZ;{BM0j7arH2_Mwl#;h zKjPf28|*=45_9UKUa$w^OQDQV{hFS)Zf`x`_7EJ%$x4ZLBfYU2y?y*1iskuUjQN$p z+eaezjcu9(z6+3VgKt^vXl4&Fh<8RGnK(6?*~2S{&twmq7A7>!fj*F4!hFQLbBOQn zc)kfA-3t4Fzptw-HjqA?-dA#s^1~rDgZ7bqTs~GZW96CcJil;%Vbkf7x{MS3M7tY? z)KGq4ySU^+#tBc(Zcnx#KJ;#}HvKrK%2Q;w?`{C!VtZro$*oyEcwAvw%Gn#o94*dj zGm_esz%ACReT$E_3A%B;#%5_5R(#wgn0_y%r9gM>>{aA%qG-Aw(s{1_2kS88b1`Hu z3bk2NbHKWn^qRL1*h6J8@heHC{t#cE>A)}inb!+^Q20Lh1SWeRf6kc6_@#UXP!~Ur z;pK5lL)DFD)5L+B`(6!ix8)%62YlTe@Cdc1Zu!zLSE^1lo1PF@w*?feu+sckspj*? zpFLmtpX&kqecjq6THfC)Dy;o`K9CSU&N59*`KhtUM;824Y<%3sX|AM4M)3W{aN>KK z>(j`8fhF%w;rVx^{EX~jgPPex$Bm@tg|gC2hRGicFc9z!efaJs-!%uAK6HV9QT|~4 zv7~7Z_$U9R_+Yz`P&emHKY@c^dqeDmnJYbkcQ+ViLe75uaxv{d+U?c$A~F7LAw(FZ zK>WWffBqk1TZ~Y5`}dnp=cT7H`#`woS}a%kRvvYk&f5p{ywP-pkJq~!I#(0lwO?Q0 z@gz&;A&TFX#XO&Shdq?72Zq1%`p{_BZCc3qCjTHlm%h&ME6bjqN_@W+!s8>OW(0?* z6B|vVWrd^Lu^B+Wt!_^%)gD^-m+Kw17DmhrhHuwy`MLpw+~m!X9%y3ONftyy^x-f zJ#0;5_OZs0v5M^F>&;9*NY4qM{(|8y@NcrOt3Q%Hj29E%M!ihZV)1=rbWRZX&9RU^ z*soo#Z0E%I)f3sNbq-L3*po)WDk+*=EfbXHxr**D1QK*rgbXfv)z$zvkxZ`zw^ThuQ)>U3$?1z z6fwB4`&IBw@fO$|@Ms~mSCAfnesdSWmA-)m?VEGKr&^_=^{1nrx8(=OAG4<|(LycQ zUstCDtzuwod(sccz0c5YzH`S}CW~plruX)dMGcFE9++GyKQZEig;9j3@%|1h%UwWt zvTMhU(nZAY9v$=o?G46`8(}|^%)()w?rcRkMsR&_H&y(Trxo)F6DJc{sw!4r z4f!bi)%?XK^5+#t2JIWak@(JkpJ5gs5*wFJXZ%vWtOmi+BYDj00r`8dR~~O4J+U68 zQkhL&ZR)!FuUlcI^|Z)Hm8uQ*@@HO2!oY5nA1D-&ZMY@cu#$8)!WF9xhTbAS_i^Vg zxzhFhy}i9(miev@1)sFurT6ysd25s}&p*v)$sST?`gS6Fpm;@Cznrzx^8(7g(o_3n zSBJl!{fhMAv@6-a0bgi5<=YT?cC47S1(56wS2UFIbD zqz5LGMuUi-XC2#4Uu_>!lh|Bqu0727i@ z-9K!FmGqVTJ8m3nC;d%?e}_Jc?}x3ZAbo~?sQR?a&9jEBxJ>atg?0&dWm`b)!WN1L zkr5H|C0vPCk+7Pd&-L%$-@8wH;`@>-T@Si_Li;gH>z^Bl8k(l@=2kI(tRa0 z`>%B;=C7d3T)IBDdo%d1#CXCSOxek~JpbQjTau_fabj*>6WVFL5_GF3_~ZKU71n~# zFZ}>b13R(nX+Hy4^^l-0FTlKz&j(bh*|S{*39A(e>3qINeD!#y>qT{8w^px39GW+NnQimtC$R z{x7*wf9dyZSI*6L-DKkZ-JsX&k*^_A{f>O?-_7rDylFQ=)R6{KFPnX+0ZIHR*Y@uU%n1816EZ z@ZiVMzILJCmzbXueppyb{0Go{Za%P70P^wQ6zBo*G2jv3huWV@1OK@^|6u`_rGyKx zUPtYTlY#Ny;iU6XgtHegOzWkDcjft}yTX2G{fzMOz4$#`LhC7n>rK9^UGaOEe^={) zTN=)#iT^PhI={Pt+W+hI{@3iGX|2=ca@PygU$e<%x_V~q!v0|k`&0ZQeyaC_EZ}P= zCmbUD**|pDZpCVpo^am#xqN%ajjt>t{Lbq-;-1{Ga3bE(ophYX^RQmH)qk+{;q8Tl_QoxXFJtoF6|){1e|T z4IfIy8`A#o@ZT(T@*V5cpXCE4^VKsT8_=-?E~G%-OT@XST2no=pIM;AM8PYp`r%gUp;OT=6m$}wu_r)k3QFN z9OZvLMS7$Cx>FzS@iff$|Ci){HjdMA;;xSV*e;igzmXP!{~U|iT$_0LxJRlrystmy zL(^5Nupf+JK38)C{mEazJXB`|L3bCvEG*+wnUpv{2L6`irymT&s0wXdY*gf z>9f2))BF#7>0?G+BpgTcKN&t)G4tZ3(Z25SH2)*4U%_7=Py2Cz#)Ep`f$s4%|C9OX z^=A*BC3}dc`Ja!s-q3Vo~ z8k6aoSt>aa?gM|1r~y>fmV4-}xn=%CYBCR*pa(~`g{2Z+SGmT}*qo@|zB&x;+x%(% z2YX0d{Wjq;f0}O*jvG(c_w^@#1iy))eHo_tA7Nit;y=*;HTW~}FX2o@Ew#hEh;LOy zM5Gh9BwZDp{drfYu3>dWMK>qQY&XOMTK|E38;5mc{L%h2_|;Dx2EM@`t^W|ei>5L@ zDgL0{n7iOC@fqI_`Xuw#8$Z>ZHH{wFDW2B5ee^~{m62gu|A9RiFCW`Dc{Hx4`Jeog_1wNJurXo=kWKI%jG?{ga`VQzw6-dS5A}{9LX&U zp!FYfV`60WXVSt7@Jaherbd-|-zE=zMP8Xdb|>|qH!^<-Zyy1)o`UAcrP0h@X#K~m zN>oRO5Z>lb>%q8Q9nzERW1D|4*5~p2i9Oqd6*c8<3!wEJWQSPqnf#r#@azxKsQ`us_0U z-X^S#-wOMbfZuKD^nI=*PJztNu|d(bA39>|J}XZGbxCQR$Ugs+~=hCOJtG(KYB zmP^^?!Dl;aY5WM=uXBhG(ph8=oKT|wkLL&1;W&F1!!GeWoX%{oPwSET=yTwEeS^;2 ztZw?bJpahl!|?YZH74+V?jZP{dN_dekMPm09)%Tohk1WD!{0yAO2Pl(fMSf72?S;( z0K-0L{TEQ39M0^+g7sg*lZHt3)~GVX`x-ykPhvo4W*@ZvOW*GzTR_1}Bf54j*8NIH=9Iq5@xLq$dJHjGcQA4GRU@KYO2? zad8y!tJRVo5dXO;xE`3+gJnKO!>)AMF#w%y@>zuP|e zd~|{5&EIS0oJT%+Fo3@wm*3oSDXmBP)E|N2-}%kz#-Gabw@e*1nDRLdaNQx|e@x&c zOTr;@ZF9=89q@nfzZ3Zo*~h0Jz#a<61U4Ama&+cK^@odq!9VGz3GIJ-gJIs^VJ|a7 zJY4JG*J^3MAMR_- zU&OE+`~9+_GGkdz4%tU3*#r6aciV{X%+kz5#RkG>z6747EhT*bw*B%0;mpz;%kfHK z?;>OK*_Gv^=4Doqe{td>tId+JXVf#9)np&yf--B%RbiiC@5~d#m$1Mtw>JrOF+DQD zC+wx5&~9(yK92Ep-~xLK-d+>!IWdrL&$laVmo=U--D7~kZ$Wd)HM3?@>RUesQvBvL zwdyNXY57~GO#;4l5_Buf2f_ba%0RMTojFnY{f_dUTQ@5M9enT21^;=URz4>f%wdbA-&gTQNBnx|6Sg{OUWL37na#} zWdX-$-mr%<>!FW;=Vg{s{z&|vC|gPG)s#QL-EHQtSB{-IFSDA)TiCnIYB| zic8;X{+{~Qg+R*Bxq=k=xkG82(%*{V`Gxx{t3NH@v}JQlAg$NwYSoG(TgpG#vUyS< z~<58&TpUww9dZA;4LCBWdH;Y%jp6GZKs&O&sYAczqjVQHEx|B zNV$RO+9g>hC_c3JHdH+GAmjfj+#m994erkKs|^l0)A|$PANPU(d0C#s7xDk&myCZ0KCxG`Jza0}qWQN5 z?Zv_2U7$LW8+Ek3w&&s>f#$*QLNLk=o@MT~Ew8my;qO%M(7UM2s+|je2j7%WLho%G z-{t+iitK~@{p0kNLFE6ueH7X&O0o!N*^9CM#Pu$+?#}B#_&Tkh5Z`+~r`pH9#FnU z_OSE~#y7=p=z}tTJj0}iWDiq=%JU82zwK1`x4AiGR8O?S{~de}XbTMf!MD@|f;$Vs zjLp_lUNqi>ow%^yrSGl%{kLKv7oF}Lyzb_CCwIZcOWLNK(++#^aX~&0e`q4!x)NM|kmT;2*dT@=M}BJr@2yFRMCZ z)$%wo_|HsYeAD^}>HYe5z&H4(`flP|x0u@#Q=H{V_Ct8Xd*Ht~=O+GO0r-diJFZ_h zAN<2U==X5Fa%CLjpYEqAXi+YCBaQ4Kknw9*%nv6$u<-g#`tVi=@jWY$=4Yh$69*BV z6iD@3I^=`U^ZYIFck+*X;J#wuY05x{e|Hgteba2Uc;yn`@ONi!?Y17jBcA_Oet+xr zqz|{xC#4*-2Z|RGA8SPq=WG+jZ>k>^7nRutcLd)vGfOF-6hhx$>dE|_<`>WlYxp4E z->Z4OD700){sQ5wYSKsOfpzvPJpb33e%R#k6Bz$gKgsnjlP4<~K8*b_;#)n9_|NgQ zBt7lGAIBJO;pE9Y|7d5|Crsr1-;?$`xqQ2PPAKD>?x(4>E2fWR*qitTju=e-e*ye{ z>8FAJkCqXh6iD@1qz3_y5dSfOG(RJMm$fPXw^!2Ut2N&+*?9u}tcv3#;W0lLh2+qvbmgQV0`xY13tWQ74`}+xsACUWs z!4LENSJ8PH_`mf9Pp0>D-bz?dRx!p0{Laj(4i0&(7wP@0gBahmUQPMm#K4T8ImKDm zX?{%nM+`;$hyT<1IFE;+q+g$N6Hg3ceBZcUq3~z=Px~Kq{VTqR|1lT9=VD(jzePT> zM;h{j3xU00uf+dzkH8*~FMbGqNgsSfz~GnqqpM9(JRvOK*?hI$i`Lgbze3E79c5Sl z!sly^kqSBH=YMGY{!iOO>-$suxILc`ac5^|9mw${z3{PB$UV4h)0(mzJH->&hurgl zm1F0WWu2z^hq%aI;Vof&Q+$Em%lma?_;u(B@inM3^uIXk^d{_Q16K@wf(x1n|EK*B zY9IVK>;e2cuwNI%1Ly&r52f}2?o9t_{fn?qTi~~BUc{#c^Mf93z^}pXN%hyd<`j8n zLHYjUSM9uB>zeIK2`4?++_IAIk4deN!=F!)K0^MuNVy#6x&i)+{riu8egP-=r}ar^ z?qu30w~d#GJ281j(+B+c%ItD^dv2wv*v>FlXp?soGR)hL-7bGvC@iP;DA*J6=`Q5< z5TqyuoL_TK<2|e;?rOcYPy9@B?vKUudZ8Jm17&|lT_IDdrmC?CbS z45j|7hK|AcLzf^2p3|S5KcegDyxEk;*m;xlQF}db{zUhplbX&GhEGiIUR!y%axo zKF5;ur5~NoTR)NYzdpMz9Oo~DTi@o-V+rQ!>HJ=AZs#JL$3p)r4X-St{_lL3KYtf= z%*gPzdG>GVy!{#j&con5^@d5T|86=1S@O zj5p5DdetqoGW&`A&Eo-n*PmFD*@@@3!q8tKLH#<;t5AP&yiM}Aq3nFZE6ajI=zL1? zEY|wk^~J3Q$BFJDmq+u*!W z7?0}=)L+qbx}MIL|FDjoAKh75pH1flOXAr1l48T*BsyQT;zgV%!TF)Bt9pgd`GN>3 zt2bX7x#H`rpU~c*?;d>vr)YrdF68Mo&S+1zC~GyG?Xb0P<#BOz zwS8SB@q2a?@!d{;?PR}==&r8hZB|cT40{1KEec>*y2xcH>g&zH&gc93qrS4|P&zNC zYNYpfcqT94^DVhtF}^c*ASZi?wlnD!j<@xn^awleP#B(vdUtPGPB_)GPjju$J{V5* z>J@9KUVWN)C-|lF3fB(e`m^PtlMR`N==__#e#3BqQ&+x!-je%pKH;i|Q$Byb0QG`< zXgp9q>>){|@u2e|$FtaZft{6ZIq04#Z!)VV?zpk-RH`4J)|KJ9@Y7vUFKBv_Oa9Dj z&Vm54Zv_f~WvKsF_@%o&1wA$x`ad_zm(}Zznz5L#_x(7|*Gl!kz><+dTrEm z52;y0<=Zm5`P?+|`mw0jh^Rq*{vThjeSWOd1&#Q9vJcf{ljg!Fe7*CLNtRRCyT z34gMH;bH?$c;oNVUeqsQJd)wRgzXL8E(so=%%49JiJY8%_kPo_)(>igW=&fS`Ols` zdo)+}=b}Dvg>`)cs~6n8gy9Bb>@sZktLDFedcm~|Q6JnZgs`9U&rbfR2gB@zum3~; z)6sv_``qY%5MS>%?q>fNq8{X&beyCAm-nLcz_#2S% zqDCnBH`FJb*SO@Dw?#ckvW4nLE`EagA=Gz}{iA#&aYrKhkNP39e_+*IKf>KnAHvsz ztDfa_P60n}3wRCvRjDE(J7d3Bbs+Nu>0f^ofJ8ou{$YRjAoP#=mot&?Z#>0wU}L3r z6ZU&L#Zx?zVSo4f*I4hhbc`pxm&m*g_A6Xh&Rxpab7Ft~_t$G+KQ2ha>SwUgKHFAa z?s5e66xCSa$99OiDu?ZtAFu4Vk@iFKCS!jb`{ks6wEsD+8}`GoKTi5*!uUMNnY()> z9rZee{-XRv@c?%K^Uw936#v{;%jLs`XD@}uYPA&qB&bi)__O^i%5SipX)KOqnDQC) z*LXUQt#=QpK|KT3H?M!=Ha6rLZE3YV;SlXt;gvvr1V2*!0`?1qy^Z!p+-T)0yqX;Q zkDSnk{YQ?=c%AJxa&YVOcvt7qudtt-Y{CAb(pIkNp`SV_ko2C`i)-@P{$b~8>^EQo zpmZMF51{x*_}xH;rHg9(%)lYeY=4O2AGU`hMcnM8v>!<8FXLambN<ofKH*nV7&Wx^qvZ`JerFE%d+zOV!9D_B2?sHrs2di(KgwqAA|@r~Bc zcFrZN40QB2JsA5Vz!|HSVt-VvoYaBsuNQ>odB8p*dvK<{fyuvkQvRdD`bz8kr!{W9 zUe%jxNQ*y^bDGxYu-zq}&<_1YeFEiIV)XwVf7XA>M``_97s1vm>$A^CVL!^cJ>HGq zf1vn@^(yPG#jO97?^6GFy~po2csZ~^#jiJD|HzW0!TLh(WLiJE5J>h+{eL%r_7|0b zl;6;P!lZ{V9#fTp)L+^^>cfSV1)#qp5Z|c3zjr^V^>}o{c$C6l$UeLca`_8R*<h`7iqpYj;%Kh0N&|2h5n^%#51j1T$sv&7;2dW`4cq@MixTjFrG-s-?_4`l0Y z%j0PM&aRx=mG!?a{FDdw)0Dx^)PIW?*)!H#6i;zsV**n$Zu0wk``g+cehs%l{5Xw} zNApn(hx~DFxjR^{{SbhPe$4-zn<2M=zf31`cVgd{z9V2U77w%~mOMY6ANyboy5KD^%v^UJyv_I|gB8a7|7 zdk6EyDwmN%YGV2MD6|e-!tnp<-z=XHMmN+0s&IeY9FK78{>XPwpWmg1<-7JvxcLK8{`|F2=!AbU ze)!LhKXez*)e6^h&XYM8@r$!zOYck?-vt>UdzjG?DrAhq|b{4Qd#BZ zab9G96rVge)z373xwv11;?DTn5%su^=jjiJd6mnVt;Kpc`IE$0A&+%}o?`!E)QqmY zUc@?)Ugq4yVO;tCW_1Rx@5<47vj;c(mz(#)@3r>7*T^3ZWOZB~$NOLZ6M_RN^ggw! zlX%~utx)_U-am!)CcOU!?@vsr)x1g9&ld(@cMSgeYS?iu0q1)!xh5Q1fcJr5KJ?j! zARKpuU3lyh(ZBnoP8yEp^Mm$H)^J?40Oyfm66-3Xq&SYOs^aiv-_`N-eSF6&pfSr{K=saWO8=NRT8;?Zx`_yW={G?_ z>3M}%|2-+7{aU*h-A_}SB7ciB?e&75(({KQ|FPqJMsXir60C3N=2D>-N$i~ZS$}E! zuXi`#eSL|OO?K{y*InstanceID(blasIndex) ->HitGroupIndex(blasIndex) ->Blas(rayTracingSubMesh.m_blas) - ->Transform(rayTracingMesh.second.m_transform) + ->Matrix3x4(rayTracingMesh.second.m_matrix3x4) ; } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index 99748677d9..d5c9bedf80 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -295,10 +295,10 @@ namespace AZ for (const auto& mesh : m_meshes) { - AZ::Transform meshTransform = transformFeatureProcessor->GetTransformForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first)); - AZ::Transform noScaleTransform = meshTransform; - noScaleTransform.ExtractScale(); - AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromTransform(noScaleTransform); + AZ::Matrix3x4 meshMatrix3x4 = transformFeatureProcessor->GetMatrix3x4ForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first)); + AZ::Matrix3x4 noScaleMatrix3x4 = meshMatrix3x4; + noScaleMatrix3x4.ExtractScale(); + AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromMatrix3x4(noScaleMatrix3x4); rotationMatrix = rotationMatrix.GetInverseFull().GetTranspose(); const RayTracingFeatureProcessor::SubMeshVector& subMeshes = mesh.second.m_subMeshes; From 2bfb93e5e1fec303714a50df7fc7f03fac862c8d Mon Sep 17 00:00:00 2001 From: greerdv Date: Thu, 15 Apr 2021 12:34:35 +0100 Subject: [PATCH 04/27] fixing non-uniform scale for mesh on activation --- .../Code/Source/Mesh/MeshComponentController.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 17ee56f36e..59f4a8a92a 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -293,7 +293,9 @@ namespace AZ m_meshHandle = m_meshFeatureProcessor->AcquireMesh(m_configuration.m_modelAsset, materials); m_meshFeatureProcessor->ConnectModelChangeEventHandler(m_meshHandle, m_changeEventHandler); - const AZ::Matrix3x4& matrix3x4 = m_transformInterface ? Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()) : Matrix3x4::Identity(); + const AZ::Matrix3x4& matrix3x4 = m_transformInterface + ? Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()) * Matrix3x4::CreateScale(m_cachedNonUniformScale) + : Matrix3x4::Identity(); m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, matrix3x4); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); From 0c10e769c5bd9c0058a51226782e687590a61e37 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Sat, 17 Apr 2021 00:13:14 -0700 Subject: [PATCH 05/27] ATOM-14040 Add Support for Cavity Maps Before working on adding cavity map support, I am replacing the 010_SpecularOcclusion test case with maps that make it easier to distinguish what's going on. The brick map was just too noisy. This simpler tile map will make it easier to see if there are artifacts like banding that get introduced somewhere along the way. There are corresponding changes in AtomSampleViewer for the baseline screenshot. --- .../010_AmbientOcclusion.material | 14 ++++++++++---- .../Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg | 3 +++ .../TestData/Textures/cc0/Tiles009_1K_Color.jpg | 3 +++ .../Textures/cc0/Tiles009_1K_Displacement.jpg | 3 +++ .../TestData/Textures/cc0/Tiles009_1K_Normal.jpg | 3 +++ .../Textures/cc0/Tiles009_1K_Roughness.jpg | 3 +++ 6 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg create mode 100644 Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg create mode 100644 Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg create mode 100644 Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg create mode 100644 Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material index 66843b3a2c..2c0b6767f3 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material @@ -1,15 +1,21 @@ { "description": "", - "materialType": "Materials\\Types\\StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { "ambientOcclusion": { "enable": true, - "factor": 1.25, - "textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_ao.png" + "factor": 2.0, + "textureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg" }, "baseColor": { - "textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_bc.png" + "color": [ + 1.0, + 1.0, + 0.21223773062229157, + 1.0 + ] } } } \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg new file mode 100644 index 0000000000..3494ef8a6c --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de6b49c1c4965896a190ed5f40c7d91f9deb942d859fd96264828df768098a83 +size 45257 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg new file mode 100644 index 0000000000..bf62c26631 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Color.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0172df6b91bb42bf6c41d18a6fdb7088397663d71f0c2d3ee504a4e91a7e5e98 +size 426462 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg new file mode 100644 index 0000000000..49efd77e18 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Displacement.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9de0bb2f58936658e8bd3599e487cbd6af3394c772d3132cd77a73774cfb5994 +size 230692 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg new file mode 100644 index 0000000000..c61e7f316b --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Normal.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48a8690b74141da4e7e06cd10b47f0eb787b5333a915cd1e048ab24bec485ad0 +size 759052 diff --git a/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg new file mode 100644 index 0000000000..bef45f0995 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Textures/cc0/Tiles009_1K_Roughness.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddd79ef9962100cd5a9eec686bdcfb98db19ab410329e50df53d6781f9d8b441 +size 421004 From f5cb6f438b09da7cb5c353d25903549fb7f93e3e Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Tue, 20 Apr 2021 00:12:53 -0700 Subject: [PATCH 06/27] Making room for specular cavity occlusion support in the buffer. We can pre-multiply the diffuseAmbientOcclusion into the albedo term output from the forward pass, instead of multiplying it in the diffuse GI passes. The difference due to precision is negligable. This can be seen in the corresponding changes in AtomSampleViewer baseline screenshots. ATOM-14040 Add Support for Cavity Maps --- .../ShaderLib/Atom/Features/PBR/LightingModel.azsli | 8 ++++---- .../DiffuseGlobalIllumination/DiffuseComposite.azsl | 12 ++++-------- .../DiffuseComposite_nomsaa.azsl | 12 ++++-------- .../DiffuseGlobalFullscreen.azsl | 10 +++------- .../DiffuseGlobalFullscreen_nomsaa.azsl | 10 +++------- 5 files changed, 18 insertions(+), 34 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli index 678e8cf061..71e283291f 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli @@ -79,6 +79,7 @@ void PbrVsHelper(in VSInput IN, inout VSOutput OUT, float3 worldPosition, bool s struct PbrLightingOutput { + // Note some of these use special encodings, which are identical to struct ForwardPassOutput float4 m_diffuseColor; float4 m_specularColor; float4 m_albedo; @@ -98,7 +99,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN, float3 vtxBitangent, float2 anisotropy, // angle and factor float3 emissive, - float occlusion, + float diffuseAmbientOcclusion, float4 transmissionTintThickness, float4 transmissionParams, float clearCoatFactor, @@ -213,7 +214,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN, } // Apply ambient occlusion to indirect diffuse - iblDiffuse *= occlusion; + iblDiffuse *= diffuseAmbientOcclusion; // Adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); @@ -259,8 +260,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN, // albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc) lightingOutput.m_specularF0 = float4(specularF0, roughness); - lightingOutput.m_albedo.rgb = surface.albedo * diffuseResponse; - lightingOutput.m_albedo.a = occlusion; + lightingOutput.m_albedo.rgb = surface.albedo * diffuseResponse * diffuseAmbientOcclusion; lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(normal); lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl index 9b4e703f89..b3b26c4d42 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite.azsl @@ -24,7 +24,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass Texture2DMS m_downsampledProbeIrradiance; Texture2DMS m_downsampledDepth; Texture2DMS m_downsampledNormal; - Texture2DMS m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2DMS m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2DMS m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2DMS m_depth; @@ -118,7 +118,7 @@ float3 SampleProbeIrradiance(uint sampleIndex, uint2 probeIrradianceCoords, floa } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; uint samples; @@ -160,23 +160,19 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(screenCoords, sampleIndex); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(screenCoords, sampleIndex); - float occlusion = albedo.a; float useProbeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(probeIrradianceCoords, sampleIndex).a; float3 diffuse = float3(0.0f, 0.0f, 0.0f); if (useProbeIrradiance > 0.0f) { float3 irradiance = SampleProbeIrradiance(sampleIndex, probeIrradianceCoords, depth, normal, albedo, ImageScale); - diffuse = (albedo.rgb / PI) * irradiance * occlusion; + diffuse = (albedo.rgb / PI) * irradiance; } else { - float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal); diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl index 74571b5c6a..a5d761d815 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseComposite_nomsaa.azsl @@ -27,7 +27,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass Texture2D m_downsampledProbeIrradiance; Texture2D m_downsampledDepth; Texture2D m_downsampledNormal; - Texture2D m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2D m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2D m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2D m_depth; @@ -121,7 +121,7 @@ float3 SampleProbeIrradiance(uint2 probeIrradianceCoords, float depth, float3 no } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; PassSrg::m_depth.GetDimensions(dimensions.x, dimensions.y); @@ -162,23 +162,19 @@ PSOutput MainPS(VSOutput IN) float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0)); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(int3(screenCoords, 0)); - float occlusion = albedo.a; float useProbeIrradiance = PassSrg::m_downsampledProbeIrradiance.Load(int3(probeIrradianceCoords,0)).a; float3 diffuse = float3(0.0f, 0.0f, 0.0f); if (useProbeIrradiance > 0.0f) { float3 irradiance = SampleProbeIrradiance(probeIrradianceCoords, depth, normal, albedo, ImageScale); - diffuse = (albedo.rgb / PI) * irradiance * occlusion; + diffuse = (albedo.rgb / PI) * irradiance; } else { - float3 irradiance = SampleGlobalIBL(screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(screenCoords, depth, normal); diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl index d6a0de8159..dbc134d2ff 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen.azsl @@ -21,7 +21,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass { - Texture2DMS m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2DMS m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2DMS m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2DMS m_depth; } @@ -41,7 +41,7 @@ VSOutput MainVS(VSInput input) } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; uint samples; @@ -76,14 +76,10 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(screenCoords, sampleIndex); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(screenCoords, sampleIndex); - float occlusion = albedo.a; - float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal); float3 diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl index fe3523210a..803046efd4 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseGlobalFullscreen_nomsaa.azsl @@ -24,7 +24,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass { - Texture2D m_albedo; // RGB8 = Albedo, A = Occlusion + Texture2D m_albedo; // RGB8 = Albedo with pre-multiplied factors, A = Unused here Texture2D m_normal; // RGB10 = Normal (Encoded), A2 = Flags Texture2D m_depth; } @@ -44,7 +44,7 @@ VSOutput MainVS(VSInput input) } // retrieve irradiance from the global IBL diffuse cubemap -float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal, float3 albedo) +float3 SampleGlobalIBL(uint sampleIndex, uint2 screenCoords, float depth, float3 normal) { uint2 dimensions; PassSrg::m_depth.GetDimensions(dimensions.x, dimensions.y); @@ -78,14 +78,10 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(int3(screenCoords, 0)); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); float4 albedo = PassSrg::m_albedo.Load(int3(screenCoords, 0)); - float occlusion = albedo.a; - float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal, albedo); + float3 irradiance = SampleGlobalIBL(sampleIndex, screenCoords, depth, normal); float3 diffuse = albedo * irradiance; - // apply ambient occlusion to indirect diffuse - diffuse *= occlusion; - // adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); diffuse *= iblExposureFactor; From f0ae8056c81416a51f3df8a0cfd5434bcb17b115 Mon Sep 17 00:00:00 2001 From: greerdv Date: Tue, 20 Apr 2021 10:25:19 +0100 Subject: [PATCH 07/27] feedback from PR --- Code/Framework/AzCore/AzCore/Math/Aabb.h | 2 ++ Code/Framework/AzCore/AzCore/Math/Aabb.inl | 7 ++++ .../Atom/Feature/Mesh/MeshFeatureProcessor.h | 6 ++-- .../Mesh/MeshFeatureProcessorInterface.h | 11 +++--- .../ReflectionProbeFeatureProcessor.h | 2 +- ...ReflectionProbeFeatureProcessorInterface.h | 2 +- .../TransformServiceFeatureProcessor.h | 6 ++-- ...ransformServiceFeatureProcessorInterface.h | 13 ++++--- .../Code/Mocks/MockMeshFeatureProcessor.h | 5 +-- .../Code/Source/Mesh/MeshFeatureProcessor.cpp | 34 ++++++++++++++----- .../RayTracingAccelerationStructurePass.cpp | 3 +- .../RayTracing/RayTracingFeatureProcessor.cpp | 15 ++++---- .../RayTracing/RayTracingFeatureProcessor.h | 8 +++-- .../ReflectionProbe/ReflectionProbe.cpp | 8 ++--- .../Source/ReflectionProbe/ReflectionProbe.h | 2 +- .../ReflectionProbeFeatureProcessor.cpp | 8 ++--- .../TransformServiceFeatureProcessor.cpp | 20 ++++++++--- .../RHI/RayTracingAccelerationStructure.h | 6 ++-- .../RHI/RayTracingAccelerationStructure.cpp | 13 +++++-- .../DX12/Code/Source/RHI/RayTracingTlas.cpp | 4 ++- .../Vulkan/Code/Source/RHI/RayTracingTlas.cpp | 4 ++- .../Source/Mesh/MeshComponentController.cpp | 23 ++++++------- .../Source/Mesh/MeshComponentController.h | 1 - .../ReflectionProbeComponentController.cpp | 2 +- .../Code/Source/AtomActorInstance.cpp | 5 ++- .../Editor/EditorBlastMeshDataComponent.cpp | 4 +-- .../Code/Source/Family/ActorRenderManager.cpp | 5 +-- .../Code/Tests/ActorRenderManagerTest.cpp | 2 +- .../Rendering/Atom/WhiteBoxAtomRenderMesh.cpp | 2 +- 29 files changed, 141 insertions(+), 82 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.h b/Code/Framework/AzCore/AzCore/Math/Aabb.h index 474ac2e2ee..2d2616f5de 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.h +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.h @@ -131,6 +131,8 @@ namespace AZ void ApplyMatrix3x4(const Matrix3x4& matrix3x4); + void MultiplyByScale(const Vector3& scale); + //! Transforms an Aabb and returns the resulting Obb. Obb GetTransformedObb(const Transform& transform) const; diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.inl b/Code/Framework/AzCore/AzCore/Math/Aabb.inl index 94ad3e3e7d..25a03d20b9 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.inl +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.inl @@ -292,6 +292,13 @@ namespace AZ } + AZ_MATH_INLINE void Aabb::MultiplyByScale(const Vector3& scale) + { + m_min *= scale; + m_max *= scale; + } + + AZ_MATH_INLINE Aabb Aabb::GetTransformedAabb(const Transform& transform) const { Aabb aabb = Aabb::CreateFromMinMax(m_min, m_max); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h index bd0ede749d..eb49859141 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessor.h @@ -145,8 +145,10 @@ namespace AZ const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const override; void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) override; - void SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) override; - Matrix3x4 GetMatrix3x4(const MeshHandle& meshHandle) override; + void SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform, + const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override; + Transform GetTransform(const MeshHandle& meshHandle) override; + Vector3 GetNonUniformScale(const MeshHandle& meshHandle) override; void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) override; RHI::DrawItemSortKey GetSortKey(const MeshHandle& meshHandle) override; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h index ef8084d534..05f2a408b8 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/Mesh/MeshFeatureProcessorInterface.h @@ -61,10 +61,13 @@ namespace AZ virtual const MaterialAssignmentMap& GetMaterialAssignmentMap(const MeshHandle& meshHandle) const = 0; //! Connects a handler to any changes to an RPI::Model. Changes include loading and reloading. virtual void ConnectModelChangeEventHandler(const MeshHandle& meshHandle, ModelChangedEvent::Handler& handler) = 0; - //! Sets the Matrix3x4 for a given mesh handle. - virtual void SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) = 0; - //! Gets the Matrix3x4 for a given mesh handle. - virtual Matrix3x4 GetMatrix3x4(const MeshHandle& meshHandle) = 0; + //! Sets the transform for a given mesh handle. + virtual void SetTransform(const MeshHandle& meshHandle, const Transform& transform, + const Vector3& nonUniformScale = Vector3::CreateOne()) = 0; + //! Gets the transform for a given mesh handle. + virtual Transform GetTransform(const MeshHandle& meshHandle) = 0; + //! Gets the non-uniform scale for a given mesh handle. + virtual Vector3 GetNonUniformScale(const MeshHandle& meshHandle) = 0; //! Sets the sort key for a given mesh handle. virtual void SetSortKey(const MeshHandle& meshHandle, RHI::DrawItemSortKey sortKey) = 0; //! Gets the sort key for a given mesh handle. diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h index 610bb40369..a89875aaa6 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessor.h @@ -37,7 +37,7 @@ namespace AZ void SetProbeOuterExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& outerExtents) override; void SetProbeInnerExtents(const ReflectionProbeHandle& probe, const AZ::Vector3& innerExtents) override; void SetProbeCubeMap(const ReflectionProbeHandle& probe, Data::Instance& cubeMapImage) override; - void SetProbeMatrix3x4(const ReflectionProbeHandle& probe, const AZ::Matrix3x4& matrix3x4) override; + void SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform) override; void BakeProbe(const ReflectionProbeHandle& probe, BuildCubeMapCallback callback) override; void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) override; bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const override { return (probe.get() != nullptr); } diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h index 3053d9d44f..8b277e97c8 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/ReflectionProbe/ReflectionProbeFeatureProcessorInterface.h @@ -48,7 +48,7 @@ namespace AZ virtual void SetProbeOuterExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& outerExtents) = 0; virtual void SetProbeInnerExtents(const ReflectionProbeHandle& handle, const AZ::Vector3& innerExtents) = 0; virtual void SetProbeCubeMap(const ReflectionProbeHandle& handle, Data::Instance& cubeMapImage) = 0; - virtual void SetProbeMatrix3x4(const ReflectionProbeHandle& handle, const AZ::Matrix3x4& matrix3x4) = 0; + virtual void SetProbeTransform(const ReflectionProbeHandle& handle, const AZ::Transform& transform) = 0; virtual void BakeProbe(const ReflectionProbeHandle& handle, BuildCubeMapCallback callback) = 0; virtual void NotifyCubeMapAssetReady(const AZStd::string relativePath, NotifyCubeMapAssetReadyCallback callback) = 0; virtual bool IsValidProbeHandle(const ReflectionProbeHandle& probe) const = 0; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h index d6338d6b0c..ddec9a6a1d 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessor.h @@ -50,8 +50,10 @@ namespace AZ // TransformServiceFeatureProcessorInterface overrides ... ObjectId ReserveObjectId() override; void ReleaseObjectId(ObjectId& id) override; - void SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& matrix3x4) override; - AZ::Matrix3x4 GetMatrix3x4ForId(ObjectId id) const override; + void SetTransformForId(ObjectId id, const AZ::Transform& transform, + const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) override; + AZ::Transform GetTransformForId(ObjectId id) const override; + AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const override; private: diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h index b75257c485..bb3606b12b 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/TransformService/TransformServiceFeatureProcessorInterface.h @@ -13,6 +13,7 @@ #pragma once #include +#include #include namespace AZ @@ -34,11 +35,13 @@ namespace AZ //! Releases an object ID to be used by others. The passed in handle is invalidated. virtual void ReleaseObjectId(ObjectId& id) = 0; - //! Sets the Matrix3x4 for a given id. Id must be one reserved earlier. - virtual void SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& transform) = 0; - //! Gets the Matrix3x4 for a given id. Id must be one reserved earlier. - virtual AZ::Matrix3x4 GetMatrix3x4ForId(ObjectId) const = 0; - + //! Sets the transform (and optionally non-uniform scale) for a given id. Id must be one reserved earlier. + virtual void SetTransformForId(ObjectId id, const AZ::Transform& transform, + const AZ::Vector3& nonUniformScale = AZ::Vector3::CreateOne()) = 0; + //! Gets the transform for a given id. Id must be one reserved earlier. + virtual AZ::Transform GetTransformForId(ObjectId) const = 0; + //! Gets the non-uniform scale for a given id. Id must be one reserved earlier. + virtual AZ::Vector3 GetNonUniformScaleForId(ObjectId id) const = 0; }; } } diff --git a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h index b6428754b5..a1a7e94cb0 100644 --- a/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Mocks/MockMeshFeatureProcessor.h @@ -31,11 +31,12 @@ namespace UnitTest MOCK_CONST_METHOD1(GetModel, AZStd::intrusive_ptr(const MeshHandle&)); MOCK_CONST_METHOD1(GetMaterialAssignmentMap, const AZ::Render::MaterialAssignmentMap&(const MeshHandle&)); MOCK_METHOD2(ConnectModelChangeEventHandler, void(const MeshHandle&, ModelChangedEvent::Handler&)); - MOCK_METHOD2(SetMatrix3x4, void(const MeshHandle&, const AZ::Matrix3x4&)); + MOCK_METHOD3(SetTransform, void(const MeshHandle&, const AZ::Transform&, const AZ::Vector3&)); MOCK_METHOD2(SetExcludeFromReflectionCubeMaps, void(const MeshHandle&, bool)); MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Data::Instance&)); MOCK_METHOD2(SetMaterialAssignmentMap, void(const MeshHandle&, const AZ::Render::MaterialAssignmentMap&)); - MOCK_METHOD1(GetMatrix3x4, AZ::Matrix3x4 (const MeshHandle&)); + MOCK_METHOD1(GetTransform, AZ::Transform(const MeshHandle&)); + MOCK_METHOD1(GetNonUniformScale, AZ::Vector3(const MeshHandle&)); MOCK_METHOD2(SetSortKey, void (const MeshHandle&, AZ::RHI::DrawItemSortKey)); MOCK_METHOD1(GetSortKey, AZ::RHI::DrawItemSortKey(const MeshHandle&)); MOCK_METHOD2(SetLodOverride, void(const MeshHandle&, AZ::RPI::Cullable::LodOverride)); diff --git a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp index 409ff6ceaf..37f9360f5d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Mesh/MeshFeatureProcessor.cpp @@ -256,7 +256,7 @@ namespace AZ } } - void MeshFeatureProcessor::SetMatrix3x4(const MeshHandle& meshHandle, const AZ::Matrix3x4& matrix3x4) + void MeshFeatureProcessor::SetTransform(const MeshHandle& meshHandle, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale) { if (meshHandle.IsValid()) { @@ -264,26 +264,39 @@ namespace AZ meshData.m_cullBoundsNeedsUpdate = true; meshData.m_objectSrgNeedsUpdate = true; - m_transformService->SetMatrix3x4ForId(meshHandle->m_objectId, matrix3x4); + m_transformService->SetTransformForId(meshHandle->m_objectId, transform, nonUniformScale); // ray tracing data needs to be updated with the new transform if (m_rayTracingFeatureProcessor) { - m_rayTracingFeatureProcessor->SetMeshMatrix3x4(meshHandle->m_objectId, matrix3x4); + m_rayTracingFeatureProcessor->SetMeshTransform(meshHandle->m_objectId, transform, nonUniformScale); } } } - Matrix3x4 MeshFeatureProcessor::GetMatrix3x4(const MeshHandle& meshHandle) + Transform MeshFeatureProcessor::GetTransform(const MeshHandle& meshHandle) { if (meshHandle.IsValid()) { - return m_transformService->GetMatrix3x4ForId(meshHandle->m_objectId); + return m_transformService->GetTransformForId(meshHandle->m_objectId); } else { AZ_Assert(false, "Invalid mesh handle"); - return Matrix3x4::CreateIdentity(); + return Transform::CreateIdentity(); + } + } + + Vector3 MeshFeatureProcessor::GetNonUniformScale(const MeshHandle& meshHandle) + { + if (meshHandle.IsValid()) + { + return m_transformService->GetNonUniformScaleForId(meshHandle->m_objectId); + } + else + { + AZ_Assert(false, "Invalid mesh handle"); + return Vector3::CreateOne(); } } @@ -844,11 +857,14 @@ namespace AZ AZ_Assert(m_cullBoundsNeedsUpdate, "This function only needs to be called if the culling bounds need to be rebuilt"); AZ_Assert(m_model, "The model has not finished loading yet"); - Matrix3x4 localToWorld = transformService->GetMatrix3x4ForId(m_objectId); + Transform localToWorld = transformService->GetTransformForId(m_objectId); + Vector3 nonUniformScale = transformService->GetNonUniformScaleForId(m_objectId); Vector3 center; float radius; Aabb localAabb = m_model->GetAabb(); + localAabb.MultiplyByScale(nonUniformScale); + localAabb.GetTransformedAabb(localToWorld).GetAsSphere(center, radius); m_cullable.m_cullData.m_boundingSphere = Sphere(center, radius); @@ -922,11 +938,11 @@ namespace AZ // retrieve the list of probes that contain the centerpoint of the mesh TransformServiceFeatureProcessor* transformServiceFeatureProcessor = m_scene->GetFeatureProcessor(); - Matrix3x4 matrix3x4 = transformServiceFeatureProcessor->GetMatrix3x4ForId(m_objectId); + Transform transform = transformServiceFeatureProcessor->GetTransformForId(m_objectId); ReflectionProbeFeatureProcessor* reflectionProbeFeatureProcessor = m_scene->GetFeatureProcessor(); ReflectionProbeFeatureProcessor::ReflectionProbeVector reflectionProbes; - reflectionProbeFeatureProcessor->FindReflectionProbes(matrix3x4.GetTranslation(), reflectionProbes); + reflectionProbeFeatureProcessor->FindReflectionProbes(transform.GetTranslation(), reflectionProbes); if (!reflectionProbes.empty() && reflectionProbes[0]) { diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp index 662886aaa2..2bb2fa2ac2 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp @@ -80,7 +80,8 @@ namespace AZ ->InstanceID(blasIndex) ->HitGroupIndex(blasIndex) ->Blas(rayTracingSubMesh.m_blas) - ->Matrix3x4(rayTracingMesh.second.m_matrix3x4) + ->Transform(rayTracingMesh.second.m_transform) + ->NonUniformScale(rayTracingMesh.second.m_nonUniformScale) ; } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index 63c51fa042..7ac502ca4a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -115,7 +115,7 @@ namespace AZ } // set initial transform - mesh.m_matrix3x4 = m_transformServiceFeatureProcessor->GetMatrix3x4ForId(objectId); + mesh.m_transform = m_transformServiceFeatureProcessor->GetTransformForId(objectId); m_revision++; m_subMeshCount += aznumeric_cast(subMeshes.size()); @@ -141,7 +141,7 @@ namespace AZ m_meshInfoBufferNeedsUpdate = true; } - void RayTracingFeatureProcessor::SetMeshMatrix3x4(const ObjectId objectId, const AZ::Matrix3x4 matrix3x4) + void RayTracingFeatureProcessor::SetMeshTransform(const ObjectId objectId, const AZ::Transform transform, const AZ::Vector3 nonUniformScale) { if (!m_rayTracingEnabled) { @@ -151,7 +151,8 @@ namespace AZ MeshMap::iterator itMesh = m_meshes.find(objectId.GetIndex()); if (itMesh != m_meshes.end()) { - itMesh->second.m_matrix3x4 = matrix3x4; + itMesh->second.m_transform = transform; + itMesh->second.m_nonUniformScale = nonUniformScale; m_revision++; } @@ -296,10 +297,10 @@ namespace AZ for (const auto& mesh : m_meshes) { - AZ::Matrix3x4 meshMatrix3x4 = transformFeatureProcessor->GetMatrix3x4ForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first)); - AZ::Matrix3x4 noScaleMatrix3x4 = meshMatrix3x4; - noScaleMatrix3x4.ExtractScale(); - AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromMatrix3x4(noScaleMatrix3x4); + AZ::Transform meshTransform = transformFeatureProcessor->GetTransformForId(TransformServiceFeatureProcessorInterface::ObjectId(mesh.first)); + AZ::Transform noScaleTransform = meshTransform; + noScaleTransform.ExtractScale(); + AZ::Matrix3x3 rotationMatrix = Matrix3x3::CreateFromTransform(noScaleTransform); rotationMatrix = rotationMatrix.GetInverseFull().GetTranspose(); const RayTracingFeatureProcessor::SubMeshVector& subMeshes = mesh.second.m_subMeshes; diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h index 05fd324178..f317f1c096 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h @@ -66,7 +66,10 @@ namespace AZ SubMeshVector m_subMeshes; // mesh transform - AZ::Matrix3x4 m_matrix3x4 = AZ::Matrix3x4::CreateIdentity(); + AZ::Transform m_transform = AZ::Transform::CreateIdentity(); + + // mesh non-uniform scale + AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne(); // flag indicating if the Blas objects in the sub-meshes are built bool m_blasBuilt = false; @@ -85,7 +88,8 @@ namespace AZ //! Sets the ray tracing mesh transform //! This will cause an update to the RayTracing acceleration structure on the next frame - void SetMeshMatrix3x4(const ObjectId objectId, const AZ::Matrix3x4 matrix3x4); + void SetMeshTransform(const ObjectId objectId, const AZ::Transform transform, + const AZ::Vector3 nonUniformScale = AZ::Vector3::CreateOne()); //! Retrieves ray tracing data for all meshes in the scene const MeshMap& GetMeshes() const { return m_meshes; } diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp index 7fe51d6c37..0826739119 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp @@ -70,7 +70,7 @@ namespace AZ m_visualizationMeshHandle = m_meshFeatureProcessor->AcquireMesh(m_visualizationModelAsset); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_visualizationMeshHandle, true); m_meshFeatureProcessor->SetRayTracingEnabled(m_visualizationMeshHandle, false); - m_meshFeatureProcessor->SetMatrix3x4(m_visualizationMeshHandle, AZ::Matrix3x4::CreateIdentity()); + m_meshFeatureProcessor->SetTransform(m_visualizationMeshHandle, AZ::Transform::CreateIdentity()); // We have to pre-load this asset before creating a Material instance because the InstanceDatabase will attempt a blocking load which could deadlock, // particularly when slices are involved. @@ -206,10 +206,10 @@ namespace AZ } - void ReflectionProbe::SetMatrix3x4(const AZ::Matrix3x4& matrix3x4) + void ReflectionProbe::SetTransform(const AZ::Transform& transform) { - m_position = matrix3x4.GetTranslation(); - m_meshFeatureProcessor->SetMatrix3x4(m_visualizationMeshHandle, matrix3x4); + m_position = transform.GetTranslation(); + m_meshFeatureProcessor->SetTransform(m_visualizationMeshHandle, transform); m_outerAabbWs = Aabb::CreateCenterHalfExtents(m_position, m_outerExtents / 2.0f); m_innerAabbWs = Aabb::CreateCenterHalfExtents(m_position, m_innerExtents / 2.0f); m_updateSrg = true; diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h index 6b23afb1fc..22645a4ed3 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.h @@ -76,7 +76,7 @@ namespace AZ void Simulate(uint32_t probeIndex); const Vector3& GetPosition() const { return m_position; } - void SetMatrix3x4(const AZ::Matrix3x4& matrix3x4); + void SetTransform(const AZ::Transform& transform); const AZ::Vector3& GetOuterExtents() const { return m_outerExtents; } void SetOuterExtents(const AZ::Vector3& outerExtents); diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp index e4c1c04f99..a0d3e6ac51 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbeFeatureProcessor.cpp @@ -222,7 +222,7 @@ namespace AZ { AZStd::shared_ptr reflectionProbe = AZStd::make_shared(); reflectionProbe->Init(GetParentScene(), &m_reflectionRenderData); - reflectionProbe->SetMatrix3x4(AZ::Matrix3x4::CreateFromTransform(transform)); + reflectionProbe->SetTransform(transform); reflectionProbe->SetUseParallaxCorrection(useParallaxCorrection); m_reflectionProbes.push_back(reflectionProbe); m_probeSortRequired = true; @@ -263,10 +263,10 @@ namespace AZ probe->SetCubeMapImage(cubeMapImage); } - void ReflectionProbeFeatureProcessor::SetProbeMatrix3x4(const ReflectionProbeHandle& probe, const AZ::Matrix3x4& matrix3x4) + void ReflectionProbeFeatureProcessor::SetProbeTransform(const ReflectionProbeHandle& probe, const AZ::Transform& transform) { - AZ_Assert(probe.get(), "SetProbeMatrix3x4 called with an invalid handle"); - probe->SetMatrix3x4(matrix3x4); + AZ_Assert(probe.get(), "SetProbeTransform called with an invalid handle"); + probe->SetTransform(transform); m_probeSortRequired = true; } diff --git a/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp index a3a91ca620..acb6e4a287 100644 --- a/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/TransformService/TransformServiceFeatureProcessor.cpp @@ -210,12 +210,14 @@ namespace AZ } } - void TransformServiceFeatureProcessor::SetMatrix3x4ForId(ObjectId id, const AZ::Matrix3x4& matrix3x4) + void TransformServiceFeatureProcessor::SetTransformForId(ObjectId id, const AZ::Transform& transform, const AZ::Vector3& nonUniformScale) { AZ_Error("TransformServiceFeatureProcessor", m_isWriteable, "Transform data cannot be written to during this phase"); AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle."); if (id.IsValid()) { + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(transform); + matrix3x4.MultiplyByScale(nonUniformScale); matrix3x4.StoreToRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); // Inverse transpose to take the non-uniform scale out of the transform for usage with normals. @@ -224,10 +226,20 @@ namespace AZ } } - AZ::Matrix3x4 TransformServiceFeatureProcessor::GetMatrix3x4ForId(ObjectId id) const + AZ::Transform TransformServiceFeatureProcessor::GetTransformForId(ObjectId id) const { - AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to set the transform for an invalid handle."); - return AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); + AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the transform for an invalid handle."); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); + AZ::Transform transform = AZ::Transform::CreateFromMatrix3x4(matrix3x4); + transform.ExtractScale(); + return transform; + } + + AZ::Vector3 TransformServiceFeatureProcessor::GetNonUniformScaleForId(ObjectId id) const + { + AZ_Error("TransformServiceFeatureProcessor", id.IsValid(), "Attempting to get the non-uniform scale for an invalid handle."); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromRowMajorFloat12(m_objectToWorldTransforms.at(id.GetIndex()).m_transform); + return matrix3x4.RetrieveScale(); } } } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h index 0225673efd..317094e24c 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h @@ -110,7 +110,8 @@ namespace AZ { uint32_t m_instanceID = 0; uint32_t m_hitGroupIndex = 0; - AZ::Matrix3x4 m_matrix3x4 = AZ::Matrix3x4::CreateIdentity(); + AZ::Transform m_transform = AZ::Transform::CreateIdentity(); + AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne(); RHI::Ptr m_blas; }; using RayTracingTlasInstanceVector = AZStd::vector; @@ -153,7 +154,8 @@ namespace AZ RayTracingTlasDescriptor* Instance(); RayTracingTlasDescriptor* InstanceID(uint32_t instanceID); RayTracingTlasDescriptor* HitGroupIndex(uint32_t hitGroupIndex); - RayTracingTlasDescriptor* Matrix3x4(const AZ::Matrix3x4& matrix3x4); + RayTracingTlasDescriptor* Transform(const AZ::Transform& transform); + RayTracingTlasDescriptor* NonUniformScale(const AZ::Vector3& nonUniformScale); RayTracingTlasDescriptor* Blas(RHI::Ptr& blas); RayTracingTlasDescriptor* InstancesBuffer(RHI::Ptr& tlasInstances); RayTracingTlasDescriptor* NumInstances(uint32_t numInstancesInBuffer); diff --git a/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp b/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp index dadaeee5d4..4349761eb5 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp @@ -78,13 +78,20 @@ namespace AZ return this; } - RayTracingTlasDescriptor* RayTracingTlasDescriptor::Matrix3x4(const AZ::Matrix3x4& matrix3x4) + RayTracingTlasDescriptor* RayTracingTlasDescriptor::Transform(const AZ::Transform& transform) { - AZ_Assert(m_buildContext, "Matrix3x4 property can only be added to an Instance entry"); - m_buildContext->m_matrix3x4 = matrix3x4; + AZ_Assert(m_buildContext, "Transform property can only be added to an Instance entry"); + m_buildContext->m_transform = transform; return this; } + RayTracingTlasDescriptor* RayTracingTlasDescriptor::NonUniformScale(const AZ::Vector3& nonUniformScale) + { + AZ_Assert(m_buildContext, "NonUniformSCale property can only be added to an Instance entry"); + m_buildContext->m_nonUniformScale = nonUniformScale; + return this; + } + RayTracingTlasDescriptor* RayTracingTlasDescriptor::Blas(RHI::Ptr& blas) { AZ_Assert(m_buildContext, "Blas property can only be added to an Instance entry"); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp index 8c01b798a6..1342db5690 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp @@ -89,7 +89,9 @@ namespace AZ mappedData[i].InstanceID = instance.m_instanceID; mappedData[i].InstanceContributionToHitGroupIndex = instance.m_hitGroupIndex; // convert transform to row-major 3x4 - instance.m_matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); + matrix3x4.MultiplyByScale(instance.m_nonUniformScale); + matrix3x4.StoreToRowMajorFloat12(&mappedData[i].Transform[0][0]); mappedData[i].AccelerationStructure = static_cast(blas->GetBuffers().m_blasBuffer.get())->GetMemoryView().GetGpuAddress(); // [GFX TODO][ATOM-5270] Add ray tracing TLAS instance mask support mappedData[i].InstanceMask = 0x1; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp index 161104060e..a1346612c9 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp @@ -92,7 +92,9 @@ namespace AZ mappedData[i].instanceCustomIndex = instance.m_instanceID; mappedData[i].instanceShaderBindingTableRecordOffset = instance.m_hitGroupIndex; - instance.m_matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]); + AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(instance.m_transform); + matrix3x4.MultiplyByScale(instance.m_nonUniformScale); + matrix3x4.StoreToRowMajorFloat12(&mappedData[i].transform.matrix[0][0]); RayTracingBlas* blas = static_cast(instance.m_blas.get()); VkAccelerationStructureDeviceAddressInfoKHR addressInfo = {}; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 59f4a8a92a..e4e9080cd1 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -214,6 +214,8 @@ namespace AZ MaterialReceiverRequestBus::Handler::BusDisconnect(); MaterialComponentNotificationBus::Handler::BusDisconnect(); + m_nonUniformScaleChangedHandler.Disconnect(); + m_meshFeatureProcessor = nullptr; m_transformInterface = nullptr; m_entityId = AZ::EntityId(AZ::EntityId::InvalidEntityId); @@ -232,22 +234,18 @@ namespace AZ void MeshComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, [[maybe_unused]] const AZ::Transform& world) { - UpdateOverallMatrix(); + if (m_meshFeatureProcessor) + { + m_meshFeatureProcessor->SetTransform(m_meshHandle, world, m_cachedNonUniformScale); + } } void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3 & nonUniformScale) { m_cachedNonUniformScale = nonUniformScale; - UpdateOverallMatrix(); - } - - void MeshComponentController::UpdateOverallMatrix() - { if (m_meshFeatureProcessor) { - Matrix3x4 world = Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()); - world.MultiplyByScale(m_cachedNonUniformScale); - m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, world); + m_meshFeatureProcessor->SetTransform(m_meshHandle, m_transformInterface->GetWorldTM(), m_cachedNonUniformScale); } } @@ -293,10 +291,9 @@ namespace AZ m_meshHandle = m_meshFeatureProcessor->AcquireMesh(m_configuration.m_modelAsset, materials); m_meshFeatureProcessor->ConnectModelChangeEventHandler(m_meshHandle, m_changeEventHandler); - const AZ::Matrix3x4& matrix3x4 = m_transformInterface - ? Matrix3x4::CreateFromTransform(m_transformInterface->GetWorldTM()) * Matrix3x4::CreateScale(m_cachedNonUniformScale) - : Matrix3x4::Identity(); - m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, matrix3x4); + const AZ::Transform& transform = m_transformInterface ? m_transformInterface->GetWorldTM() : AZ::Transform::CreateIdentity(); + + m_meshFeatureProcessor->SetTransform(m_meshHandle, transform, m_cachedNonUniformScale); m_meshFeatureProcessor->SetSortKey(m_meshHandle, m_configuration.m_sortKey); m_meshFeatureProcessor->SetLodOverride(m_meshHandle, m_configuration.m_lodOverride); m_meshFeatureProcessor->SetExcludeFromReflectionCubeMaps(m_meshHandle, m_configuration.m_excludeFromReflectionCubeMaps); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h index 6c48a863ff..afdcfa25c7 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.h @@ -124,7 +124,6 @@ namespace AZ void RefreshModelRegistration(); void HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale); - void UpdateOverallMatrix(); Render::MeshFeatureProcessorInterface* m_meshFeatureProcessor = nullptr; Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp index 57aaa6a83f..005e9a6ff5 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp @@ -199,7 +199,7 @@ namespace AZ return; } - m_featureProcessor->SetProbeMatrix3x4(m_handle, Matrix3x4::CreateFromTransform(world)); + m_featureProcessor->SetProbeTransform(m_handle, world); } void ReflectionProbeComponentController::OnShapeChanged(ShapeChangeReasons changeReason) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp index 8f60d3fedd..0a17a6444d 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/AtomActorInstance.cpp @@ -192,9 +192,8 @@ namespace AZ void AtomActorInstance::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world) { - // The mesh Matrix3x4 is used to determine where the actor instance is actually rendered - AZ::Matrix3x4 matrix3x4 = AZ::Matrix3x4::CreateFromTransform(world); - m_meshFeatureProcessor->SetMatrix3x4(*m_meshHandle, matrix3x4); // handle validity is checked internally. + // The mesh transform is used to determine where the actor instance is actually rendered + m_meshFeatureProcessor->SetTransform(*m_meshHandle, world); // handle validity is checked internally. if (m_skinnedMeshRenderProxy.IsValid()) { diff --git a/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp b/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp index 6227fc4d45..51789f68da 100644 --- a/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp +++ b/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp @@ -193,7 +193,7 @@ namespace Blast AZ::Transform transform = AZ::Transform::Identity(); AZ::TransformBus::EventResult(transform, GetEntityId(), &AZ::TransformInterface::GetWorldTM); - m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(transform)); + m_meshFeatureProcessor->SetTransform(m_meshHandle, transform); } } @@ -232,7 +232,7 @@ namespace Blast { if (m_meshFeatureProcessor) { - m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(world)); + m_meshFeatureProcessor->SetTransform(m_meshHandle, world); } } } // namespace Blast diff --git a/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp b/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp index d057e5a619..74bba48d3c 100644 --- a/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp +++ b/Gems/Blast/Code/Source/Family/ActorRenderManager.cpp @@ -74,10 +74,7 @@ namespace Blast { if (m_chunkActors[chunkId]) { - auto matrix3x4 = AZ::Matrix3x4::CreateFromTransform(m_chunkActors[chunkId]->GetWorldBody()->GetTransform()); - // Multiply by scale because the transform on the world body does not store scale - matrix3x4.MultiplyByScale(m_scale); - m_meshFeatureProcessor->SetMatrix3x4(m_chunkMeshHandles[chunkId], matrix3x4); + m_meshFeatureProcessor->SetTransform(m_chunkMeshHandles[chunkId], m_chunkActors[chunkId]->GetWorldBody()->GetTransform(), m_scale); } } } diff --git a/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp b/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp index 0a7cd229a3..114721a095 100644 --- a/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp +++ b/Gems/Blast/Code/Tests/ActorRenderManagerTest.cpp @@ -114,7 +114,7 @@ namespace Blast // ActorRenderManager::SyncMeshes { - EXPECT_CALL(*m_mockMeshFeatureProcessor, SetMatrix3x4(_, _)) + EXPECT_CALL(*m_mockMeshFeatureProcessor, SetTransform(_, _, _)) .Times(aznumeric_cast(m_actorFactory->m_mockActors[0]->GetChunkIndices().size())); actorRenderManager->SyncMeshes(); } diff --git a/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp b/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp index 9c3428ad63..9aa29cb288 100644 --- a/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp +++ b/Gems/WhiteBox/Code/Source/Rendering/Atom/WhiteBoxAtomRenderMesh.cpp @@ -248,7 +248,7 @@ namespace WhiteBox void AtomRenderMesh::UpdateTransform(const AZ::Transform& worldFromLocal) { - m_meshFeatureProcessor->SetMatrix3x4(m_meshHandle, AZ::Matrix3x4::CreateFromTransform(worldFromLocal)); + m_meshFeatureProcessor->SetTransform(m_meshHandle, worldFromLocal); } void AtomRenderMesh::UpdateMaterial([[maybe_unused]] const WhiteBoxMaterial& material) From 03350134c59fd61fc938bec1a37b830d09964013 Mon Sep 17 00:00:00 2001 From: greerdv Date: Tue, 20 Apr 2021 13:41:18 +0100 Subject: [PATCH 08/27] more feedback from PR --- .../CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index e4e9080cd1..f17972ab6a 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -240,7 +240,7 @@ namespace AZ } } - void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3 & nonUniformScale) + void MeshComponentController::HandleNonUniformScaleChange(const AZ::Vector3& nonUniformScale) { m_cachedNonUniformScale = nonUniformScale; if (m_meshFeatureProcessor) From cc937e08097a0692e4c1c3cbb3c19db0bf1a0033 Mon Sep 17 00:00:00 2001 From: greerdv Date: Tue, 20 Apr 2021 14:44:31 +0100 Subject: [PATCH 09/27] feedback from PR --- Code/Framework/AzCore/AzCore/Math/Aabb.h | 8 ++++---- .../Code/Source/Mesh/MeshComponentController.cpp | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.h b/Code/Framework/AzCore/AzCore/Math/Aabb.h index 2d2616f5de..ef7704533e 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.h +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.h @@ -134,16 +134,16 @@ namespace AZ void MultiplyByScale(const Vector3& scale); //! Transforms an Aabb and returns the resulting Obb. - Obb GetTransformedObb(const Transform& transform) const; + [[nodiscard]] Obb GetTransformedObb(const Transform& transform) const; //! Transforms an Aabb and returns the resulting Obb. - Obb GetTransformedObb(const Matrix3x4& matrix3x4) const; + [[nodiscard]] Obb GetTransformedObb(const Matrix3x4& matrix3x4) const; //! Returns a new AABB containing the transformed AABB. - Aabb GetTransformedAabb(const Transform& transform) const; + [[nodiscard]] Aabb GetTransformedAabb(const Transform& transform) const; //! Returns a new AABB containing the transformed AABB. - Aabb GetTransformedAabb(const Matrix3x4& matrix3x4) const; + [[nodiscard]] Aabb GetTransformedAabb(const Matrix3x4& matrix3x4) const; //! Checks if this aabb is equal to another within a floating point tolerance. bool IsClose(const Aabb& rhs, float tolerance = Constants::Tolerance) const; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index f17972ab6a..c99ca7b848 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -433,8 +433,7 @@ namespace AZ if (model) { Aabb aabb = model->GetAabb(); - aabb.SetMin(aabb.GetMin() * m_cachedNonUniformScale); - aabb.SetMax(aabb.GetMax() * m_cachedNonUniformScale); + aabb.MultiplyByScale(m_cachedNonUniformScale); return aabb; } else From 12cbba5fad5a2d0b9e1a82c3461c4856ee4b81ba Mon Sep 17 00:00:00 2001 From: greerdv Date: Tue, 20 Apr 2021 17:42:38 +0100 Subject: [PATCH 10/27] adding test for Aabb::MultiplyByScale --- Code/Framework/AzCore/AzCore/Math/Aabb.inl | 1 + Code/Framework/AzCore/Tests/Math/AabbTests.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Code/Framework/AzCore/AzCore/Math/Aabb.inl b/Code/Framework/AzCore/AzCore/Math/Aabb.inl index 25a03d20b9..13549a30f6 100644 --- a/Code/Framework/AzCore/AzCore/Math/Aabb.inl +++ b/Code/Framework/AzCore/AzCore/Math/Aabb.inl @@ -296,6 +296,7 @@ namespace AZ { m_min *= scale; m_max *= scale; + AZ_MATH_ASSERT(IsValid(), "Min must be less than Max"); } diff --git a/Code/Framework/AzCore/Tests/Math/AabbTests.cpp b/Code/Framework/AzCore/Tests/Math/AabbTests.cpp index 6b7317f5b3..44cc800616 100644 --- a/Code/Framework/AzCore/Tests/Math/AabbTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/AabbTests.cpp @@ -446,4 +446,17 @@ namespace UnitTest EXPECT_THAT(transformedAabb.GetMin(), IsClose(aabbContainingTransformedObb.GetMin())); EXPECT_THAT(transformedAabb.GetMax(), IsClose(aabbContainingTransformedObb.GetMax())); } + + TEST(MATH_AabbTransform, MultiplyByScale) + { + Vector3 min(2.0f, 6.0f, 8.0f); + Vector3 max(6.0f, 9.0f, 10.0f); + Aabb aabb = Aabb::CreateFromMinMax(min, max); + + Vector3 scale(0.5f, 2.0f, 1.5f); + aabb.MultiplyByScale(scale); + + EXPECT_THAT(aabb.GetMin(), IsClose(Vector3(1.0f, 12.0f, 12.0f))); + EXPECT_THAT(aabb.GetMax(), IsClose(Vector3(3.0f, 18.0f, 15.0f))); + } } From 64e625a79fde20f6854c52122badcd9a9d92f558 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Tue, 20 Apr 2021 12:52:56 -0700 Subject: [PATCH 11/27] Added support for cavity maps by changing the "Ambient Occlusion" material property group go just "Occlusion", which now contains properties for both "Diffuse AO" and "Specular Cavity". Added new input attachment to the fullscreen reflection pass to receive the "ambient" gbuffer. Added diffuse and specular occlusion to the Skin material type; it was missing before. ATOM-14040 Add Support for Cavity Maps Testing: AtomSampleViewer automation, with updates that will be submitted in that repo. Manual testing in Material Editor. Built all AtomTest assets and opened a few test levels, with updates that will be submitted in that repo. Made local copies of the occlusion test materials and changed replaced the material types with EnhancedPBR and Skin, and got identical results (with clear coat disabled since it works different in EnhancedPBR and is absent in Skin). --- .../ReflectionProbeVisualization.materialtype | 32 -- .../Materials/Types/EnhancedPBR.materialtype | 148 +++++---- .../Types/EnhancedPBR_ForwardPass.azsl | 8 +- .../Types/MaterialInputs/OcclusionInput.azsli | 14 +- .../Common/Assets/Materials/Types/Skin.azsl | 8 +- .../Assets/Materials/Types/Skin.materialtype | 96 ++++-- .../Types/StandardMultilayerPBR.materialtype | 288 ++++++++++++++---- .../StandardMultilayerPBR_ForwardPass.azsl | 15 +- .../Materials/Types/StandardPBR.materialtype | 93 ++++-- .../Materials/Types/StandardPBR_AoState.lua | 48 --- .../StandardPBR_DiffuseOcclusionState.lua | 52 ++++ .../Types/StandardPBR_ForwardPass.azsl | 8 +- .../StandardPBR_SpecularOcclusionState.lua | 52 ++++ .../Common/Assets/Passes/OpaqueParent.pass | 7 + .../Passes/ReflectionGlobalFullscreen.pass | 6 + .../Common/Assets/Passes/Reflections.pass | 12 + .../Atom/Features/PBR/ForwardPassOutput.azsli | 16 +- .../Atom/Features/PBR/LightingModel.azsli | 16 +- .../ReflectionGlobalFullscreen.azsl | 9 +- .../atom_feature_common_asset_files.cmake | 1 - .../TestData/Materials/ParallaxRock.material | 4 +- .../001_ManyFeatures.material | 29 +- .../010_AmbientOcclusion.material | 18 +- .../010_BothOcclusion.material | 15 + .../010_OcclusionBase.material | 25 ++ .../010_SpecularOcclusion.material | 13 + .../100_UvTiling_AmbientOcclusion.material | 4 +- .../Types/AutoBrick_ForwardPass.azsl | 5 +- .../Types/MinimalPBR_ForwardPass.azsl | 2 +- .../Materials/Bricks038_8K/bricks038.material | 4 +- .../PaintedPlaster015.material | 6 +- .../Assets/Materials/baseboards.material | 3 - .../Assets/Materials/crown.material | 3 - .../Assets/Objects/Lucy/lucy_brass.material | 4 +- .../Assets/Objects/Lucy/lucy_stone.material | 4 +- .../Scripts/Python/DCC_Materials/pbr.material | 5 +- .../Scripts/Python/dcc_materials/pbr.material | 5 +- .../standardPBR.template.material | 11 +- .../standardPBR.template.material | 11 +- .../standardpbr.template.material | 11 +- .../StandardPBR_AllProperties.material | 11 +- 41 files changed, 775 insertions(+), 347 deletions(-) delete mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua create mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua create mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua create mode 100644 Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material create mode 100644 Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material create mode 100644 Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material diff --git a/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype index e401b42644..214fc02660 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/ReflectionProbe/ReflectionProbeVisualization.materialtype @@ -401,38 +401,6 @@ "step": 0.1 } ], - "ambientOcclusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", - "type": "Bool", - "defaultValue": false - }, - { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", - "type": "Float", - "defaultValue": 1.0, - "min": 0.0, - "max": 2.0, - "connection": { - "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" - } - }, - { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", - "type": "Image", - "connection": { - "type": "ShaderInput", - "id": "m_ambientOcclusionMap" - } - } - ], "emissive": [ { "id": "enable", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index e95c82e435..b3e4695880 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -49,9 +49,9 @@ "description": "Properties for configuring UV transforms." }, { - "id": "ambientOcclusion", - "displayName": "Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "occlusion", + "displayName": "Occlusion", + "description": "Properties for baked textures that represent geometric occlusion of light." }, { "id": "emissive", @@ -780,47 +780,96 @@ "step": 0.1 } ], - "ambientOcclusion": [ + "occlusion": [ { "id": "enable", "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "description": "Whether to enable the occlusion features.", "type": "Bool", "defaultValue": false }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", - "type": "Float", - "defaultValue": 1.0, - "min": 0.0, - "max": 2.0, - "connection": { - "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" - } - }, - { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMap" + "id": "m_diffuseOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", "type": "Enum", - "enumValues": [ "UV0", "UV1" ], - "defaultValue": "UV0", + "enumIsUv": true, + "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMapUvIndex" + "id": "m_diffuseOcclusionMapUvIndex" + } + }, + { + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionMap" + } + }, + { + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionFactor" } } ], @@ -1641,17 +1690,15 @@ } }, { - // See the comment above for details. - "type": "UseTexture", + "type": "Lua", "args": { - "textureProperty": "ambientOcclusion.textureMap", - "dependentProperties": ["ambientOcclusion.textureMapUv"], - "useTextureProperty": "ambientOcclusion.enable", - "shaderTags": [ - "ForwardPass", - "ForwardPass_EDS" - ], - "shaderOption": "o_ambientOcclusion_useTexture" + "file": "StandardPBR_DiffuseOcclusionState.lua" + } + }, + { + "type": "Lua", + "args": { + "file": "StandardPBR_SpecularOcclusionState.lua" } }, { @@ -1712,31 +1759,6 @@ "shaderOption": "o_transmission_useTexture" } }, - { - // Controls visibility for properties in the editor. - // @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue. - // @param affectedProperties - the properties that are affected by actions. - "type": "UpdatePropertyVisibility", - "args": { - "actions": [ - { - "triggerProperty": "ambientOcclusion.enable", - "triggerValue": true, - "visibility": "Enabled" - }, - { - "triggerProperty": "ambientOcclusion.enable", - "triggerValue": false, - "visibility": "Disabled" - } - ], - "affectedProperties": [ - "ambientOcclusion.factor", - "ambientOcclusion.textureMap", - "ambientOcclusion.textureMapUv" - ] - } - }, { // Controls visibility for properties in the editor. // @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue. diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index ff8b4b7778..1f7a1a73f7 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -212,9 +212,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture); // ------- Occlusion ------- - - float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex]; - float occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture); + + float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); // ------- Subsurface ------- @@ -250,7 +250,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Opacity ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli index 6149934ba5..103745cf56 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/MaterialInputs/OcclusionInput.azsli @@ -12,19 +12,23 @@ #pragma once -// This file provides utilities for common handling of inputs for ambient occlusion maps for PBR materials. +// This file provides utilities for common handling of inputs for baked occlusion maps for PBR materials. // These macros can be used to declare common shader inputs for this feature. // Use the COMMON_SRG_INPUTS_* macro in your material SRG definition, and use the COMMON_OPTIONS_* macro at the global scope in your shader. Then you can pass these variables to the Get*Input() function below. // You can optionally provide a prefix for the set of inputs which corresponds to a prefix string supplied by the .materialtype file. This is common for multi-layered material types. #define COMMON_SRG_INPUTS_OCCLUSION(prefix) \ -float prefix##m_ambientOcclusionFactor; \ -Texture2D prefix##m_ambientOcclusionMap; \ -uint prefix##m_ambientOcclusionMapUvIndex; +float prefix##m_diffuseOcclusionFactor; \ +Texture2D prefix##m_diffuseOcclusionMap; \ +uint prefix##m_diffuseOcclusionMapUvIndex; \ +float prefix##m_specularOcclusionFactor; \ +Texture2D prefix##m_specularOcclusionMap; \ +uint prefix##m_specularOcclusionMapUvIndex; #define COMMON_OPTIONS_OCCLUSION(prefix) \ -option bool prefix##o_ambientOcclusion_useTexture; +option bool prefix##o_diffuseOcclusion_useTexture; \ +option bool prefix##o_specularOcclusion_useTexture; float GetOcclusionInput(Texture2D map, sampler mapSampler, float2 uv, float factor, bool useTexture) { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index aa8ae3a010..adc9257414 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -271,6 +271,11 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) float roughness = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor, MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture); + // ------- Occlusion ------- + + float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); + // ------- Specular ------- float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex]; @@ -299,7 +304,6 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) float metallic = 0; float3 emissive = float3(0,0,0); - float occlusion = 1; float2 anisotropy = float2(0,0); float clearCoatFactor = 0.0; float clearCoatRoughness = 0.0; @@ -308,7 +312,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normalWS, tangents[0], bitangents[0], anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Preparing output ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 5912bc1484..62b1f863dd 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -24,9 +24,9 @@ "description": "Properties related to configuring surface normal." }, { - "id": "ambientOcclusion", - "displayName": "Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "occlusion", + "displayName": "Occlusion", + "description": "Properties for baked textures that represent geometric occlusion of light." }, { "id": "subsurfaceScattering", @@ -383,48 +383,96 @@ } } ], - - "ambientOcclusion": [ + "occlusion": [ { "id": "enable", "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "description": "Whether to enable the occlusion features.", "type": "Bool", "defaultValue": false }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMap" + "id": "m_diffuseOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", "type": "Enum", "enumIsUv": true, - "defaultValue": "Unwrapped", + "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMapUvIndex" + "id": "m_diffuseOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" + "id": "m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionMap" + } + }, + { + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionFactor" } } ], @@ -1023,7 +1071,13 @@ { "type": "Lua", "args": { - "file": "StandardPBR_AoState.lua" + "file": "StandardPBR_DiffuseOcclusionState.lua" + } + }, + { + "type": "Lua", + "args": { + "file": "StandardPBR_SpecularOcclusionState.lua" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype index 3b40d80b67..c7f0884d9f 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype @@ -73,9 +73,9 @@ "description": "Properties for configuring gloss clear coat" }, { - "id": "layer1_ambientOcclusion", - "displayName": "Layer 1: Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "layer1_occlusion", + "displayName": "Layer 1: Occlusion", + "description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting." }, { "id": "layer1_emissive", @@ -126,9 +126,9 @@ "description": "Properties for configuring gloss clear coat" }, { - "id": "layer2_ambientOcclusion", - "displayName": "Layer 2: Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "layer2_occlusion", + "displayName": "Layer 2: Occlusion", + "description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting." }, { "id": "layer2_emissive", @@ -179,9 +179,9 @@ "description": "Properties for configuring gloss clear coat" }, { - "id": "layer3_ambientOcclusion", - "displayName": "Layer 3: Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "layer3_occlusion", + "displayName": "Layer 3: Occlusion", + "description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting." }, { "id": "layer3_emissive", @@ -1169,47 +1169,96 @@ } } ], - "layer1_ambientOcclusion": [ + "layer1_occlusion": [ { "id": "enable", "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "description": "Whether to enable the occlusion features.", "type": "Bool", "defaultValue": false }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_layer1_m_ambientOcclusionMap" + "id": "m_layer1_m_diffuseOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_layer1_m_ambientOcclusionMapUvIndex" + "id": "m_layer1_m_diffuseOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_layer1_m_ambientOcclusionFactor" + "id": "m_layer1_m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_layer1_m_specularOcclusionMap" + } + }, + { + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_layer1_m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_layer1_m_specularOcclusionFactor" } } ], @@ -1820,47 +1869,96 @@ } } ], - "layer2_ambientOcclusion": [ + "layer2_occlusion": [ { "id": "enable", "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "description": "Whether to enable the occlusion features.", "type": "Bool", "defaultValue": false }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_layer2_m_ambientOcclusionMap" + "id": "m_layer2_m_diffuseOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_layer2_m_ambientOcclusionMapUvIndex" + "id": "m_layer2_m_diffuseOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_layer2_m_ambientOcclusionFactor" + "id": "m_layer2_m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_layer2_m_specularOcclusionMap" + } + }, + { + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_layer2_m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_layer2_m_specularOcclusionFactor" } } ], @@ -2471,47 +2569,96 @@ } } ], - "layer3_ambientOcclusion": [ + "layer3_occlusion": [ { "id": "enable", "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "description": "Whether to enable the occlusion features.", "type": "Bool", "defaultValue": false }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_layer3_m_ambientOcclusionMap" + "id": "m_layer3_m_diffuseOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_layer3_m_ambientOcclusionMapUvIndex" + "id": "m_layer3_m_diffuseOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_layer3_m_ambientOcclusionFactor" + "id": "m_layer3_m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_layer3_m_specularOcclusionMap" + } + }, + { + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_layer3_m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_layer3_m_specularOcclusionFactor" } } ], @@ -2896,7 +3043,16 @@ { "type": "Lua", "args": { - "file": "StandardPBR_AoState.lua", + "file": "StandardPBR_DiffuseOcclusionState.lua", + "propertyNamePrefix": "layer1_", + "srgNamePrefix": "m_layer1_", + "optionsNamePrefix": "o_layer1_" + } + }, + { + "type": "Lua", + "args": { + "file": "StandardPBR_SpecularOcclusionState.lua", "propertyNamePrefix": "layer1_", "srgNamePrefix": "m_layer1_", "optionsNamePrefix": "o_layer1_" @@ -3024,7 +3180,16 @@ { "type": "Lua", "args": { - "file": "StandardPBR_AoState.lua", + "file": "StandardPBR_DiffuseOcclusionState.lua", + "propertyNamePrefix": "layer2_", + "srgNamePrefix": "m_layer2_", + "optionsNamePrefix": "o_layer2_" + } + }, + { + "type": "Lua", + "args": { + "file": "StandardPBR_SpecularOcclusionState.lua", "propertyNamePrefix": "layer2_", "srgNamePrefix": "m_layer2_", "optionsNamePrefix": "o_layer2_" @@ -3152,7 +3317,16 @@ { "type": "Lua", "args": { - "file": "StandardPBR_AoState.lua", + "file": "StandardPBR_DiffuseOcclusionState.lua", + "propertyNamePrefix": "layer3_", + "srgNamePrefix": "m_layer3_", + "optionsNamePrefix": "o_layer3_" + } + }, + { + "type": "Lua", + "args": { + "file": "StandardPBR_SpecularOcclusionState.lua", "propertyNamePrefix": "layer3_", "srgNamePrefix": "m_layer3_", "optionsNamePrefix": "o_layer3_" diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl index 04407adf7d..5e8ad11d54 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl @@ -267,10 +267,15 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Occlusion ------- - float layer1_occlusion = GetOcclusionInput(MaterialSrg::m_layer1_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer1_m_ambientOcclusionFactor, o_layer1_o_ambientOcclusion_useTexture); - float layer2_occlusion = GetOcclusionInput(MaterialSrg::m_layer2_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer2_m_ambientOcclusionFactor, o_layer2_o_ambientOcclusion_useTexture); - float layer3_occlusion = GetOcclusionInput(MaterialSrg::m_layer3_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer3_m_ambientOcclusionFactor, o_layer3_o_ambientOcclusion_useTexture); - float occlusion = BlendLayers(layer1_occlusion, layer2_occlusion, layer3_occlusion, blendMaskValues); + float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture); + float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture); + float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture); + float diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues); + + float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture); + float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture); + float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture); + float specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues); // ------- Subsurface ------- @@ -348,7 +353,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normalWS, tangents[0], bitangents[0], anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Opacity ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype index 9750d09538..f8c7edb2ed 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype @@ -44,9 +44,9 @@ "description": "Properties for configuring UV transforms." }, { - "id": "ambientOcclusion", - "displayName": "Ambient Occlusion", - "description": "Properties for baked AO texture." + "id": "occlusion", + "displayName": "Occlusion", + "description": "Properties for baked textures that represent geometric occlusion of light." }, { "id": "emissive", @@ -724,47 +724,96 @@ "step": 0.1 } ], - "ambientOcclusion": [ + "occlusion": [ { "id": "enable", "displayName": "Enable", - "description": "Whether to enable the ambient occlusion feature.", + "description": "Whether to enable the occlusion features.", "type": "Bool", "defaultValue": false }, { - "id": "textureMap", - "displayName": "Texture Map", - "description": "Texture map for defining ambient occlusion area.", + "id": "diffuseTextureMap", + "displayName": "Diffuse AO", + "description": "Texture map for defining occlusion area for diffuse ambient lighting.", "type": "Image", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMap" + "id": "m_diffuseOcclusionMap" } }, { - "id": "textureMapUv", - "displayName": "UV", - "description": "Ambient occlusion texture map UV set", + "id": "diffuseUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Diffuse AO texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "diffuseTextureMapUv", + "displayName": " UV", + "description": "Diffuse AO texture map UV set.", "type": "Enum", "enumIsUv": true, "defaultValue": "Tiled", "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionMapUvIndex" + "id": "m_diffuseOcclusionMapUvIndex" } }, { - "id": "factor", - "displayName": "Factor", - "description": "Strength factor for scaling the values", + "id": "diffuseFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Diffuse AO", "type": "Float", "defaultValue": 1.0, "min": 0.0, - "max": 2.0, + "softMax": 2.0, "connection": { "type": "ShaderInput", - "id": "m_ambientOcclusionFactor" + "id": "m_diffuseOcclusionFactor" + } + }, + { + "id": "specularTextureMap", + "displayName": "Specular Cavity", + "description": "Texture map for defining occlusion area for specular lighting.", + "type": "Image", + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionMap" + } + }, + { + "id": "specularUseTexture", + "displayName": " Use Texture", + "description": "Whether to use the Specular Cavity texture map.", + "type": "Bool", + "defaultValue": true + }, + { + "id": "specularTextureMapUv", + "displayName": " UV", + "description": "Specular Cavity texture map UV set.", + "type": "Enum", + "enumIsUv": true, + "defaultValue": "Tiled", + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionMapUvIndex" + } + }, + { + "id": "specularFactor", + "displayName": " Factor", + "description": "Strength factor for scaling the values of Specular Cavity", + "type": "Float", + "defaultValue": 1.0, + "min": 0.0, + "softMax": 2.0, + "connection": { + "type": "ShaderInput", + "id": "m_specularOcclusionFactor" } } ], @@ -1272,7 +1321,13 @@ { "type": "Lua", "args": { - "file": "StandardPBR_AoState.lua" + "file": "StandardPBR_DiffuseOcclusionState.lua" + } + }, + { + "type": "Lua", + "args": { + "file": "StandardPBR_SpecularOcclusionState.lua" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua deleted file mode 100644 index a27817d925..0000000000 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_AoState.lua +++ /dev/null @@ -1,48 +0,0 @@ --------------------------------------------------------------------------------------- --- --- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or --- its licensors. --- --- For complete copyright and license terms please see the LICENSE at the root of this --- distribution (the "License"). All use of this software is governed by the License, --- or, if provided, by the license below or the license accompanying this file. Do not --- remove or modify any license notices. This file is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- --- ----------------------------------------------------------------------------------------------------- - -function GetMaterialPropertyDependencies() - return {"ambientOcclusion.enable", "ambientOcclusion.textureMap"} -end - -function GetShaderOptionDependencies() - return {"o_ambientOcclusion_useTexture"} -end - -function Process(context) - local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable") - local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap") - - context:SetShaderOptionValue_bool("o_ambientOcclusion_useTexture", enableAo and textureMap ~= nil) -end - -function ProcessEditor(context) - local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable") - - if(not enableAo) then - context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Enabled) - local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap") - if(textureMap == nil) then - context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Enabled) - context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Enabled) - end - end -end diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua new file mode 100644 index 0000000000..aed13fa83f --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua @@ -0,0 +1,52 @@ +-------------------------------------------------------------------------------------- +-- +-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +-- its licensors. +-- +-- For complete copyright and license terms please see the LICENSE at the root of this +-- distribution (the "License"). All use of this software is governed by the License, +-- or, if provided, by the license below or the license accompanying this file. Do not +-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- +-- +---------------------------------------------------------------------------------------------------- + +function GetMaterialPropertyDependencies() + return {"occlusion.enable", "occlusion.diffuseTextureMap", "occlusion.diffuseUseTexture"} +end + +function GetShaderOptionDependencies() + return {"o_diffuseOcclusion_useTexture"} +end + +function Process(context) + local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") + local textureMap = context:GetMaterialPropertyValue_image("occlusion.diffuseTextureMap") + local enableDiffuse = context:GetMaterialPropertyValue_bool("occlusion.diffuseUseTexture") + + context:SetShaderOptionValue_bool("o_diffuseOcclusion_useTexture", enableOcclusionMaps and textureMap ~= nil and enableDiffuse) +end + +function ProcessEditor(context) + local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") + + if(not enableOcclusionMaps) then + context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMap", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Hidden) + else + context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMap", MaterialPropertyVisibility_Enabled) + local textureMap = context:GetMaterialPropertyValue_image("occlusion.diffuseTextureMap") + if(textureMap == nil) then + context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Hidden) + else + context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Enabled) + context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Enabled) + context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Enabled) + end + end +end diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl index 22e3da4572..0c2882365a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl @@ -171,9 +171,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture); // ------- Occlusion ------- - - float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex]; - float occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture); + + float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); // ------- Subsurface ------- @@ -208,7 +208,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normalWS, tangents[0], bitangents[0], anisotropy, - emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); // ------- Opacity ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua new file mode 100644 index 0000000000..d67f658c7b --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua @@ -0,0 +1,52 @@ +-------------------------------------------------------------------------------------- +-- +-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +-- its licensors. +-- +-- For complete copyright and license terms please see the LICENSE at the root of this +-- distribution (the "License"). All use of this software is governed by the License, +-- or, if provided, by the license below or the license accompanying this file. Do not +-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- +-- +---------------------------------------------------------------------------------------------------- + +function GetMaterialPropertyDependencies() + return {"occlusion.enable", "occlusion.specularTextureMap", "occlusion.specularUseTexture"} +end + +function GetShaderOptionDependencies() + return {"o_specularOcclusion_useTexture"} +end + +function Process(context) + local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") + local textureMap = context:GetMaterialPropertyValue_image("occlusion.specularTextureMap") + local enableDiffuse = context:GetMaterialPropertyValue_bool("occlusion.specularUseTexture") + + context:SetShaderOptionValue_bool("o_specularOcclusion_useTexture", enableOcclusionMaps and textureMap ~= nil and enableDiffuse) +end + +function ProcessEditor(context) + local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") + + if(not enableOcclusionMaps) then + context:SetMaterialPropertyVisibility("occlusion.specularTextureMap", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Hidden) + else + context:SetMaterialPropertyVisibility("occlusion.specularTextureMap", MaterialPropertyVisibility_Enabled) + local textureMap = context:GetMaterialPropertyValue_image("occlusion.specularTextureMap") + if(textureMap == nil) then + context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Hidden) + context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Hidden) + else + context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Enabled) + context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Enabled) + context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Enabled) + end + end +end diff --git a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass index 9877d736a8..87e93e16b3 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass @@ -180,6 +180,13 @@ "Attachment": "SpecularF0Output" } }, + { + "LocalSlot": "AlbedoInput", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "AlbedoOutput" + } + }, { "LocalSlot": "ClearCoatNormalInput", "AttachmentRef": { diff --git a/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass b/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass index d77ba74cf9..1b763f86c2 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/ReflectionGlobalFullscreen.pass @@ -27,6 +27,12 @@ "SlotType": "Input", "ScopeAttachmentUsage": "Shader" }, + { + // This is needed for the alpha channel which has specularOcclusion factor + "Name": "AlbedoInput", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader" + }, { "Name": "ClearCoatNormalInput", "SlotType": "Input", diff --git a/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass b/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass index 083c6bd16f..97881d3d71 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/Reflections.pass @@ -17,6 +17,11 @@ "SlotType": "Input", "ScopeAttachmentUsage": "Shader" }, + { + "Name": "AlbedoInput", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader" + }, { "Name": "ClearCoatNormalInput", "SlotType": "Input", @@ -127,6 +132,13 @@ "Attachment": "SpecularF0Input" } }, + { + "LocalSlot": "AlbedoInput", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "AlbedoInput" + } + }, { "LocalSlot": "ClearCoatNormalInput", "AttachmentRef": { diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli index 4185b08571..f0a43d6b1d 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli @@ -12,19 +12,19 @@ struct ForwardPassOutput { - // m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled - float4 m_diffuseColor : SV_Target0; - float4 m_specularColor : SV_Target1; - float4 m_albedo : SV_Target2; - float4 m_specularF0 : SV_Target3; - float4 m_normal : SV_Target4; - float4 m_clearCoatNormal : SV_Target5; + float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering + float4 m_specularColor : SV_Target1; //!< RGB = Specular Lighting, A = Unused + float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion + float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness + float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled + float4 m_clearCoatNormal : SV_Target5; //!< RG = EncodeNormalSphereMap(clearCoatNormal), B = clearCoatFactor, A = clearCoatRoughness float3 m_scatterDistance : SV_Target6; }; struct ForwardPassOutputWithDepth { - // m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled + // See above for descriptions of special encodings + float4 m_diffuseColor : SV_Target0; float4 m_specularColor : SV_Target1; float4 m_albedo : SV_Target2; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli index 71e283291f..d1d1fbb8b1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli @@ -100,6 +100,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN, float2 anisotropy, // angle and factor float3 emissive, float diffuseAmbientOcclusion, + float specularOcclusion, float4 transmissionTintThickness, float4 transmissionParams, float clearCoatFactor, @@ -237,11 +238,6 @@ PbrLightingOutput PbrLighting( in VSOutput IN, } } - // Emissive contribution - // Emissive light is apply to specular now, as diffuse will be used for subsurface scattering later down the pipeline - // We may change this if specular is also used for other processing - specularLighting += emissive; - if (o_enableDirectionalLights) { ApplyDirectionalLights(dirToCamera, surface, IN.m_shadowCoords, diffuseLighting, specularLighting, translucentBackLighting); @@ -253,6 +249,13 @@ PbrLightingOutput PbrLighting( in VSOutput IN, diffuseLighting += translucentBackLighting * transmissionTintThickness.xyz; } + specularLighting *= specularOcclusion; + + // Emissive contribution + // Emissive light is apply to specular now, as diffuse will be used for subsurface scattering later down the pipeline + // We may change this if specular is also used for other processing + specularLighting += emissive; + PbrLightingOutput lightingOutput; lightingOutput.m_diffuseColor = float4(diffuseLighting, alpha); @@ -261,6 +264,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN, // albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc) lightingOutput.m_specularF0 = float4(specularF0, roughness); lightingOutput.m_albedo.rgb = surface.albedo * diffuseResponse * diffuseAmbientOcclusion; + lightingOutput.m_albedo.a = specularOcclusion; lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(normal); lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; @@ -299,7 +303,7 @@ PbrLightingOutput MakeDebugOutput(VSOutput IN, float3 debugColor, float3 normalW PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); return lightingOutput; } diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl index 136e205d49..98f2672ee8 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/Reflections/ReflectionGlobalFullscreen.azsl @@ -43,8 +43,9 @@ ShaderResourceGroup PassSrg : SRG_PerPass { Texture2DMS m_depth; - Texture2DMS m_normal; // RGB10 = Normal (Encoded), A2 = Flags + Texture2DMS m_normal; // RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled Texture2DMS m_specularF0; // RGB8 = SpecularF0, A8 = Roughness + Texture2DMS m_albedo; // RGB = Not used here, A = specularOcclusion Texture2DMS m_clearCoatNormal; // R16G16 = Normal (Packed), B16A16 = (factor, perceptual roughness) Texture2DMS m_blendWeight; Texture2D m_brdfMap; @@ -80,6 +81,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) float4 encodedNormal = PassSrg::m_normal.Load(IN.m_position.xy, sampleIndex); float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb); bool multiScatterCompensationEnabled = (encodedNormal.a > 0.0f); + + float4 albedo = PassSrg::m_albedo.Load(IN.m_position.xy, sampleIndex); + float specularOcclusion = albedo.a; // reconstruct world space position from the depth at this location in screenspace float3 positionWS = ReconstructWorldPositionFromDepth(IN.m_position.xy, sampleIndex).xyz; @@ -136,6 +140,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex) // apply exposure setting specular *= pow(2.0, SceneSrg::m_iblExposure); + // maybe attenuate the specular + specular *= specularOcclusion; + PSOutput OUT; OUT.m_color = float4(specular, 1.0f); return OUT; diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake index 44b0b590b2..037149a988 100644 --- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake +++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake @@ -36,7 +36,6 @@ set(FILES Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.shader Materials/Types/StandardPBR.materialtype - Materials/Types/StandardPBR_AoState.lua Materials/Types/StandardPBR_ClearCoatEnableFeature.lua Materials/Types/StandardPBR_ClearCoatState.lua Materials/Types/StandardPBR_Common.azsli diff --git a/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material b/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material index 4c91053515..1bc5c39e4a 100644 --- a/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material +++ b/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material @@ -4,9 +4,9 @@ "parentMaterial": "Materials/Presets/PBR/default_grid.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "enable": true, - "textureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg" + "diffuseTextureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg" }, "baseColor": { "textureMap": "TestData/Textures/cc0/Rock030_2K_Color.jpg" diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material index e84c6296be..19c87f193d 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material @@ -4,11 +4,6 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "layer1_ambientOcclusion": { - "enable": true, - "factor": 1.6399999856948853, - "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" - }, "layer1_baseColor": { "color": [ 0.3495536744594574, @@ -32,6 +27,11 @@ "flipY": true, "textureMap": "TestData/Textures/cc0/bark1_norm.jpg" }, + "layer1_occlusion": { + "diffuseFactor": 1.6399999856948853, + "diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg", + "enable": true + }, "layer1_parallax": { "enable": true, "factor": 0.02500000037252903, @@ -53,10 +53,6 @@ "offsetU": 0.5, "offsetV": 0.25 }, - "layer2_ambientOcclusion": { - "factor": 1.2200000286102296, - "textureMap": "TestData/Textures/cc0/bark1_disp.jpg" - }, "layer2_baseColor": { "textureMap": "TestData/Textures/cc0/Lava004_1K_Color.jpg" }, @@ -76,6 +72,11 @@ "flipY": true, "textureMap": "TestData/Textures/cc0/Lava004_1K_Normal.jpg" }, + "layer2_occlusion": { + "enable": true, + "specularFactor": 2.0, + "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" + }, "layer2_parallax": { "enable": true, "factor": 0.01600000075995922, @@ -88,11 +89,6 @@ "offsetU": 0.5, "offsetV": 0.25 }, - "layer3_ambientOcclusion": { - "enable": true, - "factor": 1.0399999618530274, - "textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg" - }, "layer3_baseColor": { "color": [ 0.6315556764602661, @@ -115,6 +111,11 @@ "layer3_normal": { "textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Normal.jpg" }, + "layer3_occlusion": { + "diffuseFactor": 1.0399999618530274, + "diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg", + "enable": true + }, "layer3_parallax": { "enable": true, "factor": 0.004999999888241291, diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material index 2c0b6767f3..ef75528284 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material @@ -1,21 +1,13 @@ { "description": "", "materialType": "Materials/Types/StandardPBR.materialtype", - "parentMaterial": "", + "parentMaterial": "010_OcclusionBase.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "factor": 2.0, - "textureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg" - }, - "baseColor": { - "color": [ - 1.0, - 1.0, - 0.21223773062229157, - 1.0 - ] + "occlusion": { + "diffuseFactor": 2.0, + "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg", + "enable": true } } } \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material new file mode 100644 index 0000000000..d8dc4d8609 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material @@ -0,0 +1,15 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "010_OcclusionBase.material", + "propertyLayoutVersion": 3, + "properties": { + "occlusion": { + "enable": true, + "diffuseFactor": 2.0, + "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg", + "specularFactor": 2.0, + "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" + } + } +} \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material new file mode 100644 index 0000000000..9a41a7d191 --- /dev/null +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_OcclusionBase.material @@ -0,0 +1,25 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "", + "propertyLayoutVersion": 3, + "properties": { + "baseColor": { + "color": [ + 0.06784161180257797, + 0.2073090672492981, + 0.29570457339286806, + 1.0 + ] + }, + "clearCoat": { + "enable": true + }, + "normal": { + "textureMap": "TestData/Textures/cc0/Tiles009_1K_Normal.jpg" + }, + "roughness": { + "factor": 0.0 + } + } +} \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material new file mode 100644 index 0000000000..afaa9f9f4b --- /dev/null +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material @@ -0,0 +1,13 @@ +{ + "description": "", + "materialType": "Materials/Types/StandardPBR.materialtype", + "parentMaterial": "010_OcclusionBase.material", + "propertyLayoutVersion": 3, + "properties": { + "occlusion": { + "enable": true, + "specularFactor": 2.0, + "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" + } + } +} \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material index 9eec81823d..457f0b00e6 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material @@ -4,9 +4,9 @@ "parentMaterial": "TestData\\Materials\\StandardPbrTestCases\\UvTilingBase.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "enable": true, - "textureMap": "TestData/Objects/cube/cube_diff.tif" + "diffuseTextureMap": "TestData/Objects/cube/cube_diff.tif" } } } \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl b/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl index 6607228673..b7642054a8 100644 --- a/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl +++ b/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl @@ -163,7 +163,8 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) GetSurfaceShape(IN.m_uv, surfaceDepth, surfaceNormal); const float3 normal = TangentSpaceToWorld(surfaceNormal, normalize(IN.m_normal), normalize(IN.m_tangent), normalize(IN.m_bitangent)); - const float occlusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor; + const float diffuseAmbientOcclusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor; + const float specularOcclusion = 1; const float metallic = 0; const float roughness = 1; const float specularF0Factor = 0.5; @@ -178,7 +179,7 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); OUT.m_diffuseColor = lightingOutput.m_diffuseColor; OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled diff --git a/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl b/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl index 8f23239437..f08b167892 100644 --- a/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl +++ b/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl @@ -76,7 +76,7 @@ ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN) PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); OUT.m_diffuseColor = lightingOutput.m_diffuseColor; OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material index faf8e1f734..2650ee3081 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material @@ -4,9 +4,9 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "enable": true, - "textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" + "diffuseTextureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material index ed0230a3ca..4006b4ec51 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material @@ -4,10 +4,10 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "enable": true, - "factor": 0.30000001192092898, - "textureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png" + "diffuseFactor": 0.30000001192092898, + "diffuseTextureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png" }, "baseColor": { "textureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_BaseColor.png" diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material index 233b35ab46..7e31eaa5b6 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/baseboards.material @@ -4,9 +4,6 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" - }, "baseColor": { "color": [ 0.496940553188324, diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material index a5c18d0d8b..121b27c021 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/crown.material @@ -4,9 +4,6 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" - }, "baseColor": { "color": [ 0.496940553188324, diff --git a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material index 61a9974e0b..e5c3be3e8d 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material +++ b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material @@ -4,9 +4,9 @@ "parentMaterial": "Materials/Presets/PBR/metal_brass.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "enable": true, - "textureMap": "Objects/Lucy/Lucy_ao.tif" + "diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material index d48cb44721..79a7e507ec 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material +++ b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material @@ -4,9 +4,9 @@ "parentMaterial": "Materials/Presets/PBR/metal_brass.material", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "enable": true, - "textureMap": "Objects/Lucy/Lucy_ao.tif" + "diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material index 4bf22b8762..8a74384d10 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material @@ -4,10 +4,9 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material index 4bf22b8762..8a74384d10 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material @@ -4,10 +4,9 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { + "occlusion": { "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material index 5632c6fc0d..cc2c548174 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standardPBR.template.material @@ -7,10 +7,13 @@ "general": { "texcoord": 0 }, - "ambientOcclusion": { - "factor": 1.0, - "useTexture": false, - "textureMap": "" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": false, + "diffuseTextureMap": "", + "specularFactor": 1.0, + "specularUseTexture": false, + "specularTextureMap": "" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material index 1ac6fb2fcb..78891d6c46 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/legacy_asset_converter/standardPBR.template.material @@ -7,10 +7,13 @@ "general": { "texcoord": 0 }, - "ambientOcclusion": { - "factor": 1.0, - "useTexture": false, - "textureMap": "" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": false, + "diffuseTextureMap": "", + "specularFactor": 1.0, + "specularUseTexture": false, + "specularTextureMap": "" }, "baseColor": { "color": [ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material index 4bf22b8762..30d895f9ac 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/maya_dcc_materials/standardpbr.template.material @@ -4,10 +4,13 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": true, + "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif", + "specularFactor": 1.0, + "specularUseTexture": true, + "specularTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material index 4bf22b8762..00ff63829f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/stingraypbs_converter/StandardPBR_AllProperties.material @@ -4,10 +4,13 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "factor": 1.0, - "useTexture": true, - "textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" + "occlusion": { + "diffuseFactor": 1.0, + "diffuseUseTexture": false, + "diffuseTextureMap": "", + "specularFactor": 1.0, + "specularUseTexture": false, + "specularTextureMap": "" }, "baseColor": { "color": [ 1.0, 1.0, 1.0 ], From 94b11e5c8f0bd8fb77a2ea105a1a103b2da26731 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Tue, 20 Apr 2021 16:40:10 -0700 Subject: [PATCH 12/27] Replaced StandardPBR_DiffuseOcclusionState and StandardPBR_SpecularOcclusionState functor scripts with just UseTexture functors. The behavior is the basically the same and a lot simpler. All we lose is the occlusion "enable" flag, which is cleaner anyway. ATOM-14040 Add Support for Cavity Maps --- .../Materials/Types/EnhancedPBR.materialtype | 21 +++-- .../Assets/Materials/Types/Skin.materialtype | 21 +++-- .../Types/StandardMultilayerPBR.materialtype | 81 +++++++------------ .../Materials/Types/StandardPBR.materialtype | 21 +++-- .../StandardPBR_DiffuseOcclusionState.lua | 52 ------------ .../StandardPBR_SpecularOcclusionState.lua | 52 ------------ .../TestData/Materials/ParallaxRock.material | 1 - .../001_ManyFeatures.material | 7 +- .../010_AmbientOcclusion.material | 3 +- .../010_BothOcclusion.material | 1 - .../010_SpecularOcclusion.material | 1 - .../100_UvTiling_AmbientOcclusion.material | 1 - .../Materials/Bricks038_8K/bricks038.material | 1 - .../PaintedPlaster015.material | 1 - .../Assets/Objects/Lucy/lucy_brass.material | 1 - .../Assets/Objects/Lucy/lucy_stone.material | 1 - .../Scripts/Python/DCC_Materials/pbr.material | 2 +- .../Scripts/Python/dcc_materials/pbr.material | 2 +- 18 files changed, 65 insertions(+), 205 deletions(-) delete mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua delete mode 100644 Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index b3e4695880..cb66a987ae 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -781,13 +781,6 @@ } ], "occlusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the occlusion features.", - "type": "Bool", - "defaultValue": false - }, { "id": "diffuseTextureMap", "displayName": "Diffuse AO", @@ -1690,15 +1683,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_DiffuseOcclusionState.lua" + "textureProperty": "occlusion.diffuseTextureMap", + "useTextureProperty": "occlusion.diffuseUseTexture", + "dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"], + "shaderOption": "o_diffuseOcclusion_useTexture" } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_SpecularOcclusionState.lua" + "textureProperty": "occlusion.specularTextureMap", + "useTextureProperty": "occlusion.specularUseTexture", + "dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"], + "shaderOption": "o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 62b1f863dd..4ecf9389ba 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -384,13 +384,6 @@ } ], "occlusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the occlusion features.", - "type": "Bool", - "defaultValue": false - }, { "id": "diffuseTextureMap", "displayName": "Diffuse AO", @@ -1069,15 +1062,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_DiffuseOcclusionState.lua" + "textureProperty": "occlusion.diffuseTextureMap", + "useTextureProperty": "occlusion.diffuseUseTexture", + "dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"], + "shaderOption": "o_diffuseOcclusion_useTexture" } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_SpecularOcclusionState.lua" + "textureProperty": "occlusion.specularTextureMap", + "useTextureProperty": "occlusion.specularUseTexture", + "dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"], + "shaderOption": "o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype index c7f0884d9f..7610a4c9db 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.materialtype @@ -1170,13 +1170,6 @@ } ], "layer1_occlusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the occlusion features.", - "type": "Bool", - "defaultValue": false - }, { "id": "diffuseTextureMap", "displayName": "Diffuse AO", @@ -1870,13 +1863,6 @@ } ], "layer2_occlusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the occlusion features.", - "type": "Bool", - "defaultValue": false - }, { "id": "diffuseTextureMap", "displayName": "Diffuse AO", @@ -2570,13 +2556,6 @@ } ], "layer3_occlusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the occlusion features.", - "type": "Bool", - "defaultValue": false - }, { "id": "diffuseTextureMap", "displayName": "Diffuse AO", @@ -3041,21 +3020,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_DiffuseOcclusionState.lua", - "propertyNamePrefix": "layer1_", - "srgNamePrefix": "m_layer1_", - "optionsNamePrefix": "o_layer1_" + "textureProperty": "layer1_occlusion.diffuseTextureMap", + "useTextureProperty": "layer1_occlusion.diffuseUseTexture", + "dependentProperties": ["layer1_occlusion.diffuseTextureMapUv", "layer1_occlusion.diffuseFactor"], + "shaderOption": "o_layer1_o_diffuseOcclusion_useTexture" } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_SpecularOcclusionState.lua", - "propertyNamePrefix": "layer1_", - "srgNamePrefix": "m_layer1_", - "optionsNamePrefix": "o_layer1_" + "textureProperty": "layer1_occlusion.specularTextureMap", + "useTextureProperty": "layer1_occlusion.specularUseTexture", + "dependentProperties": ["layer1_occlusion.specularTextureMapUv", "layer1_occlusion.specularFactor"], + "shaderOption": "o_layer1_o_specularOcclusion_useTexture" } }, { @@ -3178,21 +3157,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_DiffuseOcclusionState.lua", - "propertyNamePrefix": "layer2_", - "srgNamePrefix": "m_layer2_", - "optionsNamePrefix": "o_layer2_" + "textureProperty": "layer2_occlusion.diffuseTextureMap", + "useTextureProperty": "layer2_occlusion.diffuseUseTexture", + "dependentProperties": ["layer2_occlusion.diffuseTextureMapUv", "layer2_occlusion.diffuseFactor"], + "shaderOption": "o_layer2_o_diffuseOcclusion_useTexture" } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_SpecularOcclusionState.lua", - "propertyNamePrefix": "layer2_", - "srgNamePrefix": "m_layer2_", - "optionsNamePrefix": "o_layer2_" + "textureProperty": "layer2_occlusion.specularTextureMap", + "useTextureProperty": "layer2_occlusion.specularUseTexture", + "dependentProperties": ["layer2_occlusion.specularTextureMapUv", "layer2_occlusion.specularFactor"], + "shaderOption": "o_layer2_o_specularOcclusion_useTexture" } }, { @@ -3315,21 +3294,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_DiffuseOcclusionState.lua", - "propertyNamePrefix": "layer3_", - "srgNamePrefix": "m_layer3_", - "optionsNamePrefix": "o_layer3_" + "textureProperty": "layer3_occlusion.diffuseTextureMap", + "useTextureProperty": "layer3_occlusion.diffuseUseTexture", + "dependentProperties": ["layer3_occlusion.diffuseTextureMapUv", "layer3_occlusion.diffuseFactor"], + "shaderOption": "o_layer3_o_diffuseOcclusion_useTexture" } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_SpecularOcclusionState.lua", - "propertyNamePrefix": "layer3_", - "srgNamePrefix": "m_layer3_", - "optionsNamePrefix": "o_layer3_" + "textureProperty": "layer3_occlusion.specularTextureMap", + "useTextureProperty": "layer3_occlusion.specularUseTexture", + "dependentProperties": ["layer3_occlusion.specularTextureMapUv", "layer3_occlusion.specularFactor"], + "shaderOption": "o_layer3_o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype index f8c7edb2ed..e071a793a5 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR.materialtype @@ -725,13 +725,6 @@ } ], "occlusion": [ - { - "id": "enable", - "displayName": "Enable", - "description": "Whether to enable the occlusion features.", - "type": "Bool", - "defaultValue": false - }, { "id": "diffuseTextureMap", "displayName": "Diffuse AO", @@ -1319,15 +1312,21 @@ } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_DiffuseOcclusionState.lua" + "textureProperty": "occlusion.diffuseTextureMap", + "useTextureProperty": "occlusion.diffuseUseTexture", + "dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"], + "shaderOption": "o_diffuseOcclusion_useTexture" } }, { - "type": "Lua", + "type": "UseTexture", "args": { - "file": "StandardPBR_SpecularOcclusionState.lua" + "textureProperty": "occlusion.specularTextureMap", + "useTextureProperty": "occlusion.specularUseTexture", + "dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"], + "shaderOption": "o_specularOcclusion_useTexture" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua deleted file mode 100644 index aed13fa83f..0000000000 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DiffuseOcclusionState.lua +++ /dev/null @@ -1,52 +0,0 @@ --------------------------------------------------------------------------------------- --- --- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or --- its licensors. --- --- For complete copyright and license terms please see the LICENSE at the root of this --- distribution (the "License"). All use of this software is governed by the License, --- or, if provided, by the license below or the license accompanying this file. Do not --- remove or modify any license notices. This file is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- --- ----------------------------------------------------------------------------------------------------- - -function GetMaterialPropertyDependencies() - return {"occlusion.enable", "occlusion.diffuseTextureMap", "occlusion.diffuseUseTexture"} -end - -function GetShaderOptionDependencies() - return {"o_diffuseOcclusion_useTexture"} -end - -function Process(context) - local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") - local textureMap = context:GetMaterialPropertyValue_image("occlusion.diffuseTextureMap") - local enableDiffuse = context:GetMaterialPropertyValue_bool("occlusion.diffuseUseTexture") - - context:SetShaderOptionValue_bool("o_diffuseOcclusion_useTexture", enableOcclusionMaps and textureMap ~= nil and enableDiffuse) -end - -function ProcessEditor(context) - local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") - - if(not enableOcclusionMaps) then - context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMap", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMap", MaterialPropertyVisibility_Enabled) - local textureMap = context:GetMaterialPropertyValue_image("occlusion.diffuseTextureMap") - if(textureMap == nil) then - context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Enabled) - context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Enabled) - context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Enabled) - end - end -end diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua deleted file mode 100644 index d67f658c7b..0000000000 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_SpecularOcclusionState.lua +++ /dev/null @@ -1,52 +0,0 @@ --------------------------------------------------------------------------------------- --- --- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or --- its licensors. --- --- For complete copyright and license terms please see the LICENSE at the root of this --- distribution (the "License"). All use of this software is governed by the License, --- or, if provided, by the license below or the license accompanying this file. Do not --- remove or modify any license notices. This file is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- --- ----------------------------------------------------------------------------------------------------- - -function GetMaterialPropertyDependencies() - return {"occlusion.enable", "occlusion.specularTextureMap", "occlusion.specularUseTexture"} -end - -function GetShaderOptionDependencies() - return {"o_specularOcclusion_useTexture"} -end - -function Process(context) - local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") - local textureMap = context:GetMaterialPropertyValue_image("occlusion.specularTextureMap") - local enableDiffuse = context:GetMaterialPropertyValue_bool("occlusion.specularUseTexture") - - context:SetShaderOptionValue_bool("o_specularOcclusion_useTexture", enableOcclusionMaps and textureMap ~= nil and enableDiffuse) -end - -function ProcessEditor(context) - local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable") - - if(not enableOcclusionMaps) then - context:SetMaterialPropertyVisibility("occlusion.specularTextureMap", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("occlusion.specularTextureMap", MaterialPropertyVisibility_Enabled) - local textureMap = context:GetMaterialPropertyValue_image("occlusion.specularTextureMap") - if(textureMap == nil) then - context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Hidden) - context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Hidden) - else - context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Enabled) - context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Enabled) - context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Enabled) - end - end -end diff --git a/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material b/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material index 1bc5c39e4a..f639534bfb 100644 --- a/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material +++ b/Gems/Atom/TestData/TestData/Materials/ParallaxRock.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseTextureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg" }, "baseColor": { diff --git a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material index 19c87f193d..8f916ec490 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardMultilayerPbrTestCases/001_ManyFeatures.material @@ -29,8 +29,7 @@ }, "layer1_occlusion": { "diffuseFactor": 1.6399999856948853, - "diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg", - "enable": true + "diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg" }, "layer1_parallax": { "enable": true, @@ -73,7 +72,6 @@ "textureMap": "TestData/Textures/cc0/Lava004_1K_Normal.jpg" }, "layer2_occlusion": { - "enable": true, "specularFactor": 2.0, "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" }, @@ -113,8 +111,7 @@ }, "layer3_occlusion": { "diffuseFactor": 1.0399999618530274, - "diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg", - "enable": true + "diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg" }, "layer3_parallax": { "enable": true, diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material index ef75528284..efc375dc81 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_AmbientOcclusion.material @@ -6,8 +6,7 @@ "properties": { "occlusion": { "diffuseFactor": 2.0, - "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg", - "enable": true + "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg" } } } \ No newline at end of file diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material index d8dc4d8609..cee64dd107 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_BothOcclusion.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseFactor": 2.0, "diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg", "specularFactor": 2.0, diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material index afaa9f9f4b..703088d6f8 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/010_SpecularOcclusion.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "specularFactor": 2.0, "specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg" } diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material index 457f0b00e6..e0e4019b8c 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/100_UvTiling_AmbientOcclusion.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseTextureMap": "TestData/Objects/cube/cube_diff.tif" } } diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material index 2650ee3081..b4b1e10b2e 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/Bricks038_8K/bricks038.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseTextureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png" }, "baseColor": { diff --git a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material index 4006b4ec51..2d622e8263 100644 --- a/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material +++ b/Gems/AtomContent/LookDevelopmentStudioPixar/Assets/Materials/PaintedPlaster015_8K/PaintedPlaster015.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseFactor": 0.30000001192092898, "diffuseTextureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png" }, diff --git a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material index e5c3be3e8d..8b37245ae7 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material +++ b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_brass.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif" }, "baseColor": { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material index 79a7e507ec..4f6a9e1292 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material +++ b/Gems/AtomLyIntegration/CommonFeatures/Assets/Objects/Lucy/lucy_stone.material @@ -5,7 +5,6 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "enable": true, "diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif" }, "baseColor": { diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material index 8a74384d10..94fc5a16bd 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Atom/Scripts/Python/DCC_Materials/pbr.material @@ -5,7 +5,7 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "factor": 1.0, + "diffuseFactor": 1.0, "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material index 8a74384d10..94fc5a16bd 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/dcc_materials/pbr.material @@ -5,7 +5,7 @@ "propertyLayoutVersion": 3, "properties": { "occlusion": { - "factor": 1.0, + "diffuseFactor": 1.0, "diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif" }, "baseColor": { From 8a8ecf25d6022f8bdf0adeb2151a70a5928d44c6 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Tue, 20 Apr 2021 21:54:55 -0700 Subject: [PATCH 13/27] Fixed ATOM-15297 StandardPBR_ForwardPass.shadervariantlist Job Fails With Obscure Error ShaderVariantAssetBuilder::ProcessJob was not handling the should-exit-early flag, described at ValidateShaderVariantListLocation(). It was assuming that this flag would be set only during error conditions, which is not the case. I just had to rearrange the logic to handle deferred errors and should-exit-early separately. Testing: The problematic job now finishes successfully. I also edited the shadervariantlist file to give it a bad path to the shader and confirmed that we still get the "Error during CreateJobs" message. --- .../Source/Editor/ShaderVariantAssetBuilder.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp index 1e3c7b6759..ccb984b416 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp @@ -405,18 +405,20 @@ namespace AZ void ShaderVariantAssetBuilder::ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const { const auto& jobParameters = request.m_jobDescription.m_jobParameters; + if (jobParameters.find(ShaderVariantLoadErrorParam) != jobParameters.end()) { - if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) - { - AZ_TracePrintf(ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overriden by game project.", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); - response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; - return; - } AZ_Error(ShaderVariantAssetBuilderName, false, "Error during CreateJobs: %s", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed; return; } + + if (jobParameters.find(ShouldExitEarlyFromProcessJobParam) != jobParameters.end()) + { + AZ_TracePrintf(ShaderVariantAssetBuilderName, "Doing nothing on behalf of [%s] because it's been overridden by game project.", jobParameters.at(ShaderVariantLoadErrorParam).c_str()); + response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; + return; + } AssetBuilderSDK::JobCancelListener jobCancelListener(request.m_jobId); if (jobCancelListener.IsCancelled()) From 8fe1505d1d755f539407af16ff97f8304c593a90 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Wed, 21 Apr 2021 00:32:41 -0700 Subject: [PATCH 14/27] Fixed up issues with my prior occlusion changes, after merging latest main, got everything working again. ATOM-14040 Add Support for Cavity Maps --- .../Assets/Materials/Types/StandardPBR_ForwardPass.azsl | 5 ++--- .../Atom/Features/PBR/Lighting/LightingData.azsli | 8 ++++++-- .../Atom/Features/PBR/Lighting/StandardLighting.azsli | 7 ++----- .../ShaderLib/Atom/Features/PBR/LightingModel.azsli | 3 ++- .../Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl index fe465faec5..c08dc53c6a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl @@ -213,9 +213,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Occlusion ------- - float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); - float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); - + lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); // ------- Clearcoat ------- diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index aa5fa05bcf..37cae0acb1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -47,8 +47,10 @@ class LightingData // Normal . View float NdotV; + // Occlusion factors // 0 = dark, 1 = light - float occlusion; + float diffuseAmbientOcclusion; + float specularOcclusion; void Init(float3 positionWS, float3 normal, float roughnessLinear); void CalculateMultiscatterCompensation(float3 specularF0, bool enabled); @@ -62,7 +64,8 @@ void LightingData::Init(float3 positionWS, float3 normal, float roughnessLinear) translucentBackLighting = 0; multiScatterCompensation = 1.0f; emissiveLighting = float3(0.0f, 0.0f, 0.0f); - occlusion = 1.0f; + diffuseAmbientOcclusion = 1.0f; + specularOcclusion = 1.0f; dirToCamera = normalize(ViewSrg::m_worldPosition.xyz - positionWS); @@ -79,6 +82,7 @@ void LightingData::CalculateMultiscatterCompensation(float3 specularF0, bool ena void LightingData::FinalizeLighting(float3 transmissionTint) { + specularLighting *= specularOcclusion; specularLighting += emissiveLighting; // Transmitted light diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli index 31fbbd2138..d0fb78a6d5 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli @@ -45,8 +45,8 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat // albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc) lightingOutput.m_specularF0 = float4(surface.specularF0, surface.roughnessLinear); - lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse; - lightingOutput.m_albedo.a = lightingData.occlusion; + lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse * lightingData.diffuseAmbientOcclusion; + lightingOutput.m_albedo.a = lightingData.specularOcclusion; lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal); lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; @@ -58,6 +58,3 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat - - - diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli index 5bdefca637..a3a9c9ffd1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli @@ -109,7 +109,8 @@ PbrLightingOutput PbrLighting( VSOutput IN, lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); lightingData.emissiveLighting = emissive; - lightingData.occlusion = occlusion; + lightingData.diffuseAmbientOcclusion = diffuseAmbientOcclusion; + lightingData.specularOcclusion = specularOcclusion; // Directional light shadow coordinates lightingData.shadowCoords = shadowCoords; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli index f08acd2684..bbb6a33b55 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli @@ -76,7 +76,7 @@ void ApplyIBL(Surface surface, inout LightingData lightingData) // Adjust IBL lighting by exposure. float iblExposureFactor = pow(2.0, SceneSrg::m_iblExposure); - lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.occlusion); + lightingData.diffuseLighting += (iblDiffuse * iblExposureFactor * lightingData.diffuseAmbientOcclusion); lightingData.specularLighting += (iblSpecular * iblExposureFactor); } } From 496891b4c05686879a883619a8ccf54a49d5b275 Mon Sep 17 00:00:00 2001 From: greerdv Date: Wed, 21 Apr 2021 10:55:05 +0100 Subject: [PATCH 15/27] feedback from PR --- .../Include/Atom/RHI/RayTracingAccelerationStructure.h | 2 +- Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp | 8 +++++--- .../Code/Source/Mesh/MeshComponentController.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h index 317094e24c..5fde518cb2 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingAccelerationStructure.h @@ -12,7 +12,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 46059a3132..15c8aaf528 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -167,16 +167,18 @@ namespace AZ bool Model::RayIntersection(const AZ::Transform& modelTransform, const AZ::Vector3& nonUniformScale, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distanceFactor, AZ::Vector3& normal) const { AZ_PROFILE_FUNCTION(Debug::ProfileCategory::AzRender); + const AZ::Vector3 clampedScale = nonUniformScale.GetMax(AZ::Vector3(AZ::MinTransformScale)); + const AZ::Transform inverseTM = modelTransform.GetInverse(); - const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / nonUniformScale; + const AZ::Vector3 raySrcLocal = inverseTM.TransformPoint(rayStart) / clampedScale; // Instead of just rotating 'dir' we need it to be scaled too, so that 'distanceFactor' will be in the target units rather than object local units. const AZ::Vector3 rayDest = rayStart + dir; - const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / nonUniformScale; + const AZ::Vector3 rayDestLocal = inverseTM.TransformPoint(rayDest) / clampedScale; const AZ::Vector3 rayDirLocal = rayDestLocal - raySrcLocal; bool result = LocalRayIntersection(raySrcLocal, rayDirLocal, distanceFactor, normal); - normal = (normal * nonUniformScale).GetNormalized(); + normal = (normal * clampedScale).GetNormalized(); return result; } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index c99ca7b848..b0315fdf9c 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -232,7 +232,7 @@ namespace AZ return m_configuration; } - void MeshComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, [[maybe_unused]] const AZ::Transform& world) + void MeshComponentController::OnTransformChanged(const AZ::Transform& /*local*/, const AZ::Transform& world) { if (m_meshFeatureProcessor) { From 70b4938cffed004679b0bf6c0de9280cddab02a7 Mon Sep 17 00:00:00 2001 From: phistere Date: Wed, 21 Apr 2021 11:55:01 -0500 Subject: [PATCH 16/27] LYN-2524: Launch AP from SDK when not found in the executable directory --- .../AssetSystemComponentHelper_Linux.cpp | 26 ++++++++++++++++--- .../Asset/AssetSystemComponentHelper_Mac.cpp | 22 ++++++++++++++++ .../AssetSystemComponentHelper_Windows.cpp | 21 +++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp index 1f71b97a57..4f9aeaf6c3 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp @@ -29,6 +29,29 @@ namespace AzFramework::AssetSystem::Platform bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot, AZStd::string_view projectPath) { + AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory }; + assetProcessorPath /= "AssetProcessor"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. + assetProcessorPath.Assign(engineRoot); + assetProcessorPath /= "bin"; +#if defined(AZ_DEBUG_BUILD) + assetProcessorPath /= "debug"; +#elif defined(AZ_PROFILE_BUILD) + assetProcessorPath /= "profile"; +#else + assetProcessorPath /= "release"; +#endif + assetProcessorPath /= "AssetProcessor"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + pid_t firstChildPid = fork(); if (firstChildPid == 0) { @@ -47,9 +70,6 @@ namespace AzFramework::AssetSystem::Platform pid_t secondChildPid = fork(); if (secondChildPid == 0) { - AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory }; - assetProcessorPath /= "AssetProcessor"; - AZStd::array args { assetProcessorPath.c_str(), assetProcessorPath.c_str(), "--start-hidden", static_cast(nullptr), static_cast(nullptr), static_cast(nullptr) diff --git a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp index 43f7599676..cc31cc9a0c 100644 --- a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp +++ b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -20,6 +21,7 @@ namespace AzFramework::AssetSystem::Platform { void AllowAssetProcessorToForeground() {} + bool LaunchAssetProcessor(AZStd::string_view executableDirectory, AZStd::string_view engineRoot, AZStd::string_view projectPath) { @@ -29,6 +31,26 @@ namespace AzFramework::AssetSystem::Platform assetProcessorPath /= "../../../AssetProcessor.app"; assetProcessorPath = assetProcessorPath.LexicallyNormal(); + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. + assetProcessorPath.Assign(engineRoot); + assetProcessorPath /= "bin"; + #if defined(AZ_DEBUG_BUILD) + assetProcessorPath /= "debug"; +#elif defined(AZ_PROFILE_BUILD) + assetProcessorPath /= "profile"; +#else + assetProcessorPath /= "release"; +#endif + assetProcessorPath /= "AssetProcessor.app"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"(open -g "%s" --args --start-hidden)", assetProcessorPath.c_str()); // Add the engine path to the launch command if not empty if (!engineRoot.empty()) diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index 3f4dbef22a..155a69a691 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -67,6 +68,26 @@ namespace AzFramework::AssetSystem::Platform AZ::IO::FixedMaxPath assetProcessorPath{ executableDirectory }; assetProcessorPath /= "AssetProcessor.exe"; + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. + assetProcessorPath.Assign(engineRoot); + assetProcessorPath /= "bin"; +#if defined(AZ_DEBUG_BUILD) + assetProcessorPath /= "debug"; +#elif defined(AZ_PROFILE_BUILD) + assetProcessorPath /= "profile"; +#else + assetProcessorPath /= "release"; +#endif + assetProcessorPath /= "AssetProcessor.exe"; + + if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) + { + return false; + } + } + auto fullLaunchCommand = AZ::IO::FixedMaxPathString::format(R"("%s" --start-hidden)", assetProcessorPath.c_str()); // Add the engine path to the launch command if not empty From a3e1d84566270ae09681e7e33f191f911d13ec03 Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 21 Apr 2021 10:54:26 -0700 Subject: [PATCH 17/27] Test metrics uses both Jenkins endpoints fix --- scripts/build/Jenkins/Jenkinsfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 662ddc7454..4f4708aea3 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -349,6 +349,18 @@ def Build(Map options, String platform, String type, String workspace) { } } +def getJenkinsBaseUrl() { + def job_url = new URL(env.JOB_URL) + + // Return a new URL using the protocol, host and port only. + return new URL( + job_url.getProtocol(), + job_url.getHost(), + job_url.getPort(), + '' + ).toString() +} + def TestMetrics(Map options, String workspace, String branchName, String repoName, String buildJobName, String outputDirectory, String configuration) { catchError(buildResult: null, stageResult: null) { def cmakeBuildDir = [workspace, ENGINE_REPOSITORY_NAME, outputDirectory].join('/') @@ -360,7 +372,11 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py -e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} ${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " + def jenkins_url = getJenkinsBaseUrl() + def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py" + + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + + "-e jenkins.base_url ${jenkins_url}" + + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command } From 07c0f05abb31a7176e0c1b508c87ac2dd21fa5cb Mon Sep 17 00:00:00 2001 From: mriegger Date: Wed, 21 Apr 2021 11:54:37 -0700 Subject: [PATCH 18/27] Fix for directional light not having shadows in editor --- .../CoreLights/DirectionalLightFeatureProcessor.cpp | 2 ++ .../DirectionalLightComponentController.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp index f44a56233e..04175c461f 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp @@ -1238,6 +1238,8 @@ namespace AZ void DirectionalLightFeatureProcessor::SetFilterParameterToPass(LightHandle handle, const RPI::View* cameraView) { + AZ_ATOM_PROFILE_FUNCTION("DirectionalLightFeatureProcessor", "DirectionalLightFeatureProcessor::SetFilterParameterToPass"); + if (handle != m_shadowingLightHandle) { return; diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp index c7d459c596..310e6e6eca 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/CoreLights/DirectionalLightComponentController.cpp @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include namespace AZ { @@ -586,9 +589,11 @@ namespace AZ } else { - Camera::ActiveCameraRequestBus::BroadcastResult( - cameraTransform, - &Camera::ActiveCameraRequestBus::Events::GetActiveCameraTransform); + if (const auto& viewportContext = AZ::Interface::Get()->GetDefaultViewportContext()) + { + cameraTransform = viewportContext->GetCameraTransform(); + } + } if (cameraTransform == m_lastCameraTransform) { From 7bfde0ddba9d025ee401e0d8362c1868f64d7ff1 Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 21 Apr 2021 12:45:14 -0700 Subject: [PATCH 19/27] Using jenkins env var instead of extracting function --- scripts/build/Jenkins/Jenkinsfile | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 4f4708aea3..cdb7874231 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -349,18 +349,6 @@ def Build(Map options, String platform, String type, String workspace) { } } -def getJenkinsBaseUrl() { - def job_url = new URL(env.JOB_URL) - - // Return a new URL using the protocol, host and port only. - return new URL( - job_url.getProtocol(), - job_url.getHost(), - job_url.getPort(), - '' - ).toString() -} - def TestMetrics(Map options, String workspace, String branchName, String repoName, String buildJobName, String outputDirectory, String configuration) { catchError(buildResult: null, stageResult: null) { def cmakeBuildDir = [workspace, ENGINE_REPOSITORY_NAME, outputDirectory].join('/') @@ -372,10 +360,9 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def jenkins_url = getJenkinsBaseUrl() def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py" + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + - "-e jenkins.base_url ${jenkins_url}" + + "-e jenkins.base_url ${env.JENKINS_URL}" + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command From efacc3c8bb69a5c3836d0711752129ab10a5453d Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 21 Apr 2021 13:28:12 -0700 Subject: [PATCH 20/27] Adding missing spaces in test metrics command string --- scripts/build/Jenkins/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index cdb7874231..4352cb1e6a 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -360,9 +360,9 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py" + + def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py " + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + - "-e jenkins.base_url ${env.JENKINS_URL}" + + "-e jenkins.base_url ${env.JENKINS_URL} " + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command From cd00d51bed78402432d76a30b2e1765e12149377 Mon Sep 17 00:00:00 2001 From: Chris Santora Date: Wed, 21 Apr 2021 14:17:39 -0700 Subject: [PATCH 21/27] Updated more materials for renamed occlusion properties. I guess these were added to main recently. ATOM-14040 Add Support for Cavity Maps --- .../Sponza/Assets/objects/sponza_mat_arch.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_background.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_bricks.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_ceiling.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_columna.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_columnb.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_columnc.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_curtainblue.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_curtaingreen.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_curtainred.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_details.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_fabricblue.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_fabricgreen.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_fabricred.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_flagpole.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_floor.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_lion.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_roof.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_vase.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_vasehanging.material | 5 ++--- .../Sponza/Assets/objects/sponza_mat_vaseround.material | 5 ++--- 21 files changed, 42 insertions(+), 63 deletions(-) diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material index da72f8a430..770e8b92cf 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_arch.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/arch_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/arch_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material index 5a195fd0b6..1347f71c86 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_background.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/background_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/background_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material index d2089b5537..4671e3906d 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_bricks.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/bricks_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/bricks_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material index 40e476305d..3c15eb8227 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_ceiling.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/ceiling_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/ceiling_1k_ao.png" }, "baseColor": { "textureBlendMode": "Lerp", diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material index 6c89c94021..62ac3e7ed7 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columna.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/columnA_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/columnA_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material index 0be26ba553..bf1e9aea61 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnb.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/columnB_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/columnB_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material index 2f1512fa4a..9614428cd8 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_columnc.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/columnC_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/columnC_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material index e68bc7a41a..47cd16b0eb 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainblue.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/curtain_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/curtain_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material index 85a5ef9775..aba840ce9e 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtaingreen.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/curtain_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/curtain_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material index 086f34727c..7255e35e88 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_curtainred.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/curtain_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/curtain_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material index 18bd2a307b..5586d371a8 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_details.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/details_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/details_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material index fb0490f9a9..23168ff9b5 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricblue.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/fabric_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/fabric_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material index c6074bf894..5760004e39 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricgreen.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/fabric_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/fabric_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material index 4215d8dde5..bd3eea7ed3 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_fabricred.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/fabric_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/fabric_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material index cbba302103..b649ca13a2 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_flagpole.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/flagpole_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/flagpole_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material index 2c2abe3931..5cb52480ec 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_floor.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/floor_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/floor_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material index 55f44b2f63..32dd098c99 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_lion.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/lion_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/lion_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material index a64486309d..fda36db2a3 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_roof.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/roof_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/roof_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material index 867943642e..6538caf94b 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vase.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/vase_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/vase_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material index 9e96fb983d..7f090b54da 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vasehanging.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/vaseHanging_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/vaseHanging_1k_ao.png" }, "baseColor": { "color": [ diff --git a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material index ebb4e537f5..78c30d614f 100644 --- a/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material +++ b/Gems/AtomContent/Sponza/Assets/objects/sponza_mat_vaseround.material @@ -4,9 +4,8 @@ "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { - "ambientOcclusion": { - "enable": true, - "textureMap": "Textures/vaseRound_1k_ao.png" + "occlusion": { + "diffuseTextureMap": "Textures/vaseRound_1k_ao.png" }, "baseColor": { "color": [ From f36bfd9db5ae5d9ef474a49b527aaf7c35762191 Mon Sep 17 00:00:00 2001 From: phistere Date: Wed, 21 Apr 2021 19:53:07 -0500 Subject: [PATCH 22/27] LYN-2524: Adding more files to CMake install to help AP run from SDK. Fixes an issue configuring an external project. --- cmake/PAL.cmake | 10 +++--- cmake/Platform/Common/Install_common.cmake | 40 +++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/cmake/PAL.cmake b/cmake/PAL.cmake index 5131005c72..c7adb660f0 100644 --- a/cmake/PAL.cmake +++ b/cmake/PAL.cmake @@ -63,10 +63,12 @@ function(ly_get_absolute_pal_filename out_name in_name) set(full_name ${in_name}) if (NOT EXISTS ${full_name}) string(REGEX MATCH "${repo_dir}/(.*)/Platform/([^/]*)/?(.*)$" match ${full_name}) - if(${CMAKE_MATCH_2} IN_LIST PAL_RESTRICTED_PLATFORMS) - set(full_name ${repo_dir}/restricted/${CMAKE_MATCH_2}/${CMAKE_MATCH_1}) - if(NOT "${CMAKE_MATCH_3}" STREQUAL "") - string(APPEND full_name "/" ${CMAKE_MATCH_3}) + if(PAL_RESTRICTED_PLATFORMS) + if("${CMAKE_MATCH_2}" IN_LIST PAL_RESTRICTED_PLATFORMS) + set(full_name ${repo_dir}/restricted/${CMAKE_MATCH_2}/${CMAKE_MATCH_1}) + if(NOT "${CMAKE_MATCH_3}" STREQUAL "") + string(APPEND full_name "/" ${CMAKE_MATCH_3}) + endif() endif() endif() endif() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 286f449acd..023b7369a7 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -184,7 +184,7 @@ function(ly_setup_cmake_install) install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . - REGEX "Findo3de.cmake" EXCLUDE + REGEX "Findo3de.cmake" EXCLUDE REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE ) install( @@ -265,6 +265,44 @@ function(ly_setup_others) REGEX "runtime" EXCLUDE ) + # Registry + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/bin/$/Registry + DESTINATION ./bin/$ + ) + install(DIRECTORY + # This one will change soon, Engine/Registry files will be relocated to Registry + ${CMAKE_SOURCE_DIR}/Engine/Registry + DESTINATION ./Engine + ) + install(FILES + ${CMAKE_SOURCE_DIR}/AssetProcessorPlatformConfig.setreg + DESTINATION ./Registry + ) + + # Qt Binaries + set(QT_BIN_DIRS bearer iconengines imageformats platforms styles translations) + foreach(qt_dir ${QT_BIN_DIRS}) + install(DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}/bin/$/${qt_dir} + DESTINATION ./bin/$ + ) + endforeach() + + # Templates + install(DIRECTORY + ${CMAKE_SOURCE_DIR}/Templates + DESTINATION . + ) + + # Misc + install(FILES + ${CMAKE_SOURCE_DIR}/ctest_pytest.ini + ${CMAKE_SOURCE_DIR}/LICENSE.txt + ${CMAKE_SOURCE_DIR}/README.md + DESTINATION . + ) + endfunction() From 93ba2ea25175164b20a2458d258887edaf12b5ea Mon Sep 17 00:00:00 2001 From: phistere Date: Thu, 22 Apr 2021 11:42:58 -0500 Subject: [PATCH 23/27] LYN-2524: Updates for PR feedback. Simplify path building, fix whitespace. --- .../Asset/AssetSystemComponentHelper_Linux.cpp | 11 +---------- .../Asset/AssetSystemComponentHelper_Mac.cpp | 11 +---------- .../Asset/AssetSystemComponentHelper_Windows.cpp | 11 +---------- cmake/Platform/Common/Install_common.cmake | 2 +- 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp index 4f9aeaf6c3..1ae3945bd6 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Asset/AssetSystemComponentHelper_Linux.cpp @@ -35,16 +35,7 @@ namespace AzFramework::AssetSystem::Platform if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. - assetProcessorPath.Assign(engineRoot); - assetProcessorPath /= "bin"; -#if defined(AZ_DEBUG_BUILD) - assetProcessorPath /= "debug"; -#elif defined(AZ_PROFILE_BUILD) - assetProcessorPath /= "profile"; -#else - assetProcessorPath /= "release"; -#endif - assetProcessorPath /= "AssetProcessor"; + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor"; if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { diff --git a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp index cc31cc9a0c..6f1f860932 100644 --- a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp +++ b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Asset/AssetSystemComponentHelper_Mac.cpp @@ -34,16 +34,7 @@ namespace AzFramework::AssetSystem::Platform if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. - assetProcessorPath.Assign(engineRoot); - assetProcessorPath /= "bin"; - #if defined(AZ_DEBUG_BUILD) - assetProcessorPath /= "debug"; -#elif defined(AZ_PROFILE_BUILD) - assetProcessorPath /= "profile"; -#else - assetProcessorPath /= "release"; -#endif - assetProcessorPath /= "AssetProcessor.app"; + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.app"; if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index 155a69a691..b716778cf4 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -71,16 +71,7 @@ namespace AzFramework::AssetSystem::Platform if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { // Check for existence of one under a "bin" directory, i.e. engineRoot is an SDK structure. - assetProcessorPath.Assign(engineRoot); - assetProcessorPath /= "bin"; -#if defined(AZ_DEBUG_BUILD) - assetProcessorPath /= "debug"; -#elif defined(AZ_PROFILE_BUILD) - assetProcessorPath /= "profile"; -#else - assetProcessorPath /= "release"; -#endif - assetProcessorPath /= "AssetProcessor.exe"; + assetProcessorPath = AZ::IO::FixedMaxPath{engineRoot} / "bin" / AZ_BUILD_CONFIGURATION_TYPE / "AssetProcessor.exe"; if (!AZ::IO::SystemFile::Exists(assetProcessorPath.c_str())) { diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 023b7369a7..105b208338 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -184,7 +184,7 @@ function(ly_setup_cmake_install) install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . - REGEX "Findo3de.cmake" EXCLUDE + REGEX "Findo3de.cmake" EXCLUDE REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE ) install( From 3aa05440764b2892a1ca31480c7420340e6c12fc Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Thu, 22 Apr 2021 10:06:28 -0700 Subject: [PATCH 24/27] Fix AssetProcessor crash on Mac --- .../ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp index e6ab482ef4..9cac7bd021 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/UnitTesting/UnitTestBusSender.cpp @@ -388,9 +388,8 @@ namespace ScriptCanvas { AZ::ScriptCanvasAttributes::HiddenIndices uniqueIdIndex = { 0 }; - auto builder = behaviorContext->Class("Unit Testing") - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ; + auto builder = behaviorContext->Class("Unit Testing"); + builder->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common); builder->Method("Add Failure", &EventSender::AddFailure, { { {"", "", behaviorContext->MakeDefaultValue(UniqueId)}, {"Report", "additional notes for the test report"} } }) ->Attribute(AZ::ScriptCanvasAttributes::HiddenParameterIndex, uniqueIdIndex) From e5a990b05c962b56c6b07fc42f7e5e4e810839c6 Mon Sep 17 00:00:00 2001 From: jckand Date: Thu, 22 Apr 2021 13:20:44 -0500 Subject: [PATCH 25/27] LYN-3120: Temporarily disabling reset of view pane layout in editor_test_helper.py teardown. Updating view of planting area for several DynVeg tests that was changed with the addition of the default level entity. --- .../PythonTests/automatedtesting_shared/editor_test_helper.py | 3 ++- .../dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py | 2 ++ .../AreaComponentSlices_SliceCreationAndVisibilityToggle.py | 2 ++ ...ceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py | 2 ++ .../DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py | 2 ++ .../DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py | 1 + .../EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py | 2 ++ .../EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py | 2 ++ .../EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py | 1 + .../dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py | 2 ++ .../EditorScripts/MeshBlocker_InstancesBlockedByMesh.py | 3 +++ .../RotationModifierOverrides_InstancesRotateWithinRange.py | 2 +- .../RotationModifier_InstancesRotateWithinRange.py | 2 +- .../dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py | 3 +++ .../dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py | 2 ++ .../dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py | 2 ++ .../dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py | 3 +++ .../dyn_veg/EditorScripts/SystemSettings_SectorSize.py | 3 +++ 18 files changed, 36 insertions(+), 3 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py index 64a19aafdf..ed9a8a58fa 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/editor_test_helper.py @@ -117,7 +117,8 @@ class EditorTestHelper: # Set the viewport back to whatever size it was at the start and restore the pane layout general.set_viewport_size(int(self.viewport_size.x), int(self.viewport_size.y)) general.set_viewport_expansion_policy("AutoExpand") - general.set_view_pane_layout(self.viewport_layout) + # Temporarily disabling reset of view pane layout: LYN-3120 + # general.set_view_pane_layout(self.viewport_layout) general.update_viewport() self.log("test finished") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py index 1c51cc9554..50511811f1 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AltitudeFilter_FilterStageToggle.py @@ -53,6 +53,8 @@ class TestAltitudeFilterFilterStageToggle(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py index d1fe82e3f7..1123a63ae4 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/AreaComponentSlices_SliceCreationAndVisibilityToggle.py @@ -59,6 +59,8 @@ class TestAreaComponentsSliceCreationAndVisibilityToggle(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) C2627900 Verifies if a slice containing the Vegetation Layer Spawner component can be created. # 2.1) Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py index 82b2fc8407..5fed50ced9 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilterOverrides_InstancesPlantAtSpecifiedRadius.py @@ -63,6 +63,8 @@ class TestDistanceBetweenFilterComponentOverrides(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components spawner_center_point = math.Vector3(520.0, 520.0, 32.0) asset_path = os.path.join("Slices", "1m_cube.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py index 9f15215358..ab4863e636 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DistanceBetweenFilter_InstancesPlantAtSpecifiedRadius.py @@ -61,6 +61,8 @@ class TestDistanceBetweenFilterComponent(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components spawner_center_point = math.Vector3(520.0, 520.0, 32.0) asset_path = os.path.join("Slices", "1m_cube.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py index b58c7488e5..366dd057bc 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_DynamicSliceSpawnerWorks.py @@ -43,6 +43,7 @@ class TestDynamicSliceInstanceSpawner(EditorTestHelper): use_terrain=False, ) general.idle_wait(1.0) + general.set_current_view_position(512.0, 480.0, 38.0) # Grab the UUID that we need for creating an Dynamic Slice Instance Spawner dynamic_slice_spawner_uuid = azlmbr.math.Uuid_CreateString('{BBA5CC1E-B4CA-4792-89F7-93711E98FBD1}', 0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py index f25fbb2b6d..dc5b5798a1 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_Embedded_E2E.py @@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerEmbeddedEditor(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components and Script Canvas component for launcher test center_point = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py index 8af75f2d17..0deb63d374 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/DynamicSliceInstanceSpawner_External_E2E.py @@ -65,6 +65,8 @@ class TestDynamicSliceInstanceSpawnerExternalEditor(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create a new entity with required vegetation area components and switch the Vegetation Asset List Source # Type to External entity_position = math.Vector3(512.0, 512.0, 32.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py index 4067de90fc..fd45fdcf2f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/EmptyInstanceSpawner_EmptySpawnerWorks.py @@ -43,6 +43,7 @@ class TestEmptyInstanceSpawner(EditorTestHelper): use_terrain=False, ) general.idle_wait(1.0) + general.set_current_view_position(512.0, 480.0, 38.0) # Grab the UUID that we need for creating an Empty Spawner empty_spawner_uuid = azlmbr.math.Uuid_CreateString('{23C40FD4-A55F-4BD3-BE5B-DC5423F217C2}', 0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py index f55243bc9c..59e20169e7 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/LayerSpawner_InheritBehaviorFlag.py @@ -60,6 +60,8 @@ class TestLayerSpawnerInheritBehavior(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create Emitter entity and add the required components position = math.Vector3(512.0, 512.0, 32.0) emitter_entity = dynveg.create_surface_entity("emitter_entity", position, 16.0, 16.0, 1.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py index 02dcc1f067..437dc31118 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/MeshBlocker_InstancesBlockedByMesh.py @@ -61,6 +61,9 @@ class test_MeshBlocker_InstancesBlockedByMesh(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(500.49, 498.69, 46.66) + general.set_current_view_rotation(-42.05, 0.00, -36.33) + # Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape" entity_position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py index b63692527c..64fee5d657 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifierOverrides_InstancesRotateWithinRange.py @@ -90,7 +90,7 @@ class TestRotationModifierOverrides_InstancesRotateWithinRange(EditorTestHelper) terrain_texture_resolution=4096, use_terrain=False, ) - general.run_console("e_WaterOcean=0") + general.set_current_view_position(512.0, 480.0, 38.0) # 2) Create vegetation entity and add components entity_position = math.Vector3(512.0, 512.0, 32.0) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py index a14363d5e9..b867b3a02c 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/RotationModifier_InstancesRotateWithinRange.py @@ -103,7 +103,7 @@ class TestRotationModifier_InstancesRotateWithinRange(EditorTestHelper): terrain_texture_resolution=4096, use_terrain=False, ) - general.run_console("e_WaterOcean=0") + general.set_current_view_position(512.0, 480.0, 38.0) # 2) Set up vegetation entities asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py index a907c7a0af..91617c0567 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SlopeFilter_FilterStageToggle.py @@ -17,6 +17,7 @@ import azlmbr.paths import azlmbr.editor as editor import azlmbr.entity as EntityId import azlmbr.components as components +import azlmbr.legacy.general as general sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) import automatedtesting_shared.hydra_editor_utils as hydra @@ -48,6 +49,8 @@ class TestSlopeFilterFilterStageToggle(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py index 1bec5e46ae..bc5b441513 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_ExclusionList.py @@ -103,6 +103,8 @@ class TestExclusiveSurfaceMasksTag(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape" entity_position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py index fbaecf1972..e9682edbc8 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SurfaceMaskFilter_InclusionList.py @@ -104,6 +104,8 @@ class TestInclusiveSurfaceMasksTag(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # 2) Create entity with components "Vegetation Layer Spawner", "Vegetation Asset List", "Box Shape" entity_position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PurpleFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py index f1e6a93760..af477d19ff 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorPointDensity.py @@ -15,6 +15,7 @@ import azlmbr.math as math import azlmbr.paths import azlmbr.editor as editor import azlmbr.bus as bus +import azlmbr.legacy.general as general sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) import automatedtesting_shared.hydra_editor_utils as hydra @@ -52,6 +53,8 @@ class TestSystemSettingsSectorPointDensity(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py index 5e80bd6b33..8c001b90ea 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/EditorScripts/SystemSettings_SectorSize.py @@ -15,6 +15,7 @@ import azlmbr.math as math import azlmbr.paths import azlmbr.editor as editor import azlmbr.bus as bus +import azlmbr.legacy.general as general sys.path.append(os.path.join(azlmbr.paths.devroot, "AutomatedTesting", "Gem", "PythonTests")) import automatedtesting_shared.hydra_editor_utils as hydra @@ -48,6 +49,8 @@ class TestSystemSettingsSectorSize(EditorTestHelper): use_terrain=False, ) + general.set_current_view_position(512.0, 480.0, 38.0) + # Create basic vegetation entity position = math.Vector3(512.0, 512.0, 32.0) asset_path = os.path.join("Slices", "PinkFlower.dynamicslice") From d6809950744fd79b34b8732388e6af70aaae101c Mon Sep 17 00:00:00 2001 From: Terry Michaels <81711813+tjmichaels@users.noreply.github.com> Date: Thu, 22 Apr 2021 13:31:26 -0500 Subject: [PATCH 26/27] Renamed several non-inclusive terms (#236) --- .../AzCore/AzCore/Debug/AssetTracking.cpp | 24 ++++++------- .../AzCore/AzCore/Debug/AssetTrackingTypes.h | 8 ++--- .../AzCore/Debug/AssetTrackingTypesImpl.h | 12 +++---- .../AzCore/Tests/Debug/AssetTracking.cpp | 2 +- Code/Sandbox/Editor/CryEditDoc.h | 1 - Code/Sandbox/Editor/Export/ExportManager.cpp | 34 +++++++++---------- Code/Sandbox/Editor/Export/ExportManager.h | 8 ++--- Code/Sandbox/Editor/FBXExporterDialog.cpp | 6 ++-- Code/Sandbox/Editor/FBXExporterDialog.h | 4 +-- Code/Sandbox/Editor/FBXExporterDialog.ui | 4 +-- Code/Sandbox/Editor/Lib/Tests/IEditorMock.h | 2 +- .../SceneCore/Export/MtlMaterialExporter.cpp | 2 +- .../SceneUI/SceneWidgets/SceneGraphWidget.h | 2 +- .../Code/Source/AssetMemoryAnalyzer.cpp | 2 +- 14 files changed, 55 insertions(+), 56 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp b/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp index 787dcff22d..f238b8a74a 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTracking.cpp @@ -63,13 +63,13 @@ namespace AZ static AssetTrackingImpl* GetSharedInstance(); static ThreadData& GetSharedThreadData(); - using MasterAssets = AZStd::unordered_map, AZStd::equal_to, AZStdAssetTrackingAllocator>; + using PrimaryAssets = AZStd::unordered_map, AZStd::equal_to, AZStdAssetTrackingAllocator>; using ThreadData = ThreadData; using mutex_type = AZStd::mutex; using lock_type = AZStd::lock_guard; mutex_type m_mutex; - MasterAssets m_masterAssets; + PrimaryAssets m_primaryAssets; AssetTreeNodeBase* m_assetRoot = nullptr; AssetAllocationTableBase* m_allocationTable = nullptr; bool m_performingAnalysis = false; @@ -118,7 +118,7 @@ namespace AZ auto& threadData = GetSharedThreadData(); AssetTreeNodeBase* parentAsset = threadData.m_currentAssetStack.empty() ? nullptr : threadData.m_currentAssetStack.back(); AssetTreeNodeBase* childAsset; - AssetMasterInfo* assetMasterInfo; + AssetPrimaryInfo* assetPrimaryInfo; if (!parentAsset) { @@ -128,22 +128,22 @@ namespace AZ { lock_type lock(m_mutex); - // Locate or create the master record for this asset - auto masterItr = m_masterAssets.find(assetId); + // Locate or create the primary record for this asset + auto primaryItr = m_primaryAssets.find(assetId); - if (masterItr != m_masterAssets.end()) + if (primaryItr != m_primaryAssets.end()) { - assetMasterInfo = &masterItr->second; + assetPrimaryInfo = &primaryItr->second; } else { - auto insertResult = m_masterAssets.emplace(assetId, AssetMasterInfo()); - assetMasterInfo = &insertResult.first->second; - assetMasterInfo->m_id = &insertResult.first->first; + auto insertResult = m_primaryAssets.emplace(assetId, AssetPrimaryInfo()); + assetPrimaryInfo = &insertResult.first->second; + assetPrimaryInfo->m_id = &insertResult.first->first; } // Add this asset to the stack for this thread's context - childAsset = parentAsset->FindOrAddChild(assetId, assetMasterInfo); + childAsset = parentAsset->FindOrAddChild(assetId, assetPrimaryInfo); } threadData.m_currentAssetStack.push_back(childAsset); @@ -304,7 +304,7 @@ namespace AZ char* pos = buffer; for (auto itr = assetStack.rbegin(); itr != assetStack.rend(); ++itr) { - pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetMasterInfo()->m_id->m_id.c_str()); + pos += azsnprintf(pos, BUFFER_SIZE - (pos - buffer), "%s\n", (*itr)->GetAssetPrimaryInfo()->m_id->m_id.c_str()); if (pos >= buffer + BUFFER_SIZE) { diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h index e5be75c7d3..00b82d09ef 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypes.h @@ -79,9 +79,9 @@ namespace AZ AssetTrackingString m_id; }; - // Master information about an asset. + // Primary information about an asset. // Currently just contains the ID of the asset, but in the future may carry additional information about that asset (such as where in code it was initialized). - struct AssetMasterInfo + struct AssetPrimaryInfo { const AssetTrackingId* m_id; }; @@ -90,8 +90,8 @@ namespace AZ class AssetTreeNodeBase { public: - virtual const AssetMasterInfo* GetAssetMasterInfo() const = 0; - virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) = 0; + virtual const AssetPrimaryInfo* GetAssetPrimaryInfo() const = 0; + virtual AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) = 0; }; // Base class for an asset tree. Implemented by the template AssetTree<>. diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h index 91f0a0ef21..711c0cf4eb 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTrackingTypesImpl.h @@ -29,18 +29,18 @@ namespace AZ class AssetTreeNode : public AssetTreeNodeBase { public: - AssetTreeNode(const AssetMasterInfo* masterInfo = nullptr, AssetTreeNode* parent = nullptr) : - m_masterInfo(masterInfo), + AssetTreeNode(const AssetPrimaryInfo* primaryInfo = nullptr, AssetTreeNode* parent = nullptr) : + m_primaryinfo(primaryInfo), m_parent(parent) { } - const AssetMasterInfo* GetAssetMasterInfo() const override + const AssetPrimaryInfo* GetAssetPrimaryInfo() const override { - return m_masterInfo; + return m_primaryinfo; } - AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetMasterInfo* info) override + AssetTreeNodeBase* FindOrAddChild(const AssetTrackingId& id, const AssetPrimaryInfo* info) override { AssetTreeNodeBase* result = nullptr; auto childItr = m_children.find(id); @@ -61,7 +61,7 @@ namespace AZ using AssetMap = AssetTrackingMap; - const AssetMasterInfo* m_masterInfo; + const AssetPrimaryInfo* m_primaryinfo; AssetTreeNode* m_parent; AssetMap m_children; AssetDataT m_data; diff --git a/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp b/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp index a4a152a4f6..92d02a2706 100644 --- a/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp +++ b/Code/Framework/AzCore/Tests/Debug/AssetTracking.cpp @@ -105,7 +105,7 @@ namespace UnitTest EXPECT_EQ(&rootAsset, &m_env->m_tree.GetRoot()); ASSERT_NE(itr, rootAsset.m_children.end()); - EXPECT_EQ(itr->second.m_masterInfo->m_id->m_id, "TestScopedAllocation.1"); + EXPECT_EQ(itr->second.m_primaryinfo->m_id->m_id, "TestScopedAllocation.1"); EXPECT_EQ(&itr->second, m_env->m_table.FindAllocation(TEST_POINTER)); diff --git a/Code/Sandbox/Editor/CryEditDoc.h b/Code/Sandbox/Editor/CryEditDoc.h index 9f954f31d8..481e9fa046 100644 --- a/Code/Sandbox/Editor/CryEditDoc.h +++ b/Code/Sandbox/Editor/CryEditDoc.h @@ -216,7 +216,6 @@ protected: void OnSliceInstantiationFailed(const AZ::Data::AssetId& sliceAssetId, const AzFramework::SliceInstantiationTicket& /*ticket*/) override; ////////////////////////////////////////////////////////////////////////// - QString m_strMasterCDFolder; bool m_bLoadFailed; QColor m_waterColor; XmlNodeRef m_fogTemplate; diff --git a/Code/Sandbox/Editor/Export/ExportManager.cpp b/Code/Sandbox/Editor/Export/ExportManager.cpp index bf5c3aa469..b41872595a 100644 --- a/Code/Sandbox/Editor/Export/ExportManager.cpp +++ b/Code/Sandbox/Editor/Export/ExportManager.cpp @@ -65,7 +65,7 @@ namespace const float kTangentDelta = 0.01f; const float kAspectRatio = 1.777778f; const int kReserveCount = 7; // x,y,z,rot_x,rot_y,rot_z,fov - const QString kMasterCameraName = "MasterCamera"; + const QString kPrimaryCameraName = "PrimaryCamera"; } // namespace @@ -169,10 +169,10 @@ CExportManager::CExportManager() , m_numberOfExportFrames(0) , m_pivotEntityObject(0) , m_bBakedKeysSequenceExport(true) - , m_animTimeExportMasterSequenceCurrentTime(0.0f) + , m_animTimeExportPrimarySequenceCurrentTime(0.0f) , m_animKeyTimeExport(true) , m_soundKeyTimeExport(true) - , m_bExportOnlyMasterCamera(false) + , m_bExportOnlyPrimaryCamera(false) { RegisterExporter(new COBJExporter()); RegisterExporter(new COCMExporter()); @@ -773,14 +773,14 @@ bool CExportManager::ShowFBXExportDialog() return false; } - SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyMasterCamera(), fpsDialog.GetFPS()); + SetFBXExportSettings(fpsDialog.GetExportCoordsLocalToTheSelectedObject(), fpsDialog.GetExportOnlyPrimaryCamera(), fpsDialog.GetFPS()); return true; } bool CExportManager::ProcessObjectsForExport() { - Export::CObject* pObj = new Export::CObject(kMasterCameraName.toUtf8().data()); + Export::CObject* pObj = new Export::CObject(kPrimaryCameraName.toUtf8().data()); pObj->entityType = Export::eCamera; m_data.m_objects.push_back(pObj); @@ -808,13 +808,13 @@ bool CExportManager::ProcessObjectsForExport() Export::CObject* pObj2 = m_data.m_objects[objectID]; CBaseObject* pObject = 0; - if (QString::compare(pObj2->name, kMasterCameraName) == 0) + if (QString::compare(pObj2->name, kPrimaryCameraName) == 0) { pObject = GetIEditor()->GetObjectManager()->FindObject(GetIEditor()->GetViewManager()->GetCameraObjectId()); } else { - if (m_bExportOnlyMasterCamera && pObj2->entityType != Export::eCameraTarget) + if (m_bExportOnlyPrimaryCamera && pObj2->entityType != Export::eCameraTarget) { continue; } @@ -952,7 +952,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode* if (numAllTracks > 0) { XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName()).toUtf8().data()); - writeNode->setAttr("time", m_animTimeExportMasterSequenceCurrentTime); + writeNode->setAttr("time", m_animTimeExportPrimarySequenceCurrentTime); for (unsigned int trackID = 0; trackID < numAllTracks; ++trackID) { @@ -1020,7 +1020,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode* XmlNodeRef keyNode = subNode->createNode(keyContentName.toUtf8().data()); - float keyGlobalTime = m_animTimeExportMasterSequenceCurrentTime + keyTime; + float keyGlobalTime = m_animTimeExportPrimarySequenceCurrentTime + keyTime; keyNode->setAttr("keyTime", keyGlobalTime); if (keyStartTime > 0) @@ -1123,13 +1123,13 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo const QString sequenceName = pSubSequence->GetName(); XmlNodeRef subSeqNode2 = seqNode->createNode(sequenceName.toUtf8().data()); - if (sequenceName == m_animTimeExportMasterSequenceName) + if (sequenceName == m_animTimeExportPrimarySequenceName) { - m_animTimeExportMasterSequenceCurrentTime = sequenceKey.time; + m_animTimeExportPrimarySequenceCurrentTime = sequenceKey.time; } else { - m_animTimeExportMasterSequenceCurrentTime += sequenceKey.time; + m_animTimeExportPrimarySequenceCurrentTime += sequenceKey.time; } AddObjectsFromSequence(pSubSequence, subSeqNode2); @@ -1336,7 +1336,7 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con { m_numberOfExportFrames = pSequence->GetTimeRange().end * m_FBXBakedExportFPS; - if (!m_bExportOnlyMasterCamera) + if (!m_bExportOnlyPrimaryCamera) { AddObjectsFromSequence(pSequence); } @@ -1365,10 +1365,10 @@ bool CExportManager::Export(const char* defaultName, const char* defaultExt, con return returnRes; } -void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps) +void CExportManager::SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps) { m_bExportLocalCoords = bLocalCoordsToSelectedObject; - m_bExportOnlyMasterCamera = bExportOnlyMasterCamera; + m_bExportOnlyPrimaryCamera = bExportOnlyPrimaryCamera; m_FBXBakedExportFPS = fps; } @@ -1439,10 +1439,10 @@ void CExportManager::SaveNodeKeysTimeToXML() if (dlg.exec()) { m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName()); - m_animTimeExportMasterSequenceName = pSequence->GetName(); + m_animTimeExportPrimarySequenceName = pSequence->GetName(); m_data.Clear(); - m_animTimeExportMasterSequenceCurrentTime = 0.0; + m_animTimeExportPrimarySequenceCurrentTime = 0.0; AddObjectsFromSequence(pSequence, m_animTimeNode); diff --git a/Code/Sandbox/Editor/Export/ExportManager.h b/Code/Sandbox/Editor/Export/ExportManager.h index d8edf1d3b1..8904ef08ed 100644 --- a/Code/Sandbox/Editor/Export/ExportManager.h +++ b/Code/Sandbox/Editor/Export/ExportManager.h @@ -171,7 +171,7 @@ private: bool AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNodeRef seqNode = 0); bool IsDuplicateObjectBeingAdded(const QString& newObject); - void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyMasterCamera, const float fps); + void SetFBXExportSettings(bool bLocalCoordsToSelectedObject, bool bExportOnlyPrimaryCamera, const float fps); bool ProcessObjectsForExport(); bool ShowFBXExportDialog(); @@ -193,13 +193,13 @@ private: float m_FBXBakedExportFPS; bool m_bExportLocalCoords; - bool m_bExportOnlyMasterCamera; + bool m_bExportOnlyPrimaryCamera; int m_numberOfExportFrames; CEntityObject* m_pivotEntityObject; bool m_bBakedKeysSequenceExport; - QString m_animTimeExportMasterSequenceName; - float m_animTimeExportMasterSequenceCurrentTime; + QString m_animTimeExportPrimarySequenceName; + float m_animTimeExportPrimarySequenceCurrentTime; XmlNodeRef m_animTimeNode; bool m_animKeyTimeExport; diff --git a/Code/Sandbox/Editor/FBXExporterDialog.cpp b/Code/Sandbox/Editor/FBXExporterDialog.cpp index 7638680b10..677e6dcfe7 100644 --- a/Code/Sandbox/Editor/FBXExporterDialog.cpp +++ b/Code/Sandbox/Editor/FBXExporterDialog.cpp @@ -55,9 +55,9 @@ bool CFBXExporterDialog::GetExportCoordsLocalToTheSelectedObject() const return m_ui->m_exportLocalCoordsCheckbox->isChecked(); } -bool CFBXExporterDialog::GetExportOnlyMasterCamera() const +bool CFBXExporterDialog::GetExportOnlyPrimaryCamera() const { - return m_ui->m_exportOnlyMasterCameraCheckBox->isChecked(); + return m_ui->m_exportOnlyPrimaryCameraCheckBox->isChecked(); } void CFBXExporterDialog::SetExportLocalCoordsCheckBoxEnable(bool checked) @@ -100,7 +100,7 @@ int CFBXExporterDialog::exec() if (m_bDisplayOnlyFPSSetting) { m_ui->m_exportLocalCoordsCheckbox->setEnabled(false); - m_ui->m_exportOnlyMasterCameraCheckBox->setEnabled(false); + m_ui->m_exportOnlyPrimaryCameraCheckBox->setEnabled(false); } m_ui->m_fpsCombo->addItem("24"); diff --git a/Code/Sandbox/Editor/FBXExporterDialog.h b/Code/Sandbox/Editor/FBXExporterDialog.h index 9978cb4aca..ffa249ca5b 100644 --- a/Code/Sandbox/Editor/FBXExporterDialog.h +++ b/Code/Sandbox/Editor/FBXExporterDialog.h @@ -36,7 +36,7 @@ public: float GetFPS() const; bool GetExportCoordsLocalToTheSelectedObject() const; - bool GetExportOnlyMasterCamera() const; + bool GetExportOnlyPrimaryCamera() const; void SetExportLocalCoordsCheckBoxEnable(bool checked); int exec() override; @@ -44,7 +44,7 @@ public: protected: void OnFPSChange(); void SetExportLocalToTheSelectedObjectCheckBox(); - void SetExportOnlyMasterCameraCheckBox(); + void SetExportOnlyPrimaryCameraCheckBox(); void accept() override; diff --git a/Code/Sandbox/Editor/FBXExporterDialog.ui b/Code/Sandbox/Editor/FBXExporterDialog.ui index 8c02ce1ca9..6b7b93c342 100644 --- a/Code/Sandbox/Editor/FBXExporterDialog.ui +++ b/Code/Sandbox/Editor/FBXExporterDialog.ui @@ -49,9 +49,9 @@ - + - Export Only Master Camera + Export Only Primary Camera diff --git a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h index a309a1a5f5..7372de523f 100644 --- a/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h +++ b/Code/Sandbox/Editor/Lib/Tests/IEditorMock.h @@ -20,7 +20,7 @@ class CEditorMock : public IEditor { public: - // GMock does not work with a variadic function (https://github.com/google/googlemock/blob/master/googlemock/docs/FrequentlyAskedQuestions.md) + // GMock does not work with a variadic function void ExecuteCommand(const char* sCommand, ...) override { va_list args; diff --git a/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp b/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp index f364167173..261b7be33f 100644 --- a/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Export/MtlMaterialExporter.cpp @@ -86,7 +86,7 @@ namespace AZ if (sourceFileExists && !updateMaterial) { - // Don't write to the cache if there's a source material as this will be the master material. + // Don't write to the cache if there's a source material as this will be the primary material. continue; } diff --git a/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h b/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h index 4f2406206f..ce01889a63 100644 --- a/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h +++ b/Code/Tools/SceneAPI/SceneUI/SceneWidgets/SceneGraphWidget.h @@ -84,7 +84,7 @@ namespace AZ NoneCheckable, // No nodes can be checked. OnlyFilterTypesCheckable // Only nodes in the filter type list can be checked. }; - // Updates the tree to include/exclude check boxes and the master selection. Call "BuildTree()" to rebuild the tree. + // Updates the tree to include/exclude check boxes and the primary selection. Call "BuildTree()" to rebuild the tree. virtual void MakeCheckable(CheckableOption option); // Add a type to filter for. Filter types are used to determine if a check box is added and/or to be shown if // the type is an end point. See "IncludeEndPoints" and "MakeCheckable" for more details. diff --git a/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp b/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp index 1083ec876a..ac3ab0dd04 100644 --- a/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp +++ b/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp @@ -308,7 +308,7 @@ namespace AssetMemoryAnalyzer AZStd::function recurse; recurse = [&recurse](AssetInfo* outAsset, AssetTreeNode* inAsset, int depth) { - outAsset->m_id = inAsset->m_masterInfo ? inAsset->m_masterInfo->m_id->m_id.c_str() : nullptr; + outAsset->m_id = inAsset->m_primaryinfo ? inAsset->m_primaryinfo->m_id->m_id.c_str() : nullptr; // For every code point in this asset node, record its allocations for (auto& codePointInfo : inAsset->m_data.m_codePointsToAllocations) From 957d1360da152ad3012209241cf40f6cdde56cd7 Mon Sep 17 00:00:00 2001 From: sharmajs-amzn <82233357+sharmajs-amzn@users.noreply.github.com> Date: Thu, 22 Apr 2021 12:54:36 -0700 Subject: [PATCH 27/27] Custom UV Stream Names in assimp (#210) (#243) * Custom UV Stream Names in assimp https://jira.agscollab.com/browse/LYN-2506 --- .../FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp index 6d9189c1de..65e7c00d74 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpUvMapImporter.cpp @@ -32,7 +32,7 @@ namespace AZ { namespace FbxSceneBuilder { - const char* AssImpUvMapImporter::m_defaultNodeName = "UVMap"; + const char* AssImpUvMapImporter::m_defaultNodeName = "UV"; AssImpUvMapImporter::AssImpUvMapImporter() { @@ -44,7 +44,7 @@ namespace AZ SerializeContext* serializeContext = azrtti_cast(context); if (serializeContext) { - serializeContext->Class()->Version(2); // LYN-2576 + serializeContext->Class()->Version(3); // LYN-2506 } } @@ -84,7 +84,13 @@ namespace AZ AZStd::shared_ptr uvMap = AZStd::make_shared(); uvMap->ReserveContainerSpace(vertexCount); + AZStd::string name(AZStd::string::format("%s%d", m_defaultNodeName, texCoordIndex)); + if (mesh->mTextureCoordsNames[texCoordIndex].length) + { + name = mesh->mTextureCoordsNames[texCoordIndex].C_Str(); + } + uvMap->SetCustomName(name.c_str()); for (int v = 0; v < mesh->mNumVertices; ++v)