From 60ec8c3cfb5d9a1110a96977bdc3318739b3f1e0 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 21:17:17 +0100 Subject: [PATCH] Alias shadowCoords memory instead of using local variable (https://github.com/o3de/o3de/pull/6428#discussion_r774255818 cont'd) Signed-off-by: Santi Paprika --- .../Features/PBR/Lights/DirectionalLight.azsli | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index e6de9e57c3..507b226682 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -31,23 +31,21 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) surface.vertexNormal, debugInfo); - // Fetch shadow coords for shrinked world position (used in thin transmission materials) - float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; - DirectionalLightShadow::GetShadowCoords( - shadowIndex, - surface.position - lightingData.shrinkFactor * surface.vertexNormal, - surface.normal, - shrinkedShadowCoords); - if (o_transmission_mode == TransmissionMode::ThickObject) { transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); } else if (o_transmission_mode == TransmissionMode::ThinObject) { - // Use shrinked positions for thin object transmission to ensure they fall onto the object when querying + // Fetch and use shrinked positions for thin object transmission to ensure they fall onto the object when querying + DirectionalLightShadow::GetShadowCoords( + shadowIndex, + surface.position - lightingData.shrinkFactor * surface.vertexNormal, + surface.normal, + lightingData.shadowCoords); + // the depth from the shadow map - transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, shrinkedShadowCoords); + transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); } }