Compositor: Re-write Pixelate node for CPU compositor #117223

Merged
Sergey Sharybin merged 3 commits from Sergey/blender:compositor_pixelate into main 2024-01-18 11:31:06 +01:00

The old implementation was a simple rounding operation and was not
implemented for full-frame compositor.

The issue with the old implementation is that it will not give
satisfactory results for images with high frequency details,
including cases when is used for a preview on Cycles render with
low number of samples. Additionally, when applied on animated
footage it produces very noisy result.

The new algorithm uses an explicit pixel size setting, which allows
the node to be used on its own, without need to have scale-down and
scale-up nodes. It also uses neighbour averaging, which produces
better looking result during animation and noisy input images.

The old tiled compositor setup will render without changes with
this change. This commit does not include modifications in the GPU
compositor implementation.

Ref #88150

The old implementation was a simple rounding operation and was not implemented for full-frame compositor. The issue with the old implementation is that it will not give satisfactory results for images with high frequency details, including cases when is used for a preview on Cycles render with low number of samples. Additionally, when applied on animated footage it produces very noisy result. The new algorithm uses an explicit pixel size setting, which allows the node to be used on its own, without need to have scale-down and scale-up nodes. It also uses neighbour averaging, which produces better looking result during animation and noisy input images. The old tiled compositor setup will render without changes with this change. This commit does not include modifications in the GPU compositor implementation. Ref #88150
Sergey Sharybin added 1 commit 2024-01-17 12:14:25 +01:00
dd5848b56c Compositor: Re-write Pixelate node for CPU compositor
The old implementation was a simple rounding operation and was not
implemented for full-frame compositor.

The issue with the old implementation is that it will not give
satisfactory results for images with high frequency details,
including cases when is used for a preview on Cycles render with
low number of samples. Additionally, when applied on animated
footage it produces very noisy result.

The new algorithm uses an explicit pixel size setting, which allows
the node to be used on its own, without need to have scale-down and
scale-up nodes. It also uses neighbour averaging, which produces
better looking result during animation and noisy input images.

The old tiled compositor setup will render without changes with
this change. This commit does not include modifications in the GPU
compositor implementation.
Author
Owner

The .blend files and render results of the old and the new algorithms for comparison.

The .blend files and render results of the old and the new algorithms for comparison.
Author
Owner

One thing to mention here, is that there Manuel had implementation of the node for the full-frame compositor as a patch (available in the archive). It has an interesting feature of supporting variable pixel size, and independent X and Y sizes. However, it has the same issues as the tile-based pixelate when it comes to animation and high-frequency details because it only does one input sample per output sample.

One thing to mention here, is that there Manuel had implementation of the node for the full-frame compositor as a patch (available in the [archive](https://archive.blender.org/developer/D11801)). It has an interesting feature of supporting variable pixel size, and independent X and Y sizes. However, it has the same issues as the tile-based pixelate when it comes to animation and high-frequency details because it only does one input sample per output sample.
Sergey Sharybin added this to the Compositing project 2024-01-17 12:29:56 +01:00
Sergey Sharybin requested review from Omar Emara 2024-01-17 12:31:58 +01:00
Member

I was thinking that maybe we make the pixel size a float. The integer part of the float is done similar to this patch, while the fractional part will be done with rounded sampling of the result of integer pixelation. But this is a good start for simplicity.

Performance-wise, would it make sense to do successive 2x2 average downsampling until we reach the desired pixel size. I suspect this will be better for larger pixel sizes.

I was thinking that maybe we make the pixel size a float. The integer part of the float is done similar to this patch, while the fractional part will be done with rounded sampling of the result of integer pixelation. But this is a good start for simplicity. Performance-wise, would it make sense to do successive 2x2 average downsampling until we reach the desired pixel size. I suspect this will be better for larger pixel sizes.
Sergey Sharybin added 1 commit 2024-01-17 12:43:18 +01:00
ce2fa90c7f Fix crash when Pixelate is applied on Depth pass
The node tried to be smart w.r.t the socket type.

While with the previous simple pass-through of rounded coordinate
did not require any special code for such flexibility, now it will
be more tricky to support it.

There are likely to be other sources of slowdown and memory usage,
and the node is likely to be used on a color anyway, so choose simpler
way of dealing with the data type.
Author
Owner

Performance-wise, would it make sense to do successive 2x2 average downsampling until we reach the desired pixel size. I suspect this will be better for larger pixel sizes.

I am not sure how to implement pixel sizes which are not power of two with such approach. It also feels that it will make it more difficult to support variable size in the future.

> Performance-wise, would it make sense to do successive 2x2 average downsampling until we reach the desired pixel size. I suspect this will be better for larger pixel sizes. I am not sure how to implement pixel sizes which are not power of two with such approach. It also feels that it will make it more difficult to support variable size in the future.
Omar Emara approved these changes 2024-01-17 17:02:12 +01:00
Omar Emara left a comment
Member

Just this small change, otherwise looks good.

I will do the GPU implementation and look into optimizing this a bit.

Just this small change, otherwise looks good. I will do the GPU implementation and look into optimizing this a bit.
@ -8308,0 +8310,4 @@
PropertyRNA *prop;
prop = RNA_def_property(srna, "pixel_size", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "custom1");
Member

Specify a range to avoid negative input.

Specify a range to avoid negative input.
Sergey Sharybin added 1 commit 2024-01-17 17:58:46 +01:00
Sergey Sharybin merged commit baab14ca38 into main 2024-01-18 11:31:06 +01:00
Sergey Sharybin deleted branch compositor_pixelate 2024-01-18 11:31:08 +01:00
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#117223
No description provided.