From 0bae6d062fe65390d371d059e843ed9ec47caa99 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 4 Jan 2022 14:58:49 +0100 Subject: [PATCH] Remove pows and sqrts from attenuation computation + readjust attenuation parameter bounds (https://github.com/o3de/o3de/pull/6428#discussion_r776071926, https://github.com/o3de/o3de/pull/6428#discussion_r776066792) Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/EnhancedPBR.materialtype | 4 ++-- .../Feature/Common/Assets/Materials/Types/Skin.materialtype | 4 ++-- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index 77caf42834..f1d8952bb2 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1254,9 +1254,9 @@ "displayName": " Distance Attenuation", "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", "type": "float", - "defaultValue": 4.0, + "defaultValue": 0.5, "min": 0.0, - "softMax": 10.0, + "softMax": 4.0, "connection": { "type": "ShaderInput", "name": "m_distanceAttenuation" diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index d42f62d0ac..59d8be914e 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -668,9 +668,9 @@ "displayName": " Distance Attenuation", "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", "type": "float", - "defaultValue": 4.0, + "defaultValue": 0.5, "min": 0.0, - "softMax": 10.0, + "softMax": 4.0, "connection": { "type": "ShaderInput", "name": "m_distanceAttenuation" diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 87dd42fd28..47ec914815 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -90,7 +90,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // result = T(s) * lightIntensity * surface.albedo * E * transmissionParams.w; // Distance attenuation applied to hide artifacts due to low-res projected areas onto shadowmaps (might need some work in the future) - result *= 1.0 / pow(max(1.0, sqrt(attenuationDistance)), lightingData.distanceAttenuation + 1.0); + result /= max(1.0, attenuationDistance * attenuationDistance * lightingData.distanceAttenuation); } break; }