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
This commit is contained in:
Clément Foucault 2019-09-07 00:44:07 +02:00
parent 963a266faf
commit ed779333bb
Notes: blender-bot 2023-02-14 01:14:36 +01:00
Referenced by issue #71722, Alembic speed decrease for deforming geometry
Referenced by issue #68594, Eevee: Soft shadows causing flickering in animation and temporal AA in scenes
1 changed files with 18 additions and 0 deletions

View File

@ -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);