Maniphest T101817

EEVEE - Custom camera type has a high DoF by default
Closed, Duplicate

Assigned To
None
Authored By
Guilherme Emerich Setúbal (Senhor)
Oct 14 2022, 2:53 AM
Tags
  • BF Blender
  • EEVEE & Viewport
Subscribers
Guilherme Emerich Setúbal (Senhor)
Omar Emara (OmarSquircleArt)

Description

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: rBb292cfe5a936
Worked: 3.2.2

Short description of error
Using any objects that is not a camera will have DoF applied to it, only solution is to decrease DoF max size

Exact steps for others to reproduce the error
Ctrl + 0 at any object

Event Timeline

Guilherme Emerich Setúbal (Senhor) created this task.Oct 14 2022, 2:53 AM
Unknown Object (User) added a subscriber: Unknown Object (User).Oct 14 2022, 8:33 AM

Can confirm.
Both eevee (in EEVEE_depth_of_field_init) as well as eevee next (DepthOfField::init, DepthOfField::sync) cast whatever datatype the passed camera object is to Camera.
Then they use it's DOF attributes which seems very odd to me.
DOF should just be disabled for anything other than a camera object.

Omar Emara (OmarSquircleArt) changed the task status from Needs Triage to Confirmed.Oct 14 2022, 10:00 AM
Omar Emara (OmarSquircleArt) added a project: EEVEE & Viewport.
Omar Emara (OmarSquircleArt) added a subscriber: Omar Emara (OmarSquircleArt).

I can confirm. But you seem to indicate that it worked correctly in 3.2, which I can't confirm, and neither on 3.1. Can you double check?

Unknown Object (User) added a comment.Oct 14 2022, 10:11 AM

@Omar Emara (OmarSquircleArt) You told me not to confirm anything without first assigning the associated tags, do I need permission for that?

Omar Emara (OmarSquircleArt) added a comment.Oct 14 2022, 10:25 AM

@da.buy Not entirely sure, but I think you can assign tags without special permissions.

Guilherme Emerich Setúbal (Senhor) updated the task description.Oct 15 2022, 1:20 AM
Guilherme Emerich Setúbal (Senhor) added a comment.EditedOct 15 2022, 1:24 AM
In T101817#1432302, @Omar Emara (OmarSquircleArt) wrote:

I can confirm. But you seem to indicate that it worked correctly in 3.2, which I can't confirm, and neither on 3.1. Can you double check?

I tested 3.2.2 ( steam version ), 3.2.0, 3.1.0 ( both from blender.org ) and it worked just fine.

Unknown Object (User) added a comment.EditedOct 15 2022, 1:34 AM

@Omar Emara (OmarSquircleArt) It's a bad type cast, the behavior depends on the stats of the original object
And I can only assign people to tasks :/

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 0d14a0c5f61..caa63b9c54c 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -189,7 +189,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata),
   const DRWContextState *draw_ctx = DRW_context_state_get();
   const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
 
-  Camera *cam = (camera != NULL) ? camera->data : NULL;
+  Camera *cam = (camera != NULL && camera->type == OB_CAMERA) ? camera->data : NULL;
 
   if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) {
     RegionView3D *rv3d = draw_ctx->rv3d;
diff --git a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc
index e4c4f6f3f6f..8672cce80b6 100644
--- a/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc
+++ b/source/blender/draw/engines/eevee_next/eevee_depth_of_field.cc
@@ -44,7 +44,7 @@ void DepthOfField::init()
 {
   const SceneEEVEE &sce_eevee = inst_.scene->eevee;
   const Object *camera_object_eval = inst_.camera_eval_object;
-  const ::Camera *camera = (camera_object_eval) ?
+  const ::Camera *camera = (camera_object_eval && camera_object_eval->type == OB_CAMERA) ?
                                reinterpret_cast<const ::Camera *>(camera_object_eval->data) :
                                nullptr;
   if (camera == nullptr) {
@@ -70,7 +70,7 @@ void DepthOfField::sync()
 {
   const Camera &camera = inst_.camera;
   const Object *camera_object_eval = inst_.camera_eval_object;
-  const ::Camera *camera_data = (camera_object_eval) ?
+  const ::Camera *camera_data = (camera_object_eval && camera_object_eval->type == OB_CAMERA) ?
                                     reinterpret_cast<const ::Camera *>(camera_object_eval->data) :
                                     nullptr;
Omar Emara (OmarSquircleArt) added a comment.Oct 15 2022, 1:03 PM

@da.buy If you think this diff fixes the issue, feel free to claim the task and submit a patch. https://wiki.blender.org/wiki/Process/Contributing_Code