From 274da967229778e03347d6be6ca61f602c9b8c65 Mon Sep 17 00:00:00 2001 From: Alaska Date: Mon, 17 Jun 2024 17:42:38 +0200 Subject: [PATCH] Render: Clamp minimum DOF focus distance Clamp DOF focus distance to a minimum of 1e-5. This is to primarily stop focus distances of 0 being used which would lead to issues in future code changes. Pull Request: https://projects.blender.org/blender/blender/pulls/123310 --- intern/cycles/scene/camera.cpp | 2 +- source/blender/blenkernel/intern/camera.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/cycles/scene/camera.cpp b/intern/cycles/scene/camera.cpp index e53eafb8fff..7ef7bd6729c 100644 --- a/intern/cycles/scene/camera.cpp +++ b/intern/cycles/scene/camera.cpp @@ -395,7 +395,7 @@ void Camera::update(Scene *scene) /* depth of field */ kcam->aperturesize = aperturesize; - kcam->focaldistance = focaldistance; + kcam->focaldistance = max(focaldistance, 1e-5f); kcam->blades = (blades < 3) ? 0.0f : blades; kcam->bladesrotation = bladesrotation; diff --git a/source/blender/blenkernel/intern/camera.cc b/source/blender/blenkernel/intern/camera.cc index 7c39038c8bf..b1d9f78138f 100644 --- a/source/blender/blenkernel/intern/camera.cc +++ b/source/blender/blenkernel/intern/camera.cc @@ -290,9 +290,9 @@ float BKE_camera_object_dof_distance(const Object *ob) ob->object_to_world().location(), cam->dof.focus_object->object_to_world().location()); } - return fabsf(dot_v3v3(view_dir, dof_dir)); + return fmax(fabsf(dot_v3v3(view_dir, dof_dir)), 1e-5f); } - return cam->dof.focus_distance; + return fmax(cam->dof.focus_distance, 1e-5f); } float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)