Converted ReflectionProbe Srg indices to ShaderInputNameIndex

Signed-off-by: dmcdiar <dmcdiar@amazon.com>
This commit is contained in:
dmcdiar
2021-09-21 14:40:26 -07:00
parent db5fd91ac9
commit e5cc029c76
2 changed files with 7 additions and 54 deletions
@@ -55,13 +55,13 @@ namespace AZ
RHI::DrawListTag m_renderOuterDrawListTag;
RHI::DrawListTag m_renderInnerDrawListTag;
RHI::ShaderInputConstantIndex m_modelToWorldStencilConstantIndex;
RHI::ShaderInputConstantIndex m_modelToWorldRenderConstantIndex;
RHI::ShaderInputConstantIndex m_modelToWorldInverseRenderConstantIndex;
RHI::ShaderInputConstantIndex m_outerObbHalfLengthsRenderConstantIndex;
RHI::ShaderInputConstantIndex m_innerObbHalfLengthsRenderConstantIndex;
RHI::ShaderInputConstantIndex m_useParallaxCorrectionRenderConstantIndex;
RHI::ShaderInputImageIndex m_reflectionCubeMapRenderImageIndex;
RHI::ShaderInputNameIndex m_modelToWorldStencilConstantIndex = "m_modelToWorld";
RHI::ShaderInputNameIndex m_modelToWorldRenderConstantIndex = "m_modelToWorld";
RHI::ShaderInputNameIndex m_modelToWorldInverseRenderConstantIndex = "m_modelToWorldInverse";
RHI::ShaderInputNameIndex m_outerObbHalfLengthsRenderConstantIndex = "m_outerObbHalfLengths";
RHI::ShaderInputNameIndex m_innerObbHalfLengthsRenderConstantIndex = "m_innerObbHalfLengths";
RHI::ShaderInputNameIndex m_useParallaxCorrectionRenderConstantIndex = "m_useParallaxCorrection";
RHI::ShaderInputNameIndex m_reflectionCubeMapRenderImageIndex = "m_reflectionCubeMap";
};
// ReflectionProbe manages all aspects of a single probe, including rendering, visualization, and cubemap generation
@@ -77,53 +77,6 @@ namespace AZ
m_reflectionRenderData.m_renderInnerSrgLayout,
m_reflectionRenderData.m_renderInnerDrawListTag);
// create ShaderResourceGroups here so we can get the layout and cache the indices
// Note: the SRGs are not needed beyond this method since each probe creates its own SRGs, we are just interested in the indices
// cache probe stencil shader indices
Data::Instance<RPI::ShaderResourceGroup> stencilSrg = RPI::ShaderResourceGroup::Create(
m_reflectionRenderData.m_stencilShader->GetAsset(),
m_reflectionRenderData.m_stencilShader->GetSupervariantIndex(),
m_reflectionRenderData.m_stencilSrgLayout->GetName());
AZ_Error("ReflectionProbeFeatureProcessor", stencilSrg.get(), "Failed to create stencil back face shader resource group");
const RHI::ShaderResourceGroupLayout* stencilSrgLayout = stencilSrg->GetLayout();
Name modelToWorldConstantName = Name("m_modelToWorld");
m_reflectionRenderData.m_modelToWorldStencilConstantIndex = stencilSrgLayout->FindShaderInputConstantIndex(modelToWorldConstantName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_modelToWorldStencilConstantIndex.IsValid(), "Failed to find stencil shader input constant [%s]", modelToWorldConstantName.GetCStr());
// cache probe render shader indices
// Note: the outer and inner render shaders use the same Srg
Data::Instance<RPI::ShaderResourceGroup> renderReflectionSrg = RPI::ShaderResourceGroup::Create(
m_reflectionRenderData.m_renderOuterShader->GetAsset(),
m_reflectionRenderData.m_renderOuterShader->GetSupervariantIndex(),
m_reflectionRenderData.m_renderOuterSrgLayout->GetName());
AZ_Error("ReflectionProbeFeatureProcessor", renderReflectionSrg.get(), "Failed to create render reflection shader resource group");
const RHI::ShaderResourceGroupLayout* renderReflectionSrgLayout = renderReflectionSrg->GetLayout();
m_reflectionRenderData.m_modelToWorldRenderConstantIndex = renderReflectionSrgLayout->FindShaderInputConstantIndex(modelToWorldConstantName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_modelToWorldRenderConstantIndex.IsValid(), "Failed to find render shader input constant [%s]", modelToWorldConstantName.GetCStr());
Name modelToWorldInverseConstantName = Name("m_modelToWorldInverse");
m_reflectionRenderData.m_modelToWorldInverseRenderConstantIndex = renderReflectionSrgLayout->FindShaderInputConstantIndex(modelToWorldInverseConstantName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_modelToWorldRenderConstantIndex.IsValid(), "Failed to find render shader input constant [%s]", modelToWorldInverseConstantName.GetCStr());
Name outerObbHalfLengthsConstantName = Name("m_outerObbHalfLengths");
m_reflectionRenderData.m_outerObbHalfLengthsRenderConstantIndex = renderReflectionSrgLayout->FindShaderInputConstantIndex(outerObbHalfLengthsConstantName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_outerObbHalfLengthsRenderConstantIndex.IsValid(), "Failed to find render shader input constant [%s]", outerObbHalfLengthsConstantName.GetCStr());
Name innerObbHalfLengthsConstantName = Name("m_innerObbHalfLengths");
m_reflectionRenderData.m_innerObbHalfLengthsRenderConstantIndex = renderReflectionSrgLayout->FindShaderInputConstantIndex(innerObbHalfLengthsConstantName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_innerObbHalfLengthsRenderConstantIndex.IsValid(), "Failed to find render shader input constant [%s]", innerObbHalfLengthsConstantName.GetCStr());
Name useParallaxCorrectionConstantName = Name("m_useParallaxCorrection");
m_reflectionRenderData.m_useParallaxCorrectionRenderConstantIndex = renderReflectionSrgLayout->FindShaderInputConstantIndex(useParallaxCorrectionConstantName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_useParallaxCorrectionRenderConstantIndex.IsValid(), "Failed to find render shader input constant [%s]", useParallaxCorrectionConstantName.GetCStr());
Name reflectionCubeMapImageName = Name("m_reflectionCubeMap");
m_reflectionRenderData.m_reflectionCubeMapRenderImageIndex = renderReflectionSrgLayout->FindShaderInputImageIndex(reflectionCubeMapImageName);
AZ_Error("ReflectionProbeFeatureProcessor", m_reflectionRenderData.m_reflectionCubeMapRenderImageIndex.IsValid(), "Failed to find render shader input image [%s]", reflectionCubeMapImageName.GetCStr());
EnableSceneNotification();
}