Skip to content

[parse_blend_file] depth of field #139

@wahn

Description

@wahn

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:

pbrt_dof

In Blender version 2.79 the two settings in questions are shown here:

dof_blend_settings

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions