Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-09-07 01:44:07 +0300
committerYimingWu <xp8110@outlook.com>2019-09-12 04:13:02 +0300
commita15de692a7273211ef27ec5f83d987303e9df5ec (patch)
tree7ad47cbbff92a1863ccf0fde67b0671ab3db38ab
parentb27eb93ea78dea49f01d9bc9a4bc82b7f6f46000 (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
-rw-r--r--source/blender/draw/engines/eevee/eevee_sampling.c18
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);