All renders have slight graininess (both Eevee and Cycles) #113719

Open
opened 2023-10-14 14:34:48 +02:00 by TomSpicer · 8 comments

System Information
Tested on Asus Rog G752VS
Operating system: Linux Mint 21.2
Graphics card: NVIDIA Corporation GP104BM [GeForce GTX 1070 Mobile]

Blender Version
Broken: 3.6.4 (2023-09-25 13:24), Blender 4.1.0 - Alpha ( October 13, 16:03:29 , 4050b0d6df )

Any render has graininess (high frequency inconsistent pixel brightness), also with Eeevee, even rendering just a background or an emissive plane with no lights in the scene.

Exact steps for others to reproduce the error

With a default startup, change the background color to something like (0,1,0) to make the graininess clearer when enhancing the rendered image in an image editor.

Problem seems absent when using "AgX" for "Viewport transform" in Blender 4.1.0 - Alpha ( October 13, 16:03:29 , 4050b0d6df ) but present for other modes and all modes from older Blender versions.

To see the graininess with a naked eye, you'll need to enhance the image, like in GIMP as illustrated.

**System Information** Tested on Asus Rog G752VS Operating system: Linux Mint 21.2 Graphics card: NVIDIA Corporation GP104BM [GeForce GTX 1070 Mobile] **Blender Version** Broken: 3.6.4 (2023-09-25 13:24), Blender 4.1.0 - Alpha ( October 13, 16:03:29 , 4050b0d6dfdb ) Any render has graininess (high frequency inconsistent pixel brightness), also with Eeevee, even rendering just a background or an emissive plane with no lights in the scene. **Exact steps for others to reproduce the error** With a default startup, change the background color to something like (0,1,0) to make the graininess clearer when enhancing the rendered image in an image editor. Problem seems absent when using "AgX" for "Viewport transform" in Blender 4.1.0 - Alpha ( October 13, 16:03:29 , 4050b0d6dfdb ) but present for other modes and all modes from older Blender versions. To see the graininess with a naked eye, you'll need to enhance the image, like in GIMP as illustrated.
TomSpicer added the
Severity
Normal
Status
Needs Triage
Type
Report
labels 2023-10-14 14:34:49 +02:00
Member

Blender applies dithering to the imageby default to reduce banding. This may be the issue you're experiencing.

To turn off dithering:

  1. Open the Properties Editor.
  2. Go to the Output tab.
  3. In the Post Processing tab, turn dithering down to 0.

Does this help/resolve your issue?

Blender applies dithering to the imageby default to reduce banding. This may be the issue you're experiencing. To turn off dithering: 1. Open the Properties Editor. 2. Go to the `Output` tab. 3. In the `Post Processing` tab, turn dithering down to 0. Does this help/resolve your issue?
Alaska added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2023-10-14 15:42:06 +02:00
Author

Blender applies dithering to the imageby default to reduce banding. This may be the issue you're experiencing.

To turn off dithering:

  1. Open the Properties Editor.
  2. Go to the Output tab.
  3. In the Post Processing tab, turn dithering down to 0.

Does this help/resolve your issue?

Why yes, you seem to have found the feature which causes the issue: setting dithering to 0 does seem to eliminate the graininess. However, I don't think this should be happening even with having default dithering. Dithering shouldn't impact flat colors. For example if only a single color background is rendered, or a flat plane with a single color emissive material like here, there's no two or more distinct colored pixels involved which a dithering filter would convert to a grainy noise for banding removal purposes.
So it seems to me like dithering filter code has a bug or limitation to properly deal with flat shaded features in the render: one may want to have dithering On for it to be applied to any gradients in the render, while also needing to have flat shaded features in the render, without one impacting the quality of the other.

As a reference, I'm providing all the dithering methods the image editor GIMP has. Out of all the options, only "Random" seems to add random graininess to flat colored features. Maybe Blender is using a similar algorithm, but I'm not sure why, something like Floyd-Steinberg or Blue Noise seems to make more sense.

> Blender applies dithering to the imageby default to reduce banding. This may be the issue you're experiencing. > > To turn off dithering: > 1. Open the Properties Editor. > 2. Go to the `Output` tab. > 3. In the `Post Processing` tab, turn dithering down to 0. > > Does this help/resolve your issue? Why yes, you seem to have found the feature which causes the issue: setting dithering to 0 does seem to eliminate the graininess. However, I don't think this should be happening even with having default dithering. Dithering shouldn't impact flat colors. For example if only a single color background is rendered, or a flat plane with a single color emissive material like here, there's no two or more distinct colored pixels involved which a dithering filter would convert to a grainy noise for banding removal purposes. So it seems to me like dithering filter code has a bug or limitation to properly deal with flat shaded features in the render: one may want to have dithering On for it to be applied to any gradients in the render, while also needing to have flat shaded features in the render, without one impacting the quality of the other. As a reference, I'm providing all the dithering methods the image editor GIMP has. Out of all the options, only "Random" seems to add random graininess to flat colored features. Maybe Blender is using a similar algorithm, but I'm not sure why, something like Floyd-Steinberg or Blue Noise seems to make more sense.

I also noticed this strange pattern in my renders and had no idea where it came from or how to get rid of it. Turns out it was render.dither_intensity, thanks.
1.gif

I also noticed this strange pattern in my renders and had no idea where it came from or how to get rid of it. Turns out it was `render.dither_intensity`, thanks. ![1.gif](/attachments/c72a3655-f09b-4ef9-9628-839184a82e76)
68 MiB
Author

I also noticed this strange pattern in my renders and had no idea where it came from or how to get rid of it. Turns out it was render.dither_intensity, thanks.
1.gif

Sounds like a relatively new feature that has been aded and enabled silently , I don't remember this artifact before.

> I also noticed this strange pattern in my renders and had no idea where it came from or how to get rid of it. Turns out it was `render.dither_intensity`, thanks. > ![1.gif](/attachments/c72a3655-f09b-4ef9-9628-839184a82e76) Sounds like a relatively new feature that has been aded and enabled silently , I don't remember this artifact before.
Member

Changing to "Needs information from Developers". The graininess is caused by dithering. And the dithering can be turned off. However, the behavior of the dither appears to be weird according to the reports from you two. So I'd like a developer that works in this area to comment on this.

Changing to "Needs information from Developers". The graininess is caused by dithering. And the dithering can be turned off. However, the behavior of the dither appears to be weird according to the reports from you two. So I'd like a developer that works in this area to comment on this.

Just chiming in with the history: the dithering feature has existed for quite some time but it was first set to 1.0 in Blender 2.80 as part of #54943 (302fea6b61). It was 0.0 in prior versions.

Just chiming in with the history: the dithering feature has existed for quite some time but it was first set to 1.0 in Blender 2.80 as part of #54943 (302fea6b6113f480f5961ddef4a4b967e873f0ef). It was 0.0 in prior versions.
Member

I agree that the dithering algorithm should only affect those areas with changing colors, it should only apply to image regions that has features within some certain thresholds.

I agree that the dithering algorithm should only affect those areas with changing colors, it should only apply to image regions that has features within some certain thresholds.

I have programmed some dithering myself as part of an image filter, and I can say that Blender's dithering algorithm makes no sense. It simply adds noise to the image. That's not dithering.

Noise is the simplest (and arguably the best) method of regulating a dithering pattern, since it requires no textures or lookup tables and also doesn't add any repeating, distracting patterns. To implement it properly, the algorithm, assuming it's being applied to one channel of one pixel at a time, needs to do the following: (This algorithm is inspired by dithering in digital audio processing.)

Input: A floating-point value, such as one channel of one pixel, from a rendered or composited image. Let's call it F.

First, calculate the 2 closest values to F that the output image format can use. Let's call them X and Y. For instance, if F = 0.499, and the output is an 8-bit integer, then X = 127 and Y = 128. (8-bit integers range from 0 to 255 while the input F ranges from 0 to 1, so we need to multiply F by 255 first, then round it down to get X, or round it up to get Y.)

Now, calculate how far the scaled F is between X and Y. Let's call that number P. For the example above, we get P = 0.245 (aka 24.5%). We now generate a random number between 0.0 (inclusive) and 1.0 (exclusive). Let's call it R.

And lastly: if P < R then return X else return Y That means there's a 24.5% chance to output X and a 75.5% chance to output Y.

You will notice that if the input number F can be represented exactly with the chosen output format (such as F = 0.0), this algorithm will always return the same output. AS IT SHOULD!


Of course, there is one last thing to consider: The user can control how strong the dithering should be. I do not have a good proposal for properly implementing this. Ideally, it should modify the likelihood that F is dithered at all, as opposed to simply outputting the single closest possible output. So if the dithering setting is low, and F is much closer to X than to Y, then the random number generator is skipped and X is returned as output.


Here is the entire algorithm in one piece of pseudocode:

/// Quantizes a single value (one channel of one pixel) for 8-bit images.
/// param F: The value to quantize for the output image.
int quantize_dithered_8bit(float F)
{
  F *= 255.f;

  if (F <= 0.f) return 0;

  if (F >= 255.f) return 255;

  float X = floor(F);
  float Y = ceil(F);
  float P = F - X;
  float R = random_float(0.f, 1.f);

  if (P < R)
    return X;
  else
    return Y;
}

/// Quantizes a single value (one channel of one pixel) for 16-bit images.
/// param F: The value to quantize for the output image.
int quantize_dithered_16bit(float F)
{
  F *= 65535.f;

  if (F <= 0.f) return 0;

  if (F >= 65535.f) return 65535.f;

  float X = floor(F);
  float Y = ceil(F);
  float P = F - X;
  float R = random_float(0.f, 1.f);

  if (P < R)
    return X;
  else
    return Y;
}

PS: Dithering shouldn't even be an option for floating-point image formats. It simply doesn't make sense.

I have programmed some dithering myself as part of an image filter, and I can say that Blender's dithering algorithm makes no sense. It simply adds noise to the image. That's not dithering. Noise is the simplest (and arguably the best) method of regulating a dithering pattern, since it requires no textures or lookup tables and also doesn't add any repeating, distracting patterns. To implement it *properly*, the algorithm, assuming it's being applied to one channel of one pixel at a time, needs to do the following: *(This algorithm is inspired by dithering in digital audio processing.)* **Input:** A floating-point value, such as one channel of one pixel, from a rendered or composited image. Let's call it `F`. First, calculate the 2 closest values to `F` that the output image format can use. Let's call them `X` and `Y`. For instance, if `F = 0.499`, and the output is an 8-bit integer, then `X = 127` and `Y = 128`. (8-bit integers range from 0 to 255 while the input `F` ranges from 0 to 1, so we need to multiply `F` by 255 first, then round it down to get `X`, or round it up to get `Y`.) Now, calculate how far the scaled `F` is between `X` and `Y`. Let's call that number `P`. For the example above, we get `P = 0.245` (aka 24.5%). We now generate a random number between 0.0 (inclusive) and 1.0 (exclusive). Let's call it `R`. And lastly: `if P < R then return X else return Y` That means there's a 24.5% chance to output X and a 75.5% chance to output Y. You will notice that if the input number `F` can be represented **exactly** with the chosen output format (such as `F = 0.0`), this algorithm will always return the same output. **AS IT SHOULD!** --- Of course, there is one last thing to consider: The user can control how strong the dithering should be. I do not have a good proposal for properly implementing this. Ideally, it should modify the likelihood that `F` is dithered at all, as opposed to simply outputting the single closest possible output. So if the dithering setting is low, and `F` is much closer to `X` than to `Y`, then the random number generator is skipped and `X` is returned as output. --- Here is the entire algorithm in one piece of pseudocode: ```c /// Quantizes a single value (one channel of one pixel) for 8-bit images. /// param F: The value to quantize for the output image. int quantize_dithered_8bit(float F) { F *= 255.f; if (F <= 0.f) return 0; if (F >= 255.f) return 255; float X = floor(F); float Y = ceil(F); float P = F - X; float R = random_float(0.f, 1.f); if (P < R) return X; else return Y; } /// Quantizes a single value (one channel of one pixel) for 16-bit images. /// param F: The value to quantize for the output image. int quantize_dithered_16bit(float F) { F *= 65535.f; if (F <= 0.f) return 0; if (F >= 65535.f) return 65535.f; float X = floor(F); float Y = ceil(F); float P = F - X; float R = random_float(0.f, 1.f); if (P < R) return X; else return Y; } ``` --- PS: Dithering shouldn't even be an option for floating-point image formats. It simply doesn't make sense.
Bart van der Braak added
Type
Bug
and removed
Type
Report
labels 2024-08-14 13:07:31 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
6 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#113719
No description provided.