Integrating github/staging through commit ab87ed9

This commit is contained in:
alexpete
2021-04-09 11:27:37 -07:00
parent ae62a97894
commit 1044dc3da1
1582 changed files with 29374 additions and 519051 deletions
@@ -63,8 +63,7 @@ namespace AZ
}
else
{
const Name& shaderOptionName = layout->GetShaderOption(optionIndex).GetName();
AZ_Error("MaterialFunctor", false, "Shader option '%s' is not owned by this material.", shaderOptionName.GetCStr());
AZ_Error("MaterialFunctor", false, "Shader option '%s' is not owned by this material.", layout->GetShaderOption(optionIndex).GetName().GetCStr());
}
return false;
@@ -395,11 +394,13 @@ namespace AZ
template const Color& MaterialFunctor::EditorContext::GetMaterialPropertyValue<Color> (const MaterialPropertyIndex& index) const;
template const Data::Instance<Image>& MaterialFunctor::EditorContext::GetMaterialPropertyValue<Data::Instance<Image>> (const MaterialPropertyIndex& index) const;
void CheckPropertyAccess(const MaterialPropertyIndex& index, const MaterialPropertyFlags& materialPropertyDependencies, const MaterialPropertiesLayout& materialPropertiesLayout)
void CheckPropertyAccess(const MaterialPropertyIndex& index, const MaterialPropertyFlags& materialPropertyDependencies, [[maybe_unused]] const MaterialPropertiesLayout& materialPropertiesLayout)
{
if (!materialPropertyDependencies.test(index.GetIndex()))
{
#if defined(AZ_ENABLE_TRACING)
const MaterialPropertyDescriptor* propertyDescriptor = materialPropertiesLayout.GetPropertyDescriptor(index);
#endif
AZ_Error("MaterialFunctor", false, "Material functor accessing an unregistered material property '%s'.",
propertyDescriptor ? propertyDescriptor->GetName().GetCStr() : "<unknown>");
}
@@ -75,7 +75,7 @@ namespace AZ
m_status = Data::AssetData::AssetStatus::Ready;
}
bool ModelAsset::LocalRayIntersectionAgainstModel(const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distance) const
bool ModelAsset::LocalRayIntersectionAgainstModel(const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distance, AZ::Vector3& normal) const
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender);
@@ -97,11 +97,11 @@ namespace AZ
}
else
{
return m_kdTree->RayIntersection(rayStart, dir, distance);
return m_kdTree->RayIntersection(rayStart, dir, distance, normal);
}
}
return BruteForceRayIntersect(rayStart, dir, distance);
return BruteForceRayIntersect(rayStart, dir, distance, normal);
}
void ModelAsset::BuildKdTree() const
@@ -136,7 +136,7 @@ namespace AZ
}
}
bool ModelAsset::BruteForceRayIntersect(const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distance) const
bool ModelAsset::BruteForceRayIntersect(const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distance, AZ::Vector3& normal) const
{
// brute force - check every triangle
if (GetLodAssets().empty() == false)
@@ -147,12 +147,18 @@ namespace AZ
float shortestDistance = std::numeric_limits<float>::max();
bool anyHit = false;
AZ::Vector3 intersectionNormal;
for (const ModelLodAsset::Mesh& mesh : loadAssetPtr->GetMeshes())
{
if (LocalRayIntersectionAgainstMesh(mesh, rayStart, dir, distance))
if (LocalRayIntersectionAgainstMesh(mesh, rayStart, dir, distance, intersectionNormal))
{
anyHit = true;
shortestDistance = AZ::GetMin(distance, shortestDistance);
if (distance < shortestDistance)
{
normal = intersectionNormal;
shortestDistance = distance;
}
}
}
@@ -168,7 +174,7 @@ namespace AZ
return false;
}
bool ModelAsset::LocalRayIntersectionAgainstMesh(const ModelLodAsset::Mesh& mesh, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distance) const
bool ModelAsset::LocalRayIntersectionAgainstMesh(const ModelLodAsset::Mesh& mesh, const AZ::Vector3& rayStart, const AZ::Vector3& dir, float& distance, AZ::Vector3& normal) const
{
const BufferAssetView& indexBufferView = mesh.GetIndexBufferAssetView();
const AZStd::array_view<ModelLodAsset::Mesh::StreamBufferInfo>& streamBufferList = mesh.GetStreamBufferInfoList();
@@ -216,7 +222,7 @@ namespace AZ
const AZ::Vector3 rayEnd = rayStart + dir * distance;
AZ::Vector3 a, b, c;
AZ::Vector3 normal;
AZ::Vector3 intersectionNormal;
float normalizedDistance = 1.f;
const AZ::u32* indexPtr = reinterpret_cast<const AZ::u32*>(indexRawBuffer.data());
@@ -241,9 +247,13 @@ namespace AZ
p = reinterpret_cast<const float*>(&positionRawBuffer[index2 * positionElementSize]);
c.Set(const_cast<float*>(p));
if (AZ::Intersect::IntersectSegmentTriangleCCW(rayStart, rayEnd, a, b, c, normal, normalizedDistance))
if (AZ::Intersect::IntersectSegmentTriangleCCW(rayStart, rayEnd, a, b, c, intersectionNormal, normalizedDistance))
{
closestNormalizedDistance = AZ::GetMin(closestNormalizedDistance, normalizedDistance);
if (normalizedDistance < closestNormalizedDistance)
{
normal = intersectionNormal;
closestNormalizedDistance = normalizedDistance;
}
anyHit = true;
}
}
@@ -221,12 +221,12 @@ namespace AZ
}
}
bool ModelKdTree::RayIntersection(const AZ::Vector3& raySrc, const AZ::Vector3& rayDir, float& distance) const
bool ModelKdTree::RayIntersection(const AZ::Vector3& raySrc, const AZ::Vector3& rayDir, float& distance, AZ::Vector3& normal) const
{
return RayIntersectionRecursively(m_pRootNode.get(), raySrc, rayDir, distance);
return RayIntersectionRecursively(m_pRootNode.get(), raySrc, rayDir, distance, normal);
}
bool ModelKdTree::RayIntersectionRecursively(ModelKdTreeNode* pNode, const AZ::Vector3& raySrc, const AZ::Vector3& rayDir, float& distance) const
bool ModelKdTree::RayIntersectionRecursively(ModelKdTreeNode* pNode, const AZ::Vector3& raySrc, const AZ::Vector3& rayDir, float& distance, AZ::Vector3& normal) const
{
if (!pNode)
{
@@ -252,7 +252,7 @@ namespace AZ
return false;
}
AZ::Vector3 ignoreNormal;
AZ::Vector3 intersectionNormal;
float hitDistanceNormalized;
const float maxDist(FLT_MAX);
float nearestDist = maxDist;
@@ -278,9 +278,15 @@ namespace AZ
const AZ::Vector3 rayEnd = raySrc + rayDir * distance;
if (AZ::Intersect::IntersectSegmentTriangleCCW(raySrc, rayEnd, trianglePoints[0], trianglePoints[1], trianglePoints[2],
ignoreNormal, hitDistanceNormalized) != Intersect::ISECT_RAY_AABB_NONE)
intersectionNormal, hitDistanceNormalized) != Intersect::ISECT_RAY_AABB_NONE)
{
float hitDistance = hitDistanceNormalized * distance;
if (nearestDist > hitDistance)
{
normal = intersectionNormal;
}
nearestDist = AZStd::GetMin(nearestDist, hitDistance);
}
}
@@ -295,8 +301,8 @@ namespace AZ
}
// running both sides to find the closest intersection
const bool bFoundChild0 = RayIntersectionRecursively(pNode->GetChild(0), raySrc, rayDir, distance);
const bool bFoundChild1 = RayIntersectionRecursively(pNode->GetChild(1), raySrc, rayDir, distance);
const bool bFoundChild0 = RayIntersectionRecursively(pNode->GetChild(0), raySrc, rayDir, distance, normal);
const bool bFoundChild1 = RayIntersectionRecursively(pNode->GetChild(1), raySrc, rayDir, distance, normal);
return bFoundChild0 || bFoundChild1;
}
@@ -138,19 +138,6 @@ namespace AZ
return nullptr;
}
AZStd::array_view<uint8_t> ModelLodAsset::Mesh::GetSemanticBuffer(const AZ::Name& semantic) const
{
if (const BufferAssetView* bufferAssetView = GetSemanticBufferAssetView(semantic))
{
if (const BufferAsset* bufferAsset = bufferAssetView->GetBufferAsset().Get())
{
return bufferAsset->GetBuffer();
}
}
return {};
}
void ModelLodAsset::SetReady()
{
m_status = Data::AssetData::AssetStatus::Ready;
@@ -39,6 +39,7 @@ namespace AZ
serializeContext->Class<PrecompiledShaderAssetSourceData>()
->Version(0)
->Field("ShaderAssetFileName", &PrecompiledShaderAssetSourceData::m_shaderAssetFileName)
->Field("PlatformIdentifiers", &PrecompiledShaderAssetSourceData::m_platformIdentifiers)
->Field("ShaderResourceGroupAssets", &PrecompiledShaderAssetSourceData::m_srgAssetFileNames)
->Field("RootShaderVariantAssets", &PrecompiledShaderAssetSourceData::m_rootShaderVariantAssets)
;
@@ -264,7 +264,7 @@ namespace AZ
if (!foundVariantAsset)
{
ReportError("Failed to find variant asset for API [%d]", perAPIShaderData.m_APIType);
ReportWarning("Failed to find variant asset for API [%d]", perAPIShaderData.m_APIType);
}
m_asset->m_perAPIShaderData.push_back(perAPIShaderData);
@@ -80,6 +80,22 @@ namespace AZ
}
}
void ShaderResourceGroupAssetCreator::AddShaderInput(const RHI::ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray)
{
if (ValidateIsReady())
{
m_shaderResourceGroupLayout->AddShaderInput(shaderInputBufferUnboundedArray);
}
}
void ShaderResourceGroupAssetCreator::AddShaderInput(const RHI::ShaderInputImageUnboundedArrayDescriptor& shaderInputImageUnboundedArray)
{
if (ValidateIsReady())
{
m_shaderResourceGroupLayout->AddShaderInput(shaderInputImageUnboundedArray);
}
}
void ShaderResourceGroupAssetCreator::AddShaderInput(const RHI::ShaderInputSamplerDescriptor& shaderInputSampler)
{
if (ValidateIsReady())
@@ -150,4 +166,4 @@ namespace AZ
return true;
}
} // namespace RPI
} // namespace AZ
} // namespace AZ