Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-03-07 17:01:30 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-03-07 17:01:30 +0400
commitcb45a5bbb08a7878f0cd14781ed84ac42e1349ad (patch)
tree6e674b67013aa73ee4bfb189c72d9628b1693405 /intern
parent925f21342709522afa334218e97e0b31f87f1516 (diff)
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.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/addon/enums.py6
-rw-r--r--intern/cycles/blender/addon/properties.py18
-rw-r--r--intern/cycles/blender/addon/ui.py7
-rw-r--r--intern/cycles/blender/blender_camera.cpp13
4 files changed, 41 insertions, 3 deletions
diff --git a/intern/cycles/blender/addon/enums.py b/intern/cycles/blender/addon/enums.py
index e1b138def3c..889a8f03552 100644
--- a/intern/cycles/blender/addon/enums.py
+++ b/intern/cycles/blender/addon/enums.py
@@ -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"),
+ )
+
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 7e7e83b4f69..751baedca45 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -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",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index faf057e13cc..a8f499cf324 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -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")
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp
index 7c9c162f8b1..e7704c5f885 100644
--- a/intern/cycles/blender/blender_camera.cpp
+++ b/intern/cycles/blender/blender_camera.cpp
@@ -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);