Render: allow to select an entire collection to set the focal point in the Depth of Field settings in the Camera properties #119869

Open
dema wants to merge 4 commits from dema/blender:dof-collection into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
First-time contributor

Add the field Focus on Collection in the Depth of Field settings in the Camera properties. This new feature was requested by the community in this post.

Problem

Actually Blender allowed setting a focal point by specifying either the distance from the camera or selecting an object. Selecting an object sets the focal point to its location. However, this method posed challenges with collections representing objects. Collections consist of multiple components, and focusing on a single component could yield undesired effects. The problem could be addressed adding an empty in the desired position and setting the focal point to its location. But this approach is difficult to apply when the object (collection) is animated, because also the empty should be animated properly.

Solution

The new "Focus on Collection" field dynamically sets the focal point to the average location of objects within a collection, accommodating nested collections. This feature ensures the focal point updates with animation, keeping complex objects in focus. This functionality is pivotal for scenes with narrow fields of view, where keeping the entire object in focus is challenging.

The new settings are presented here with an use case similar to the one described here: a pair of glasses is represented as a collection with three objects: lenses, left temple and right temple. The scene has an extremely narrow field of view, so that keeping the entire object in focus is challenging. The first image shows the result when the focal point is set to the "temple" object:
focus_temple.png

While in the second image it is set to the "glasses" collection:
focus_glasses.png

The short clip below shows how the new Depth of Field settings work:
.
While the .blend file used for the demonstration is available here.

Add the field `Focus on Collection` in the `Depth of Field` settings in the Camera properties. This new feature was requested by the community in [this post](https://blender.community/c/rightclickselect/W8ZE/). ### Problem Actually Blender allowed setting a focal point by specifying either the distance from the camera or selecting an object. Selecting an object sets the focal point to its location. However, this method posed challenges with collections representing objects. Collections consist of multiple components, and focusing on a single component could yield undesired effects. The problem could be addressed adding an empty in the desired position and setting the focal point to its location. But this approach is difficult to apply when the object (collection) is animated, because also the empty should be animated properly. ### Solution The new "Focus on Collection" field dynamically sets the focal point to the average location of objects within a collection, accommodating nested collections. This feature ensures the focal point updates with animation, keeping complex objects in focus. This functionality is pivotal for scenes with narrow fields of view, where keeping the entire object in focus is challenging. The new settings are presented here with an use case similar to the one described [here](https://blender.community/c/rightclickselect/W8ZE/): a pair of glasses is represented as a collection with three objects: lenses, left temple and right temple. The scene has an extremely narrow field of view, so that keeping the entire object in focus is challenging. The first image shows the result when the focal point is set to the "temple" object: ![focus_temple.png](/attachments/6e8fe0c2-2f0a-4015-b8e0-75484127a6d1) While in the second image it is set to the "glasses" collection: ![focus_glasses.png](/attachments/60759c7d-7fba-4687-a455-de2cc505b983) The short clip below shows how the new Depth of Field settings work: <video src="/attachments/340048d4-d580-4020-9ae4-cb81cfc15a29" title="demo.mp4" controls></video>. While the .blend file used for the demonstration is available [here]([demo.blend](/attachments/4b1ea3ec-bb39-4228-bcaa-6694e8b35936)).
dema added 3 commits 2024-03-25 11:38:26 +01:00
Iliya Katushenock added this to the Render & Cycles project 2024-03-25 12:16:37 +01:00
Iliya Katushenock reviewed 2024-03-25 12:17:43 +01:00
@ -1875,2 +1875,4 @@
build_object(-1, camera->dof.focus_object, DEG_ID_LINKED_INDIRECTLY, false);
}
if (camera->dof.focus_collection != nullptr) {
build_collection(nullptr,camera->dof.focus_collection);

Hi, can you run make format in root folder of your blender fork?

Hi, can you run `make format` in root folder of your blender fork?
Author
First-time contributor

Ok done, thank you. Now the format should be ok

Ok done, thank you. Now the format should be ok
mod_moder marked this conversation as resolved
dema added 1 commit 2024-03-25 17:19:39 +01:00
Merge conflict checking is in progress. Try again in few moments.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u dof-collection:dema-dof-collection
git checkout dema-dof-collection
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#119869
No description provided.