[Bf-blender-cvs] [5fab2ce5004] eevee-motionblur-object: EEVEE: Motion Blur: Randomize velocity tile boundaries to avoid artifacts
Clément Foucault
noreply at git.blender.org
Fri Jun 12 15:17:31 CEST 2020
Commit: 5fab2ce5004edc93b704d02234c1e658fa024854
Author: Clément Foucault
Date: Wed Jun 10 19:43:05 2020 +0200
Branches: eevee-motionblur-object
https://developer.blender.org/rB5fab2ce5004edc93b704d02234c1e658fa024854
EEVEE: Motion Blur: Randomize velocity tile boundaries to avoid artifacts
This follows the paper implementation. This gives nice results on complex
motions.
===================================================================
M source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
===================================================================
diff --git a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
index 61888597f14..dd1d621ede9 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
@@ -147,6 +147,13 @@ void gather_blur(vec2 screen_uv,
float center_motion_len = length(center_motion);
float max_motion_len = length(max_motion);
+ /* Tile boundaries randomization can fetch a tile where there is less motion than this pixel.
+ * Fix this by overriding the max_motion. */
+ if (max_motion_len < center_motion_len) {
+ max_motion_len = center_motion_len;
+ max_motion = center_motion;
+ }
+
if (max_motion_len < 0.5) {
return;
}
@@ -197,8 +204,14 @@ void main()
vec4 center_motion = sample_velocity(uv);
vec4 center_color = textureLod(colorBuffer, uv, 0.0);
- vec4 max_motion = texelFetch(tileMaxBuffer, ivec2(gl_FragCoord.xy) / maxBlurRadius, 0);
- max_motion = decode_velocity(max_motion);
+ /* TODO use blue noise texture. */
+ float rand = fract(wang_hash_noise(68241u) + sampleOffset) * 2.0 - 1.0;
+
+ /* Randomize tile boundary to avoid ugly discontinuities. Randomize 1/4th of the tile.
+ * Note this randomize only in one direction but in practice it's enough. */
+ ivec2 tile = ivec2(gl_FragCoord.xy + rand * float(maxBlurRadius) * 0.25) / maxBlurRadius;
+ tile = clamp(tile, ivec2(0), textureSize(tileMaxBuffer, 0).xy - 1);
+ vec4 max_motion = decode_velocity(texelFetch(tileMaxBuffer, tile, 0));
/* First (center) sample: time = T */
/* x: Background, y: Foreground, z: dir. */
More information about the Bf-blender-cvs
mailing list