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
This commit is contained in:
2019-05-22 15:22:10 +02:00
parent 8b52619ff8
commit 04fa0511ca
3 changed files with 3 additions and 24 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;