[Bf-blender-cvs] [ed779333bb8] master: EEVEE: Shadows: Fix correlation issue between Shadows and Anti-Aliasing

Clément Foucault noreply at git.blender.org
Sat Sep 7 00:44:52 CEST 2019


Commit: ed779333bb82a483c3f7833b959610c08f0bacb7
Author: Clément Foucault
Date:   Sat Sep 7 00:44:07 2019 +0200
Branches: master
https://developer.blender.org/rBed779333bb82a483c3f7833b959610c08f0bacb7

EEVEE: Shadows: Fix correlation issue between Shadows and Anti-Aliasing

To fix this, we just scramble the halton sequence by multiplying by a large
prime number.

It seems to work fine in practice.

We also tried Sobol sequence but it has a less uniform pattern for low
number of sample.

Fix T68594 Eevee: Soft shadows causing flickering in animation and temporal AA in scenes

===================================================================

M	source/blender/draw/engines/eevee/eevee_sampling.c

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_sampling.c b/source/blender/draw/engines/eevee/eevee_sampling.c
index 9d91e000562..39a0358cb6c 100644
--- a/source/blender/draw/engines/eevee/eevee_sampling.c
+++ b/source/blender/draw/engines/eevee/eevee_sampling.c
@@ -38,6 +38,11 @@ void EEVEE_sample_ball(int sample_ofs, float radius, float rsample[3])
 
   BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point);
 
+  /* Decorelate AA and shadow samples. (see T68594) */
+  ht_point[0] = fmod(ht_point[0] * 1151.0, 1.0);
+  ht_point[1] = fmod(ht_point[1] * 1069.0, 1.0);
+  ht_point[2] = fmod(ht_point[2] * 1151.0, 1.0);
+
   float omega = ht_point[1] * 2.0f * M_PI;
 
   rsample[2] = ht_point[0] * 2.0f - 1.0f; /* cos theta */
@@ -64,6 +69,10 @@ void EEVEE_sample_rectangle(int sample_ofs,
 
   BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
 
+  /* Decorelate AA and shadow samples. (see T68594) */
+  ht_point[0] = fmod(ht_point[0] * 1151.0, 1.0);
+  ht_point[1] = fmod(ht_point[1] * 1069.0, 1.0);
+
   /* Change ditribution center to be 0,0 */
   ht_point[0] = (ht_point[0] > 0.5f) ? ht_point[0] - 1.0f : ht_point[0];
   ht_point[1] = (ht_point[1] > 0.5f) ? ht_point[1] - 1.0f : ht_point[1];
@@ -86,6 +95,10 @@ void EEVEE_sample_ellipse(int sample_ofs,
 
   BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point);
 
+  /* Decorelate AA and shadow samples. (see T68594) */
+  ht_point[0] = fmod(ht_point[0] * 1151.0, 1.0);
+  ht_point[1] = fmod(ht_point[1] * 1069.0, 1.0);
+
   /* Uniform disc sampling. */
   float omega = ht_point[1] * 2.0f * M_PI;
   float r = sqrtf(ht_point[0]);
@@ -105,6 +118,11 @@ void EEVEE_random_rotation_m4(int sample_ofs, float scale, float r_mat[4][4])
 
   BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point);
 
+  /* Decorelate AA and shadow samples. (see T68594) */
+  ht_point[0] = fmod(ht_point[0] * 1151.0, 1.0);
+  ht_point[1] = fmod(ht_point[1] * 1069.0, 1.0);
+  ht_point[2] = fmod(ht_point[2] * 1151.0, 1.0);
+
   rotate_m4(r_mat, 'X', ht_point[0] * scale);
   rotate_m4(r_mat, 'Y', ht_point[1] * scale);
   rotate_m4(r_mat, 'Z', ht_point[2] * scale);



More information about the Bf-blender-cvs mailing list