Skip to content

Commit

Permalink
Fix mesh motion blur interpolation and velocity scaling (#108)
Browse files Browse the repository at this point in the history
- Keyframing for mesh motion blud with shape keys is now set for
  current frame and next frame. Found out a way to change shape key
  fcurve interpolation to linear type, to get rid of the default
  bezier interpolation causing initial location "burning" in the image.
  • Loading branch information
tkeskita committed Feb 17, 2024
1 parent cd0a6c9 commit 211f3b5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ def vtkdata_to_blender_mesh(

# Calculate shape key coordinates
for i, bv in enumerate(bm.verts):
bv[key_shape] = bv.co + 2.0 * motion_blur_time_step * Vector(array_data[i])
bv[key_shape] = bv.co + motion_blur_time_step * Vector(array_data[i])

bm.to_mesh(me)

Expand All @@ -731,9 +731,13 @@ def vtkdata_to_blender_mesh(
ob.data.shape_keys.animation_data_clear()
kb = ob.data.shape_keys.key_blocks["key_blur"]
kb.value = 1.0
kb.keyframe_insert("value",frame=nFrame+1)
kb.keyframe_insert("value", frame=nFrame+1)
kb.value = 0.0
kb.keyframe_insert("value",frame=nFrame-1)
kb.keyframe_insert("value", frame=nFrame)
# Set FCurve interpolation to linear (default is bezier).
# Setting kb.interpolation="KEY_LINEAR" does not produce linear interpolation.
ob.data.shape_keys.animation_data.action.fcurves[0].keyframe_points[0].interpolation='LINEAR'
ob.data.shape_keys.animation_data.action.fcurves[0].keyframe_points[1].interpolation='LINEAR'
bpy.context.scene.cycles.use_motion_blur = True
bpy.context.scene.eevee.use_motion_blur = True
# Must use "Start on Frame" Position for motion blur to avoid frame changes
Expand Down

0 comments on commit 211f3b5

Please sign in to comment.