diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-09-07 01:44:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-09-07 01:44:20 +0300 |
commit | ed779333bb82a483c3f7833b959610c08f0bacb7 (patch) | |
tree | 075e6dc8a1564959295f82340e1c33b0da46b677 /source | |
parent | 963a266faf1739ae3a89bc9f9b35050f9e0f436e (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_sampling.c | 18 |
1 files changed, 18 insertions, 0 deletions
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); |