Realtime Compositor: Implement Defocus node #116391

Merged
Omar Emara merged 2 commits from OmarEmaraDev/blender:gpu-defocus-node into main 2023-12-21 12:20:49 +01:00
Member

This patch implements the defocus node for the Realtime Compositor. The
implementation does not match the CPU compositor implementation, but
uses a new formulation that is more physically accurate and consistent
with Blender's render engines.

The existing CPU implementation is questionable starting from its circle
of confusion calculation, to the morphological operations applied on the
CoC radius, to ignoring the maximum CoC radius in the search kernel, and
ending with the threshold parameter used to reduce artifacts. Therefore,
it should be reimplemented along with this same implementation using a
more consistent methodology.

EEVEE and Workbench already have a GPU defocus method, which can be
ported to the compositor and used as the preview defocus algorithm.
While this implementation will be updated to be a more accurate method
that produces the same structure as the ported EEVEE implementation.

The new formulation ignores the threshold parameter for now, as well as
the preview parameter.

This patch implements the defocus node for the Realtime Compositor. The implementation does not match the CPU compositor implementation, but uses a new formulation that is more physically accurate and consistent with Blender's render engines. The existing CPU implementation is questionable starting from its circle of confusion calculation, to the morphological operations applied on the CoC radius, to ignoring the maximum CoC radius in the search kernel, and ending with the threshold parameter used to reduce artifacts. Therefore, it should be reimplemented along with this same implementation using a more consistent methodology. EEVEE and Workbench already have a GPU defocus method, which can be ported to the compositor and used as the preview defocus algorithm. While this implementation will be updated to be a more accurate method that produces the same structure as the ported EEVEE implementation. The new formulation ignores the threshold parameter for now, as well as the preview parameter.
Omar Emara added the
Interest
Compositing
Module
VFX & Video
labels 2023-12-20 19:20:25 +01:00
Omar Emara added 1 commit 2023-12-20 19:20:35 +01:00
909d524cfc Realtime Compositor: Implement Defocus node
This patch implements the defocus node for the Realtime Compositor. The
implementation does not match the CPU compositor implementation, but
uses a new formulation that is more physically accurate and consistent
with Blender's render engines.

The existing CPU implementation is questionable starting from its circle
of confusion calculation, to the morphological operations applied on the
CoC radius, and ending with the threshold parameter used to reduce bad
artifacts. Therefore, it should be reimplemented along with this same
implementation using a more consistent methodology.

EEVEE and Workbench already have a GPU defocus method, which can be
ported to the compositor and used as the preview defocus algorithm.
While this implementation will be updated to be a more accurate method
that produces the same structure as the ported EEVEE implementation.

The new formulation ignores the threshold parameter for now, as well as
the preview parameter.
Author
Member

I more or less gave up on reverse-engineering the method used by the CPU node and opted to just use a method that is more consistent with the rest of Blender. Then we can update both implementations to use a more consistent methodology.



Ground truth (Cycles) vs GPU compositor:

20231220-194446.png

Ground truth (Cycles) vs Full Frame compositor:

20231220-194419.png

Workbench DOF vs GPU compositor:

20231220-195055.png

I more or less gave up on reverse-engineering the method used by the CPU node and opted to just use a method that is more consistent with the rest of Blender. Then we can update both implementations to use a more consistent methodology. --- --- Ground truth (Cycles) vs GPU compositor: ![20231220-194446.png](/attachments/829bd47b-1ca2-4291-af2f-a8cef5b6f167) Ground truth (Cycles) vs Full Frame compositor: ![20231220-194419.png](/attachments/bbe2458d-137a-4425-8d75-7068cfa217bb) Workbench DOF vs GPU compositor: ![20231220-195055.png](/attachments/1fc9e2a8-227f-4c7e-864d-dd7ddfa2d018)
Omar Emara requested review from Brecht Van Lommel 2023-12-20 19:29:38 +01:00
Brecht Van Lommel approved these changes 2023-12-20 19:49:59 +01:00

For vector blur I guess you would do the same, use the EEVEE (Next) implementation instead?

Trying to port that CPU implementation to the GPU does not seems particularly useful, it's complicated and doesn't give particularly good results.

For vector blur I guess you would do the same, use the EEVEE (Next) implementation instead? Trying to port that CPU implementation to the GPU does not seems particularly useful, it's complicated and doesn't give particularly good results.
Author
Member

I haven't looked at the EEVEE implementation yet, but we might indeed do that directly, as I already looked at the Vector Blur code and it seem it would be rather hard to port as well.

I haven't looked at the EEVEE implementation yet, but we might indeed do that directly, as I already looked at the Vector Blur code and it seem it would be rather hard to port as well.
Omar Emara added 1 commit 2023-12-21 12:19:42 +01:00
Omar Emara merged commit e055db6605 into main 2023-12-21 12:20:49 +01:00
Omar Emara deleted branch gpu-defocus-node 2023-12-21 12:20:51 +01:00
Brecht Van Lommel added the
Interest
VFX & Video
label 2024-01-15 13:28:11 +01:00

Comment for testing, please ignore.

Comment for testing, please ignore.
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 project
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#116391
No description provided.