[Bf-blender-cvs] [33359237fe6] eevee-motionblur-object: EEVEE: Motion Blur: Expose max blur and depth scale

Clément Foucault noreply at git.blender.org
Fri Jun 12 15:17:32 CEST 2020


Commit: 33359237fe69dda1ef97598dcead649e159ab445
Author: Clément Foucault
Date:   Thu Jun 11 16:37:11 2020 +0200
Branches: eevee-motionblur-object
https://developer.blender.org/rB33359237fe69dda1ef97598dcead649e159ab445

EEVEE: Motion Blur: Expose max blur and depth scale

===================================================================

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/eevee/eevee_motion_blur.c
M	source/blender/draw/engines/eevee/shaders/effect_motion_blur_frag.glsl
M	source/blender/makesdna/DNA_scene_defaults.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 11b02cfb552..70d4e3c275d 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -173,8 +173,9 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
 
         layout.active = props.use_motion_blur
         col = layout.column()
-        col.prop(props, "motion_blur_samples")
         col.prop(props, "motion_blur_shutter")
+        col.prop(props, "motion_blur_depth_scale")
+        col.prop(props, "motion_blur_max")
 
 
 class RENDER_PT_eevee_depth_of_field(RenderButtonsPanel, Panel):
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 6211c58d7d4..23ea1bd39b3 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -5076,5 +5076,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
    */
   {
     /* Keep this block, even when empty. */
+
+    /* EEVEE Motion blur new parameters. */
+    if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "motion_blur_depth_scale")) {
+      LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+        scene->eevee.motion_blur_depth_scale = 100.0f;
+        scene->eevee.motion_blur_max = 32;
+      }
+    }
   }
 }
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index 612695b849b..51b5cdcb13b 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -184,7 +184,7 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
     }
 #endif
 
-    effects->motion_blur_max = 32;
+    effects->motion_blur_max = max_ii(16, scene->eevee.motion_blur_max);
     const float *fs_size = DRW_viewport_size_get();
     int tx_size[2] = {1 + ((int)fs_size[0] / effects->motion_blur_max),
                       1 + ((int)fs_size[1] / effects->motion_blur_max)};
@@ -274,14 +274,13 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat
       eGPUSamplerState state = 0;
 
       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(grp, "sampleOffset", &effects->motion_blur_sample_offset, 1);
       DRW_shgroup_uniform_texture(grp, "utilTex", EEVEE_materials_get_util_tex());
       DRW_shgroup_uniform_texture_ref_ex(grp, "colorBuffer", &effects->source_buffer, state);
       DRW_shgroup_uniform_texture_ref_ex(grp, "depthBuffer", &dtxl->depth, state);
       DRW_shgroup_uniform_texture_ref_ex(grp, "velocityBuffer", &effects->velocity_tx, state);
       DRW_shgroup_uniform_texture_ref_ex(
           grp, "tileMaxBuffer", &effects->velocity_tiles_expand_tx, state);
+      DRW_shgroup_uniform_float_copy(grp, "depthScale", scene->eevee.motion_blur_depth_scale);
       DRW_shgroup_uniform_int_copy(grp, "maxBlurRadius", effects->motion_blur_max);
       DRW_shgroup_uniform_vec2(grp, "nearFar", effects->motion_blur_near_far, 1);
       DRW_shgroup_uniform_bool_copy(grp, "isPerspective", DRW_view_is_persp_get(NULL));
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 68ac66171b6..6bfc95ea667 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
@@ -21,8 +21,7 @@ uniform sampler2DArray utilTex;
 #define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
 
 uniform int maxBlurRadius;
-uniform int samples;
-uniform float sampleOffset;
+uniform float depthScale;
 uniform vec2 viewportSize;
 uniform vec2 viewportSizeInv;
 uniform bool isPerspective;
@@ -43,12 +42,9 @@ vec2 spread_compare(float center_motion_length, float sample_motion_length, floa
   return saturate(vec2(center_motion_length, sample_motion_length) - offset_length + 1.0);
 }
 
-/* TODO expose to user */
-#define DEPTH_SCALE 100.0
-
 vec2 depth_compare(float center_depth, float sample_depth)
 {
-  return saturate(0.5 + vec2(DEPTH_SCALE, -DEPTH_SCALE) * (sample_depth - center_depth));
+  return saturate(0.5 + vec2(depthScale, -depthScale) * (sample_depth - center_depth));
 }
 
 /* Kill contribution if not going the same direction. */
diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h
index 4b6f079aa28..3f8730e21db 100644
--- a/source/blender/makesdna/DNA_scene_defaults.h
+++ b/source/blender/makesdna/DNA_scene_defaults.h
@@ -220,6 +220,8 @@
  \
     .motion_blur_samples = 8, \
     .motion_blur_shutter = 0.5f, \
+    .motion_blur_depth_scale = 100.0f, \
+    .motion_blur_max = 32, \
  \
     .shadow_cube_size = 512, \
     .shadow_cascade_size = 1024, \
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index c50e48982b3..7329365805c 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1628,8 +1628,10 @@ typedef struct SceneEEVEE {
   float bloom_radius;
   float bloom_clamp;
 
-  int motion_blur_samples;
+  int motion_blur_samples DNA_DEPRECATED;
+  int motion_blur_max;
   float motion_blur_shutter;
+  float motion_blur_depth_scale;
 
   int shadow_method DNA_DEPRECATED;
   int shadow_cube_size;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 7e9753b090a..3475d83c442 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7150,12 +7150,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
   RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 
-  prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_UNSIGNED);
-  RNA_def_property_ui_text(prop, "Samples", "Number of samples to take with motion blur");
-  RNA_def_property_range(prop, 1, 64);
-  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
-  RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
-
   prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR);
   RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
   RNA_def_property_range(prop, 0.0f, FLT_MAX);
@@ -7163,6 +7157,23 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
   RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 
+  prop = RNA_def_property(srna, "motion_blur_depth_scale", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_ui_text(prop,
+                           "Background Separation",
+                           "Lower values will reduce background"
+                           " bleeding onto foreground elements");
+  RNA_def_property_range(prop, 0.0f, FLT_MAX);
+  RNA_def_property_ui_range(prop, 0.01f, 1000.0f, 1, 2);
+  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+  RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
+  prop = RNA_def_property(srna, "motion_blur_max", PROP_INT, PROP_PIXEL);
+  RNA_def_property_ui_text(prop, "Max Blur", "Maximum blur distance a pixel can spread over");
+  RNA_def_property_range(prop, 1, 2048);
+  RNA_def_property_ui_range(prop, 1, 512, 1, -1);
+  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+  RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+
   /* Shadows */
   prop = RNA_def_property(srna, "shadow_cube_size", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_items(prop, eevee_shadow_size_items);



More information about the Bf-blender-cvs mailing list