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>2018-01-16 21:40:17 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-01-16 21:40:17 +0300
commit213e34a6c32022836337c8bf181b4bbd69fa6097 (patch)
tree28ab6eb80337475863031ffdf35cb295c8bb8c9e /source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
parent9fd28c776938fe420782a6339e9da7c619724dae (diff)
Eevee: Fix Hashed Alpha.
Now hashed alpha materials are stable when moving the camera/not using TAA. It also converge to a noise free image when using TAA. No more numerical imprecision. There still can be situations with multiple overlapping transparent surfaces that can lead to residual noise.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/prepass_frag.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/prepass_frag.glsl10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
index f921d56e3bc..1c0e65f0613 100644
--- a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl
@@ -10,14 +10,15 @@ float hash3d(vec3 a) {
return hash(vec2(hash(a.xy), a.z));
}
-//uniform float hashScale;
-float hashScale = 0.001;
+uniform float hashAlphaOffset;
float hashed_alpha_threshold(vec3 co)
{
+ const float hash_scale = 1.0; /* Roughly in pixel */
+
/* Find the discretized derivatives of our coordinates. */
float max_deriv = max(length(dFdx(co)), length(dFdy(co)));
- float pix_scale = 1.0 / (hashScale * max_deriv);
+ float pix_scale = 1.0 / (hash_scale * max_deriv);
/* Find two nearest log-discretized noise scales. */
float pix_scale_log = log2(pix_scale);
@@ -53,7 +54,8 @@ float hashed_alpha_threshold(vec3 co)
/* Avoids threshold == 0. */
threshold = clamp(threshold, 1.0e-6, 1.0);
- return threshold;
+ /* Jitter the threshold for TAA accumulation. */
+ return fract(threshold + hashAlphaOffset);
}
#endif