[parse_blend_file] depth of field
wahn opened this issue · 2 comments
It would be useful to be able to specify depth of field (DOF) settings within the Blender scene and use those on the rs-pbrt
side.
For .pbrt
files those should work correctly already, but forparse_blend_file
we still need a way how to translate the settings from the Blender UI to camera settings, which can be used for e.g. the struct PerspectiveCamera
. Here an example from the Italian Flat scene:
In Blender version 2.79 the two settings in questions are shown here:
The depth of field distance can be used as parameter focaldistance
directly, but Blender's f-stop value has to be translated somehow to PBRT's lensradius
(in this example I used lensradius = 0.0125
):
diff --git a/src/cameras/perspective.rs b/src/cameras/perspective.rs
index 92c77db..72f9d98 100644
--- a/src/cameras/perspective.rs
+++ b/src/cameras/perspective.rs
@@ -173,6 +173,10 @@ impl PerspectiveCamera {
// params.find_one_float(String::from("halffov"), -1.0);
// TODO: if (halffov > 0.f)
// TODO: let perspective_camera: Arc<Camera + Sync + Send> =
+ // TMP
+ let lensradius: Float = 0.0125;
+ let focaldistance: Float = 5.6;
+ // TMP
Arc::new(Camera::Perspective(Box::new(PerspectiveCamera::new(
cam2world,
screen,
The best solution would be to look into Blender's source code to find a proper translation hint.
The focaldistance
we need for PerspectiveCamera
can be taken directly from Camera.YF_dofdist
:
$ ./target/release/blend_info -n Camera.YF_dofdist ~/git/self_hosted/render_comparison/blend/italian_flat/italian_flat_v279.blend
Camera.YF_dofdist = 0_f32
Camera.YF_dofdist = 0_f32
Camera.YF_dofdist = 0_f32
Camera.YF_dofdist = 0_f32
Camera.YF_dofdist = 0_f32
Camera.YF_dofdist = 0_f32
Camera.YF_dofdist = 5.6_f32
From within Blender 2.79 you can access the aperture_fstop
via Python:
>>> bpy.data.cameras['Camera_Table_Details'].cycles.aperture_fstop
2.0