[Bf-blender-cvs] [a83ad13c492] eevee-motionblur-object: EEVEE: Motion Blur: Make Temporal accumulation clear up the noise
Clément Foucault
noreply at git.blender.org
Tue Apr 14 19:09:12 CEST 2020
Commit: a83ad13c492654f4e3924266538c39a8e3745583
Author: Clément Foucault
Date: Tue Mar 31 17:59:08 2020 +0200
Branches: eevee-motionblur-object
https://developer.blender.org/rBa83ad13c492654f4e3924266538c39a8e3745583
EEVEE: Motion Blur: Make Temporal accumulation clear up the noise
===================================================================
M source/blender/draw/engines/eevee/eevee_motion_blur.c
M source/blender/draw/engines/eevee/eevee_private.h
M source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
===================================================================
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 530dd38d596..ca271fd7042 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -24,6 +24,8 @@
#include "DRW_render.h"
+#include "BLI_rand.h"
+
#include "BKE_animsys.h"
#include "BKE_camera.h"
#include "BKE_object.h"
@@ -167,6 +169,7 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
DRWShadingGroup *grp = DRW_shgroup_create(e_data.motion_blur_sh, psl->motion_blur);
DRW_shgroup_uniform_int_copy(grp, "samples", scene->eevee.motion_blur_samples);
DRW_shgroup_uniform_float_copy(grp, "shutter", scene->eevee.motion_blur_shutter);
+ DRW_shgroup_uniform_float(grp, "sampleOffset", &effects->motion_blur_sample_offset, 1);
DRW_shgroup_uniform_mat4(grp, "currInvViewProjMatrix", effects->current_ndc_to_world);
DRW_shgroup_uniform_mat4(grp, "pastViewProjMatrix", effects->past_world_to_ndc);
DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &effects->source_buffer);
@@ -241,6 +244,12 @@ void EEVEE_motion_blur_draw(EEVEE_Data *vedata)
/* Motion Blur */
if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) {
+ int sample = DRW_state_is_image_render() ? effects->taa_render_sample :
+ effects->taa_current_sample;
+ double r;
+ BLI_halton_1d(2, 0.0, sample - 1, &r);
+ effects->motion_blur_sample_offset = r;
+
GPU_framebuffer_bind(effects->target_buffer);
DRW_draw_pass(psl->motion_blur);
SWAP_BUFFERS();
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 06348c153d2..3d43cc8d12e 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -622,6 +622,7 @@ typedef struct EEVEE_EffectsInfo {
CameraParams current_cam_params;
float current_time;
float past_time;
+ float motion_blur_sample_offset;
bool cam_params_init;
/* Velocity Pass */
struct GPUTexture *velocity_tx; /* Texture from pool */
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 3b1f718b4db..b7fe9e511c0 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
@@ -4,6 +4,7 @@ uniform sampler2D velocityBuffer;
uniform int samples;
uniform float shutter;
+uniform float sampleOffset;
in vec4 uvcoordsvar;
@@ -23,7 +24,7 @@ float wang_hash_noise(uint s)
float value = float(seed);
value *= 1.0 / 4294967296.0;
- return fract(value);
+ return fract(value + sampleOffset);
}
void main()
More information about the Bf-blender-cvs
mailing list