[Bf-blender-cvs] [b7afcdff7b0] master: EEVEE: Motion Blur: Add shutter position option

Clément Foucault noreply at git.blender.org
Tue Oct 13 18:09:15 CEST 2020


Commit: b7afcdff7b068f668a3bfb032cf659693c8879f0
Author: Clément Foucault
Date:   Tue Oct 13 16:55:19 2020 +0200
Branches: master
https://developer.blender.org/rBb7afcdff7b068f668a3bfb032cf659693c8879f0

EEVEE: Motion Blur: Add shutter position option

This makes it easier to generate motion trail effect with EEVEE.

This just mimics the cycles option as described here:
https://docs.blender.org/manual/en/latest/render/cycles/render_settings/motion_blur.html

This fix T80070

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

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/draw/engines/eevee/eevee_engine.c
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 1c52001f32e..ae2a7a8ccb9 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -173,7 +173,9 @@ class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):
 
         layout.active = props.use_motion_blur
         col = layout.column()
+        col.prop(props, "motion_blur_position", text="Position")
         col.prop(props, "motion_blur_shutter")
+        col.separator()
         col.prop(props, "motion_blur_depth_scale")
         col.prop(props, "motion_blur_max")
         col.prop(props, "motion_blur_steps", text="Steps")
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 872cc3247d4..355d156a083 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -460,13 +460,27 @@ static void eevee_render_to_image(void *vedata,
 
   int initial_frame = CFRA;
   float initial_subframe = SUBFRA;
-  int steps = max_ii(1, scene->eevee.motion_blur_steps);
-  int time_steps_tot = (do_motion_blur) ? steps : 1;
+  float shuttertime = (do_motion_blur) ? scene->eevee.motion_blur_shutter : 0.0f;
+  int time_steps_tot = (do_motion_blur) ? max_ii(1, scene->eevee.motion_blur_steps) : 1;
   g_data->render_tot_samples = divide_ceil_u(scene->eevee.taa_render_samples, time_steps_tot);
-  /* Centered on frame for now. */
-  float time = initial_frame + initial_subframe - scene->eevee.motion_blur_shutter / 2.0f;
+  /* Compute start time. The motion blur will cover `[time ...time + shuttertime]`. */
+  float time = initial_frame + initial_subframe;
+  switch (scene->eevee.motion_blur_position) {
+    case SCE_EEVEE_MB_START:
+      /* No offset. */
+      break;
+    case SCE_EEVEE_MB_CENTER:
+      time -= shuttertime * 0.5f;
+      break;
+    case SCE_EEVEE_MB_END:
+      time -= shuttertime;
+      break;
+    default:
+      BLI_assert(!"Invalid motion blur position enum!");
+      break;
+  }
 
-  float time_step = scene->eevee.motion_blur_shutter / time_steps_tot;
+  float time_step = shuttertime / time_steps_tot;
   for (int i = 0; i < time_steps_tot && !RE_engine_test_break(engine); i++) {
     float time_prev = time;
     float time_curr = time + time_step * 0.5f;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index b4356ddebb7..0b63a085ee6 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1635,8 +1635,10 @@ typedef struct SceneEEVEE {
   int motion_blur_samples DNA_DEPRECATED;
   int motion_blur_max;
   int motion_blur_steps;
+  int motion_blur_position;
   float motion_blur_shutter;
   float motion_blur_depth_scale;
+  char _pad0[4];
 
   int shadow_method DNA_DEPRECATED;
   int shadow_cube_size;
@@ -2405,6 +2407,13 @@ enum {
   /* SHADOW_METHOD_MAX = 3, */ /* UNUSED */
 };
 
+/* SceneEEVEE->motion_blur_position */
+enum {
+  SCE_EEVEE_MB_CENTER = 0,
+  SCE_EEVEE_MB_START = 1,
+  SCE_EEVEE_MB_END = 2,
+};
+
 /* SceneDisplay->render_aa, SceneDisplay->viewport_aa */
 enum {
   SCE_DISPLAY_AA_OFF = 0,
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index b909885b006..24cff501b59 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -6851,6 +6851,17 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
+  static const EnumPropertyItem eevee_motion_blur_position_items[] = {
+      {SCE_EEVEE_MB_START, "START", 0, "Start on Frame", "The shutter opens at the current frame"},
+      {SCE_EEVEE_MB_CENTER,
+       "CENTER",
+       0,
+       "Center on Frame",
+       "The shutter is open during the current frame"},
+      {SCE_EEVEE_MB_END, "END", 0, "End on Frame", "The shutter closes at the current frame"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
   srna = RNA_def_struct(brna, "SceneEEVEE", NULL);
   RNA_def_struct_path_func(srna, "rna_SceneEEVEE_path");
   RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport");
@@ -7240,6 +7251,15 @@ 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_position", PROP_ENUM, PROP_NONE);
+  RNA_def_property_enum_items(prop, eevee_motion_blur_position_items);
+  RNA_def_property_ui_text(prop,
+                           "Motion Blur Position",
+                           "Offset for the shutter's time interval, "
+                           "allows to change the motion blur trails");
+  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