Compositor: glitch noise with classic Kuwahara filter in GPU compositor #113578

Closed
opened 2023-10-12 09:13:12 +02:00 by Sun Kim · 7 comments
Contributor

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2060 SUPER/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.40

Blender Version
Broken: version: 4.1.0 Alpha, branch: main, commit date: 2023-10-11 23:05, hash: fba58a148317

It happens since the variable size support for Kuwahara filter was introduced with 203559757a.

Short description of error
Glitch noise appears when using classic mode of Kuwahara filter in GPU compositor. It can be observed in both viewport and rendered image.

Viewport:

kuwahara_noise (1).png

Rendered with GPU compositor:

kuwahara_noise_render.png

Exact steps for others to reproduce the error
File: kuwahara_noise (1).blend

It happens when...

  • Using classic mode of Kuwahara filter
  • Set the size over 5.0. Even 5.00001 causes the noise. Setting the size to less than 5.0 or exactly 5.0 does not cause the noise.
  • Brighter the scene the noise gets more apparent. With low brightness the noise is very subtle but it's still there.

When the emission of the material is set to 6.0. Noise is subtle compared to the above image (in which the emission was set to 500.0 to make the noise more apparent):

kuwahara_noise_emission_6.0.png

(The black dot is camera gizmo, not part of the noise.)

When the patch for variable size support was in development the noise appeared in a different range of size, see #112946 (comment)

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2060 SUPER/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 536.40 **Blender Version** Broken: version: 4.1.0 Alpha, branch: main, commit date: 2023-10-11 23:05, hash: `fba58a148317` It happens since the variable size support for Kuwahara filter was introduced with 203559757a. **Short description of error** Glitch noise appears when using classic mode of Kuwahara filter in GPU compositor. It can be observed in both viewport and rendered image. Viewport: ![kuwahara_noise (1).png](/attachments/b6becda7-9afd-40af-8052-72450edff960) Rendered with GPU compositor: ![kuwahara_noise_render.png](/attachments/5be4a0a8-bcf3-4857-a117-688b7182699b) **Exact steps for others to reproduce the error** File: [kuwahara_noise (1).blend](/attachments/cd53fd71-da6e-4b13-9908-27990dc78f89) It happens when... - Using classic mode of Kuwahara filter - Set the size over 5.0. Even 5.00001 causes the noise. Setting the size to less than 5.0 or exactly 5.0 does not cause the noise. - Brighter the scene the noise gets more apparent. With low brightness the noise is very subtle but it's still there. When the emission of the material is set to 6.0. Noise is subtle compared to the above image (in which the emission was set to 500.0 to make the noise more apparent): ![kuwahara_noise_emission_6.0.png](/attachments/a0f6d046-00de-4e02-9be9-98f498b68e7f) (The black dot is camera gizmo, not part of the noise.) When the patch for variable size support was in development the noise appeared in a different range of size, see https://projects.blender.org/blender/blender/pulls/112946#issuecomment-1034923
Sun Kim added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-10-12 09:13:13 +02:00
Omar Emara added
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-10-12 09:55:57 +02:00
Omar Emara self-assigned this 2023-10-12 09:56:06 +02:00
Member

To clarify the behavior, we have two methods for computing Classic Kuwahara. One is faster for low sizes below 5 and one is faster for sizes above 5. The latter has precision issues due to the use of a structure called Summed Area Tables, the precision gets worst as values gets higher in the image. Using the former accurate method was hard to justify because it can be orders of magnitude slower.

I suspect we can fix that somehow with reasonable performance, but I don't have a concrete plan. SO for now, I would say clamp your input to the [0, 1] range as a workaround.

To clarify the behavior, we have two methods for computing Classic Kuwahara. One is faster for low sizes below 5 and one is faster for sizes above 5. The latter has precision issues due to the use of a structure called Summed Area Tables, the precision gets worst as values gets higher in the image. Using the former accurate method was hard to justify because it can be orders of magnitude slower. I suspect we can fix that somehow with reasonable performance, but I don't have a concrete plan. SO for now, I would say clamp your input to the `[0, 1]` range as a workaround.
Omar Emara added the
Module
VFX & Video
Interest
Compositing
labels 2023-10-12 10:02:24 +02:00
Member

#114191 attempts to solve this issue. But a full fix is probably impossible at the same performance level.

#114191 attempts to solve this issue. But a full fix is probably impossible at the same performance level.
Member

@persun We attempted to solve this by improving precision, and while the precision was improved numerically, the artifacts persisted. So it is clear to us that this can't be solved completely by improving precision.

We have two alternatives:

  1. We allow the user to use a much slower, more accurate method.
  2. We document the fact that those artifacts are expected when you have very high values in the scene. And the user should clamp to the [0, 1] range in that case.

What do you think? Is clamping sufficient for your needs?

@persun We attempted to solve this by improving precision, and while the precision was improved numerically, the artifacts persisted. So it is clear to us that this can't be solved completely by improving precision. We have two alternatives: 1) We allow the user to use a **much slower**, more accurate method. 2) We document the fact that those artifacts are expected when you have very high values in the scene. And the user should clamp to the `[0, 1]` range in that case. What do you think? Is clamping sufficient for your needs?
Author
Contributor

@OmarEmaraDev I'm actually not sure. The case above with a very high emission value was to make the noise obvious and is unlikely use case (at least for me), so I don't worry about that much of excessive noise.

But subtle noise still happens with values close to real-life use cases, and I'm not sure clamping will help much in that case.

I also noticed it happens with CPU compositor too. For some reasons it starts with size 4.0 unlike GPU's 5.0, so it makes easier to compare the images with and without the noise.

Here are renders to showcase the effects of subtle noise.

Kuwahara size 4.0, GPU compositor render: no noise

kuwahara-noise_size-4.0_gpu.png

Kuwahara size 4.0, Full frame CPU compositor render: subtle noise

kuwahara-noise_size-4.0_cpu-full-frame.png

Comparing size 4.0 CPU and GPU renders, you can see that the noise makes the top-right side of the image blurrier (or harsher if you zoom in).

With an additional light (Kuwahara size 4.0, GPU compositor render)

kuwahara-noise-case-2_size-4.0_gpu.png

With an additional light (Kuwahara size 4.0, Full frame CPU compositor render)

kuwahara-noise-case-2_size-4.0_cpu-full-frame.png

With an additional light, the noise becomes red-ish, more noticeable. It also blurs the boundary of Suzanne.


That said, I also concur that performance hit is not desirable. So I'm not actually sure, other than marking this as a known issue and note users to work around or deal with the noise somehow. (I also think the harshness made by the noise look cool if it's desirable.) Maybe bring this to the feedback thread on devtalk and ask other users will help.

@OmarEmaraDev I'm actually not sure. The case above with a very high emission value was to make the noise obvious and is unlikely use case (at least for me), so I don't worry about that much of excessive noise. But subtle noise still happens with values close to real-life use cases, and I'm not sure clamping will help much in that case. I also noticed it happens with CPU compositor too. For some reasons it starts with size 4.0 unlike GPU's 5.0, so it makes easier to compare the images with and without the noise. Here are renders to showcase the effects of subtle noise. ### Kuwahara size 4.0, GPU compositor render: no noise ![kuwahara-noise_size-4.0_gpu.png](/attachments/3e2c36ba-5a0c-4b72-ac51-44e9590e8550) ### Kuwahara size 4.0, Full frame CPU compositor render: subtle noise ![kuwahara-noise_size-4.0_cpu-full-frame.png](/attachments/0e4dc22b-6c1b-4cb7-a699-87d7ff10db38) Comparing size 4.0 CPU and GPU renders, you can see that the noise makes the top-right side of the image blurrier (or harsher if you zoom in). ### With an additional light (Kuwahara size 4.0, GPU compositor render) ![kuwahara-noise-case-2_size-4.0_gpu.png](/attachments/1b7f62ea-c1df-4564-9744-d044d1451957) ### With an additional light (Kuwahara size 4.0, Full frame CPU compositor render) ![kuwahara-noise-case-2_size-4.0_cpu-full-frame.png](/attachments/7d8508c9-42a1-4a0a-b024-43a0c830e559) With an additional light, the noise becomes red-ish, more noticeable. It also blurs the boundary of Suzanne. --- That said, I also concur that performance hit is not desirable. So I'm not actually sure, other than marking this as a known issue and note users to work around or deal with the noise somehow. (I also think the harshness made by the noise look cool if it's desirable.) Maybe bring this to the feedback thread on devtalk and ask other users will help.
Member

Can you check this build and see if the improvements to the GPU compositor resolves the noise in the base case?
https://builder.blender.org/download/patch/PR114191/

Can you check this build and see if the improvements to the GPU compositor resolves the noise in the base case? https://builder.blender.org/download/patch/PR114191/
Author
Contributor

Can you check this build and see if the improvements to the GPU compositor resolves the noise in the base case?

It reduces noise somewhat but it's still there and makes the image blurry.

Kuwahara size 5.0 - main build

kuwahara_noise_5.0_main.png

Kuwahara size 5.1 - main build

kuwahara_noise_5.1_main.png

Kuwahara size 5.1 - PR114191 build

kuwahara_noise_5.1_PR.png

> Can you check this build and see if the improvements to the GPU compositor resolves the noise in the base case? It reduces noise somewhat but it's still there and makes the image blurry. ### Kuwahara size 5.0 - main build ![kuwahara_noise_5.0_main.png](/attachments/db20139c-8f36-4b9e-b8cf-d92312051942) ### Kuwahara size 5.1 - main build ![kuwahara_noise_5.1_main.png](/attachments/12b1352c-9ff4-43ac-a502-37ecd2579ab9) ### Kuwahara size 5.1 - PR114191 build ![kuwahara_noise_5.1_PR.png](/attachments/16e38e9e-ab56-4579-a54e-05a7056c430c)
Member

Okay, at this point, I think we should add an option to change between the slow and fast methods.
But I will ask in DevTalk first. Thank you for the feedback @persun!

Okay, at this point, I think we should add an option to change between the slow and fast methods. But I will ask in DevTalk first. Thank you for the feedback @persun!
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-01-17 14:32:50 +01:00
Sign in to join this conversation.
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#113578
No description provided.