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
This commit is contained in:
Clément Foucault 2020-10-13 16:55:19 +02:00
parent ed96c59c20
commit b7afcdff7b
Notes: blender-bot 2023-02-13 21:24:49 +01:00
Referenced by issue #80070, Motion Blur Start position
4 changed files with 50 additions and 5 deletions

View File

@ -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")

View File

@ -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;

View File

@ -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,

View File

@ -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);