[Bf-blender-cvs] [04fa0511ca5] master: DrawEngines: Depth Of Field Units

Jeroen Bakker noreply at git.blender.org
Wed May 22 16:16:43 CEST 2019


Commit: 04fa0511ca5ec305356a6060b25e2845053d62d6
Author: Jeroen Bakker
Date:   Wed May 22 15:22:10 2019 +0200
Branches: master
https://developer.blender.org/rB04fa0511ca5ec305356a6060b25e2845053d62d6

DrawEngines: Depth Of Field Units

The unit system is designed for displaying and editing and not for
rendering. Eevee, Workbench and GPencil used these settings to convert
the focal length and sensor size to world units. Making depth of field
render differently with Cycles.

For now we will remove the scale in the draw engines to match cycles,
until we implemented a camera parameters specific scale.

Reviewed By: brecht, fclem

Maniphest Tasks: T64988

Differential Revision: https://developer.blender.org/D4925

===================================================================

M	source/blender/draw/engines/eevee/eevee_depth_of_field.c
M	source/blender/draw/engines/gpencil/gpencil_shader_fx.c
M	source/blender/draw/engines/workbench/workbench_effect_dof.c

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index ae8e7614302..c14f08857c3 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -140,14 +140,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
     float focus_dist = BKE_camera_object_dof_distance(camera);
     float focal_len = cam->lens;
 
-    /* this is factor that converts to the scene scale. focal length and sensor are expressed in
-     * mm unit.scale_length is how many meters per blender unit we have. We want to convert to
-     * blender units though because the shader reads coordinates in world space, which is in
-     * blender units.
-     * Note however that focus_distance is already in blender units and shall not be scaled here
-     * (see T48157). */
-    float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f;
-    float scale_camera = 0.001f / scale;
+    const float scale_camera = 0.001f;
     /* we want radius here for the aperture number  */
     float aperture = 0.5f * scale_camera * focal_len / fstop;
     float focal_len_scaled = scale_camera * focal_len;
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index d46e850ba82..5d3944e34f0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -119,13 +119,7 @@ static void GPENCIL_dof_nearfar(Object *camera, float coc, float nearfar[2])
   float focus_dist = BKE_camera_object_dof_distance(camera);
   float focal_len = cam->lens;
 
-  /* This is factor that converts to the scene scale. focal length and sensor are expressed in mm
-   * unit.scale_length is how many meters per blender unit we have. We want to convert to blender
-   * units though because the shader reads coordinates in world space, which is in blender units.
-   * Note however that focus_distance is already in blender units and shall not be scaled here
-   * (see T48157). */
-  float scale = (scene->unit.system) ? scene->unit.scale_length : 1.0f;
-  float scale_camera = 0.001f / scale;
+  const float scale_camera = 0.001f;
   /* we want radius here for the aperture number  */
   float aperture_scaled = 0.5f * scale_camera * focal_len / fstop;
   float focal_len_scaled = scale_camera * focal_len;
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index 6886b73650c..e24536759db 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -231,7 +231,6 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
 
   {
     const DRWContextState *draw_ctx = DRW_context_state_get();
-    const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
     RegionView3D *rv3d = draw_ctx->rv3d;
 
     /* Parameters */
@@ -242,14 +241,7 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera)
     float focal_len = cam->lens;
 
     /* TODO(fclem) deduplicate with eevee */
-
-    /* this is factor that converts to the scene scale. focal length and sensor are expressed in mm
-     * unit.scale_length is how many meters per blender unit we have. We want to convert to blender
-     * units though because the shader reads coordinates in world space, which is in blender units.
-     * Note however that focus_distance is already in blender units and shall not be scaled here
-     * (see T48157). */
-    float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f;
-    float scale_camera = 0.001f / scale;
+    const float scale_camera = 0.001f;
     /* we want radius here for the aperture number  */
     float aperture = 0.5f * scale_camera * focal_len / fstop;
     float focal_len_scaled = scale_camera * focal_len;



More information about the Bf-blender-cvs mailing list