diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-05-17 17:57:31 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-17 18:59:26 +0300 |
commit | bc3139d79226896cf6c2b0813a1188eda70fad09 (patch) | |
tree | e5c7f1f878b4769def10e2ddbc75aacebda4afd5 /intern | |
parent | 043299ab69ca47a42fc8ca4f629727f8a6a2dd31 (diff) |
Cycles/Eevee: unify depth of field settings for cameras
There is now a checkbox to enable/disable depth of field per camera. For Eevee
this replace the scene level setting. For Cycles there is now only an F-Stop
value, no longer a Radius.
Existing files are converted based on Cycles or Eevee being set in the scene.
Differential Revision: https://developer.blender.org/D4882
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 48 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 55 | ||||
-rw-r--r-- | intern/cycles/blender/blender_camera.cpp | 34 |
3 files changed, 36 insertions, 101 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 35f9e17dc41..d9e145c8b75 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -68,11 +68,6 @@ enum_filter_types = ( ('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"), ) -enum_aperture_types = ( - ('RADIUS', "Radius", "Directly change the size of the aperture"), - ('FSTOP', "F-stop", "Change the size of the aperture by f-stop"), -) - enum_panorama_types = ( ('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"), ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"), @@ -742,49 +737,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): class CyclesCameraSettings(bpy.types.PropertyGroup): - aperture_type: EnumProperty( - name="Aperture Type", - description="Use f-stop number or aperture radius", - items=enum_aperture_types, - default='RADIUS', - ) - aperture_fstop: FloatProperty( - name="Aperture f-stop", - description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)", - min=0.0, soft_min=0.1, soft_max=64.0, - default=5.6, - step=10, - precision=1, - ) - aperture_size: FloatProperty( - name="Aperture Size", - description="Radius of the aperture for depth of field (higher values give more defocus)", - min=0.0, soft_max=10.0, - default=0.0, - step=1, - precision=4, - subtype='DISTANCE', - ) - aperture_blades: IntProperty( - name="Aperture Blades", - description="Number of blades in aperture for polygonal bokeh (at least 3)", - min=0, max=100, - default=0, - ) - aperture_rotation: FloatProperty( - name="Aperture Rotation", - description="Rotation of blades in aperture", - soft_min=-pi, soft_max=pi, - subtype='ANGLE', - default=0, - ) - aperture_ratio: FloatProperty( - name="Aperture Ratio", - description="Distortion to simulate anamorphic lens bokeh", - min=0.01, soft_min=1.0, soft_max=2.0, - default=1.0, - precision=4, - ) panorama_type: EnumProperty( name="Panorama Type", description="Distortion to use for the calculation", diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 86f58769025..80b4159f2ec 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1016,20 +1016,27 @@ class CYCLES_CAMERA_PT_dof(CyclesButtonsPanel, Panel): def poll(cls, context): return context.camera and CyclesButtonsPanel.poll(context) + def draw_header(self, context): + cam = context.camera + dof = cam.dof + self.layout.prop(dof, "use_dof", text="") + def draw(self, context): layout = self.layout layout.use_property_split = True cam = context.camera + dof = cam.dof + layout.active = dof.use_dof split = layout.split() col = split.column() - col.prop(cam, "dof_object", text="Focus Object") + col.prop(dof, "focus_object", text="Focus Object") sub = col.row() - sub.active = cam.dof_object is None - sub.prop(cam, "dof_distance", text="Distance") + sub.active = dof.focus_object is None + sub.prop(dof, "focus_distance", text="Distance") class CYCLES_CAMERA_PT_dof_aperture(CyclesButtonsPanel, Panel): @@ -1043,44 +1050,17 @@ class CYCLES_CAMERA_PT_dof_aperture(CyclesButtonsPanel, Panel): def draw(self, context): layout = self.layout layout.use_property_split = True - flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) cam = context.camera - ccam = cam.cycles - - col = flow.column() - col.prop(ccam, "aperture_type") - if ccam.aperture_type == 'RADIUS': - col.prop(ccam, "aperture_size", text="Size") - elif ccam.aperture_type == 'FSTOP': - col.prop(ccam, "aperture_fstop", text="Number") - col.separator() - - col = flow.column() - col.prop(ccam, "aperture_blades", text="Blades") - col.prop(ccam, "aperture_rotation", text="Rotation") - col.prop(ccam, "aperture_ratio", text="Ratio") - - -class CYCLES_CAMERA_PT_dof_viewport(CyclesButtonsPanel, Panel): - bl_label = "Viewport" - bl_parent_id = "CYCLES_CAMERA_PT_dof" - - @classmethod - def poll(cls, context): - return context.camera and CyclesButtonsPanel.poll(context) - - def draw(self, context): - layout = self.layout - layout.use_property_split = True + dof = cam.dof + layout.active = dof.use_dof flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False) - cam = context.camera - dof_options = cam.gpu_dof - - sub = flow.column(align=True) - sub.prop(dof_options, "fstop") - sub.prop(dof_options, "blades") + col = flow.column() + col.prop(dof, "aperture_fstop") + col.prop(dof, "aperture_blades") + col.prop(dof, "aperture_rotation") + col.prop(dof, "aperture_ratio") class CYCLES_PT_context_material(CyclesButtonsPanel, Panel): @@ -2147,7 +2127,6 @@ classes = ( CYCLES_PT_post_processing, CYCLES_CAMERA_PT_dof, CYCLES_CAMERA_PT_dof_aperture, - CYCLES_CAMERA_PT_dof_viewport, CYCLES_PT_context_material, CYCLES_OBJECT_PT_motion_blur, CYCLES_OBJECT_PT_cycles_settings, diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index b3bfaa992a9..92dc8a8a4c6 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -119,10 +119,10 @@ static float blender_camera_focal_distance(BL::RenderEngine &b_engine, BL::Camera &b_camera, BlenderCamera *bcam) { - BL::Object b_dof_object = b_camera.dof_object(); + BL::Object b_dof_object = b_camera.dof().focus_object(); if (!b_dof_object) - return b_camera.dof_distance(); + return b_camera.dof().focus_distance(); /* for dof object, return distance along camera Z direction */ BL::Array<float, 16> b_ob_matrix; @@ -191,26 +191,30 @@ static void blender_camera_from_object(BlenderCamera *bcam, bcam->lens = b_camera.lens(); - /* allow f/stop number to change aperture_size but still - * give manual control over aperture radius */ - int aperture_type = get_enum(ccamera, "aperture_type"); - - if (aperture_type == 1) { - float fstop = RNA_float_get(&ccamera, "aperture_fstop"); + if (b_camera.dof().use_dof()) { + /* allow f/stop number to change aperture_size but still + * give manual control over aperture radius */ + float fstop = b_camera.dof().aperture_fstop(); fstop = max(fstop, 1e-5f); if (bcam->type == CAMERA_ORTHOGRAPHIC) bcam->aperturesize = 1.0f / (2.0f * fstop); else bcam->aperturesize = (bcam->lens * 1e-3f) / (2.0f * fstop); - } - else - bcam->aperturesize = RNA_float_get(&ccamera, "aperture_size"); - bcam->apertureblades = RNA_int_get(&ccamera, "aperture_blades"); - bcam->aperturerotation = RNA_float_get(&ccamera, "aperture_rotation"); - bcam->focaldistance = blender_camera_focal_distance(b_engine, b_ob, b_camera, bcam); - bcam->aperture_ratio = RNA_float_get(&ccamera, "aperture_ratio"); + bcam->apertureblades = b_camera.dof().aperture_blades(); + bcam->aperturerotation = b_camera.dof().aperture_rotation(); + bcam->focaldistance = blender_camera_focal_distance(b_engine, b_ob, b_camera, bcam); + bcam->aperture_ratio = b_camera.dof().aperture_ratio(); + } + else { + /* DOF is turned of for the camera. */ + bcam->aperturesize = 0.0f; + bcam->apertureblades = 0; + bcam->aperturerotation = 0.0f; + bcam->focaldistance = 0.0f; + bcam->aperture_ratio = 1.0f; + } bcam->shift.x = b_engine.camera_shift_x(b_ob, bcam->use_spherical_stereo); bcam->shift.y = b_camera.shift_y(); |