Eevee: Volumetrics: Avoid light leaking if last step is going trough geometry.
authorClément Foucault <foucault.clem@gmail.com>
Wed, 5 Jul 2017 22:27:42 +0000 (00:27 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Wed, 5 Jul 2017 22:28:13 +0000 (00:28 +0200)
source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl

index 56fa126e490b9e4dff6b0d52f762fbb75a51c3ef..a99769c7fec853f5c077f37b30e54bbdc13437bc 100644 (file)
@@ -181,7 +181,7 @@ void main()
        // float rand = (1.0 / 16.0) * float(((int(gl_FragCoord.x + gl_FragCoord.y) & 0x3) << 2) + (int(gl_FragCoord.x) & 0x3));
        float dist = volume_start;
        for (float i = 0.5; i < VOLUMETRIC_INTEGRATION_MAX_STEP && i < (volume_integration_steps - 0.1); ++i) {
-               float new_dist = find_next_step(rand, i);
+               float new_dist = max(max_z, find_next_step(rand, i));
                float step = dist - new_dist; /* Marching step */
                dist = new_dist;
 
@@ -227,7 +227,7 @@ void main()
                /* Evaluate transmittance to view independantely */
                transmittance *= Tr;
 
-               if (dist < max_z)
+               if (dist <= max_z)
                        break;
        }