http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Camera#Depth_of_Field
Patch by Ejner Fergo.
("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"),
+ )
+
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",
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")
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);