Cycles: option to specify camera aperture in radius or f/stop:

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Camera#Depth_of_Field

Patch by Ejner Fergo.
This commit is contained in:
Brecht Van Lommel 2012-03-07 13:01:30 +00:00
parent 925f213427
commit cb45a5bbb0
4 changed files with 41 additions and 3 deletions

@ -49,3 +49,9 @@ filter_types = (
("BOX", "Box", "Box filter"),
("GAUSSIAN", "Gaussian", "Gaussian filter"),
)
aperture_types = (
("RADIUS", "Radius", "Directly change the size of the aperture"),
("FSTOP", "F/stop", "Change the size of the aperture by f/stops"),
)

@ -231,11 +231,27 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
type=cls,
)
cls.aperture_type = EnumProperty(
name="Aperture Type",
description="Use f/stop number or aperture radius",
items=enums.aperture_types,
default='RADIUS',
)
cls.aperture_fstop = FloatProperty(
name="Aperture F/stop",
description="F/stop ratio (lower numbers equals more bokeh while higher numbers equals less bokeh)",
min=0.0, soft_min=0.1, soft_max=64.0,
default=5.6,
step=10,
precision=1,
)
cls.aperture_size = FloatProperty(
name="Aperture Size",
description="Radius of the aperture for depth of field",
min=0.0, max=10.0,
min=0.0, soft_max=10.0,
default=0.0,
step=1,
precision=4,
)
cls.aperture_blades = IntProperty(
name="Aperture Blades",

@ -263,7 +263,12 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
col = split.column()
col.label("Aperture:")
col.prop(ccam, "aperture_size", text="Size")
sub = col.column(align=True)
sub.prop(ccam, "aperture_type", text="")
if ccam.aperture_type == 'RADIUS':
sub.prop(ccam, "aperture_size", text="Size")
elif ccam.aperture_type == 'FSTOP':
sub.prop(ccam, "aperture_fstop", text="Number")
sub = col.column(align=True)
sub.prop(ccam, "aperture_blades", text="Blades")

@ -98,7 +98,18 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::Object b_ob)
bcam->ortho_scale = b_camera.ortho_scale();
bcam->lens = b_camera.lens();
bcam->aperturesize = RNA_float_get(&ccamera, "aperture_size");
/* allow f/stop number to change aperture_size but still
give manual control over aperture radius */
int aperture_type = RNA_enum_get(&ccamera, "aperture_type");
if(aperture_type == 1) {
float fstop = RNA_float_get(&ccamera, "aperture_fstop");
bcam->aperturesize = (bcam->lens*1e-3f)/(2.0f*max(fstop, 1e-5f));
}
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_ob, b_camera);