diff options
author | Jason Fielder <jason_apple> | 2022-04-14 12:47:52 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-14 12:49:18 +0300 |
commit | b0dc3aff2c73f2a1b65406dcb7fe73c95b9485ed (patch) | |
tree | 29642f7e85e2f5189549c1710854c421463a2e0d /source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl | |
parent | d62f443f2d0b464131f77f770f9aa19d81164f0c (diff) |
Metal: GLSL shader compatibility 3rd pass
Undefined behaviour for divergent control-flow fixes, replacement for partial vector references, and resolution of a number of calculation precision issues occuring on macOS.
Authored by Apple: Michael Parkin-White
Ref: T96261
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D14437
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl index 11f57c0a82e..527bbd18896 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_integration_frag.glsl @@ -70,7 +70,11 @@ void main() vec3 Tr = exp(-s_extinction * s_len); /* integrate along the current step segment */ - Lscat = (Lscat - Lscat * Tr) / max(vec3(1e-8), s_extinction); + /* Note: Original calculation carries precision issues when compiling for AMD GPUs + * and running Metal. This version of the equation retains precision well for all + * macOS HW configurations. */ + Lscat = (Lscat * (1.0f - Tr)) / max(vec3(1e-8), s_extinction); + /* accumulate and also take into account the transmittance from previous steps */ finalScattering += finalTransmittance * Lscat; |