From 6f96369581d3dcb4d672007a28afb0f5d3c95398 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Mon, 17 Jun 2024 16:04:31 -0400 Subject: [PATCH] Refactor attenuation math to avoid -log(0.0) --- source/Renderer/shaders/punctual.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/Renderer/shaders/punctual.glsl b/source/Renderer/shaders/punctual.glsl index 1e7af287..254cbbf4 100644 --- a/source/Renderer/shaders/punctual.glsl +++ b/source/Renderer/shaders/punctual.glsl @@ -119,8 +119,7 @@ vec3 applyVolumeAttenuation(vec3 radiance, float transmissionDistance, vec3 atte else { // Compute light attenuation using Beer's law. - vec3 attenuationCoefficient = -log(attenuationColor) / attenuationDistance; - vec3 transmittance = exp(-attenuationCoefficient * transmissionDistance); // Beer's law + vec3 transmittance = pow(attenuationColor, vec3(transmissionDistance / attenuationDistance)); return transmittance * radiance; } }