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>2021-02-24 13:36:16 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-02-24 13:37:03 +0300
commit32ca8e58a374dc28df0b0a744e407a8ebf58e56e (patch)
tree23c1fea1b674424a74ce27b78011f649546d9323
parentbb2af40ec7dd9a0c41991bc2faaf6eb3f0618016 (diff)
Workbench: Fix samples taken outside of pixel footprint
With the previous implementation, we could have pixels with offset larger than 1 pixel. Also fix a bug when the closest_index is not last. The sample positions were incorrect in this case.
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_antialiasing.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
index 77fdbde99ef..84cc4359aa6 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
@@ -64,10 +64,17 @@ static void workbench_taa_jitter_init_order(float (*table)[2], int num)
}
}
- /* move jitter table so that closest sample is in center */
+ float closest_sample[2];
+ copy_v2_v2(closest_sample, table[closest_index]);
for (int index = 0; index < num; index++) {
- sub_v2_v2(table[index], table[closest_index]);
- mul_v2_fl(table[index], 2.0f);
+ /* move jitter table so that closest sample is in center */
+ sub_v2_v2(table[index], closest_sample);
+ for (int i = 0; i < 2; i++) {
+ /* Avoid samples outside range (wrap arround). */
+ table[index][i] = fmodf(table[index][i] + 0.5f, 1.0f);
+ /* Recenter the distribution[-1..1]. */
+ table[index][i] += table[index][i] * 2.0f - 1.0f;
+ }
}
/* swap center sample to the start of the table */