Compositor: Rewrite and optimize Double Edge Mask node #117545
No reviewers
Labels
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#117545
Loading…
Reference in New Issue
No description provided.
Delete Branch "OmarEmaraDev/blender:rewrite-double-edge-mask-node"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This patch rewrites and optimizes the Double Edge Mask node to be orders
of magnitude faster. For a 1k complex mask, it is 650x faster, while for
a 1k simple mask, it is only 50x faster.
This improvement is attributed to the use of a new Jump Flooding
algorithm as well as multi-threading, matching the GPU implementation.
The result of the new implementation differs in that the boundaries of
the masks are now identified as the last pixels inside the mask.
@Sergey I still need to figure out and give more details on the differences, the old code is a bit convoluted, just a tiny bit ☺️. But the base code should be ready for review.
Just reading this out of curiosity (nice speedup!) and noticed one thing. Array references should typically become
MutableSpan
instead. That clarifies that functions don't care about ownership, and makes them container-agnostic.@ -5,2 +5,4 @@
#include <cstdlib>
#include "BLI_math_vector.hh"
#include "BLI_math_vector_types.hh"
BLI_math_vector.hh
includesBLI_math_vector_types.hh
out of necessity, no need to write them both here@ -1283,2 +130,2 @@
MEM_freeN(gbuf);
}
const int2 size = int2(this->get_width(), this->get_height());
Array<int2> inner_boundary = Array<int2>(size_t(size.x) * size.y);
Can be written more simply as
Thanks @HooglyBoogly! Do you happened to know if the
jump_flooding
function will have "Return value optimization", or will it copy the array on return? I am worried that the pointer and deference operations will confuse the compiler somehow.The test failures is due to two things:
Another difference that is not related to test failure is:
More generally, by looking at the history of the node, there is no adjacency information, so the UI and documentation are probably wrong. And it seems the node was added as a workaround for feathered masks. See https://archive.blender.org/wiki/index.php/User:Xgl_asyliax/ and https://blenderartists.org/t/yay-double-edge-matte-might-get-in-to-trunk/523603/15.
The simple use-case in the
double_edge_mask.blend
seems to work very nicely with this patch.I was doing some digging of the failing tests, trying to identify the cause, or the practicality of it. The inner and outer masks are barely touching there, so i've expanded the inner mast a bit in the
double_edge_mask_tricky.blend
. Intuitively one would probably expect smooth feather, with soft transition from white in the center to the black at the outer edges of the feather. However, the new implementation doesn't have such smooth edges. Is it something that is covered by the difference in the second point of the tests faulures?The code seems fine, and the behavioir seems to be more intuitive.
Perhaps we should add some Dilate node in the regression tests to make inner and outer masks to actually intersect.