diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-10-27 17:00:51 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-10-28 00:43:06 +0300 |
commit | b909dfdae140ba0cc71003ad30dc612b059732d6 (patch) | |
tree | 9d705fd6606d4eb7a34196fe6efe67879356b9c9 /intern | |
parent | 6a529e14f4c25fc20b797799b602472d3a22a0f9 (diff) |
Cycles: Expose user-defined shutter curve to the interface
Shutter curve now can be controlled using curve mapping widget in the motion
blur panel in Render buttons. Only mapping from 0..1 by x axis are allowed,
Y values will be normalized to fill in 0..1 space as well automatically.
Y values of 0 means fully closed shutter, Y values of 1 means fully opened
shutter.
Default mapping is set to old behavior when shutter opens and closes instantly.
This shutter mapping curve could easily be used by any other render engine by
accessing scene.render.motion_blur_shutter_curve.
Reviewers: #cycles, brecht, juicyfruit, campbellbarton
Differential Revision: https://developer.blender.org/D1585
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 13 | ||||
-rw-r--r-- | intern/cycles/blender/blender_camera.cpp | 9 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 10 |
3 files changed, 32 insertions, 0 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 3700da3263e..3678391ccd5 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -268,6 +268,19 @@ class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel): col.prop(cscene, "motion_blur_position", text="Position") col.prop(rd, "motion_blur_shutter") + col = layout.column() + col.label("Shutter curve:") + col.template_curve_mapping(rd, "motion_blur_shutter_curve") + + col = layout.column(align=True) + row = col.row(align=True) + row.operator("render.shutter_curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH' + row.operator("render.shutter_curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND' + row.operator("render.shutter_curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT' + row.operator("render.shutter_curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP' + row.operator("render.shutter_curve_preset", icon='LINCURVE', text="").shape = 'LINE' + row.operator("render.shutter_curve_preset", icon='NOCURVE', text="").shape = 'MAX' + class CyclesRender_PT_film(CyclesButtonsPanel, Panel): bl_label = "Film" diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 7cb5e38d4e5..cde3840b796 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -37,6 +37,7 @@ struct BlenderCamera { float lens; float shuttertime; Camera::MotionPosition motion_position; + float shutter_curve[RAMP_TABLE_SIZE]; float aperturesize; uint apertureblades; @@ -417,6 +418,8 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int cam->fov_post = cam->fov; cam->motion_position = bcam->motion_position; + memcpy(cam->shutter_curve, bcam->shutter_curve, sizeof(cam->shutter_curve)); + /* border */ cam->border = bcam->border; cam->viewport_camera_border = bcam->viewport_camera_border; @@ -437,6 +440,9 @@ void BlenderSync::sync_camera(BL::RenderSettings b_render, BL::Object b_override bcam.pixelaspect.x = b_render.pixel_aspect_x(); bcam.pixelaspect.y = b_render.pixel_aspect_y(); bcam.shuttertime = b_render.motion_blur_shutter(); + curvemapping_to_array(b_render.motion_blur_shutter_curve(), + bcam.shutter_curve, + RAMP_TABLE_SIZE); PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); switch(RNA_enum_get(&cscene, "motion_blur_position")) { @@ -545,6 +551,9 @@ static void blender_camera_from_view(BlenderCamera *bcam, BL::RenderEngine b_eng bcam->farclip = b_v3d.clip_end(); bcam->lens = b_v3d.lens(); bcam->shuttertime = b_scene.render().motion_blur_shutter(); + curvemapping_to_array(b_scene.render().motion_blur_shutter_curve(), + bcam->shutter_curve, + RAMP_TABLE_SIZE); if(b_rv3d.view_perspective() == BL::RegionView3D::view_perspective_CAMERA) { /* camera view */ diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index bd1c37a7560..2e9e9266404 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -62,6 +62,16 @@ static inline void colorramp_to_array(BL::ColorRamp ramp, float4 *data, int size } } +static inline void curvemapping_to_array(BL::CurveMapping cumap, float *data, int size) +{ + cumap.update(); + BL::CurveMap curve = cumap.curves[0]; + for(int i = 0; i < size; i++) { + float t = (float)i/(float)(size-1); + data[i] = curve.evaluate(t); + } +} + static inline void curvemapping_color_to_array(BL::CurveMapping cumap, float4 *data, int size, bool rgb_curve) { cumap.update(); |