Fix: EEVEE: Undefined behavior in view_z_to_volume_z

The remaped depth can become negative in the range between
the camera near plane and the volume near plane.
`log2` is not defined for `x <= 0`.

This would cause artifact on Mac where volumes would poke
through objects.
This commit is contained in:
Clément Foucault 2026-05-27 17:44:47 +02:00
parent 9ec4e6bf28
commit d0ae9292f9

View file

@ -51,7 +51,7 @@ float view_z_to_volume_z(float depth, float near, float far, float distribution)
{
if (drw_view_is_perspective()) {
/* Exponential distribution. */
return distribution * log2(depth * far + near);
return distribution * log2(max(1e-8, depth * far + near));
}
else {
/* Linear distribution. */