Renderings vom 2.9 LTS produce different results than 3.0 #93710

Closed
opened 2021-12-05 17:10:52 +01:00 by Daniel Thiele · 19 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 472.12

Blender Version
Broken: version: 3.0
Worked: 2.93.5, branch: master, commit date: 2021-10-05 12:04, hash: a791bdabd0

Short description of error
Render looks broken in 3.0 with denoising

Exact steps for others to reproduce the error
Download https://drive.google.com/file/d/10VwtBGw_wD3nBIFMGLUW8qooYDEs8sta/view?usp=sharing

Render it with the settings in that exact same resolution with denoising enablebed. The denoised image hast some strange light shining on the humans in the very front row. the noisy image does not have that. It works as expected in 2.9 LTS

This image shows the artifact. It's the "yellow" arms in the bottom of the image that only shows up after denoising.
#93710 Denoising Artifacts.jpg


Here is a simplified file and set of steps provided by @Alaska

  1. Create a new .blend file, add an object to it that fills the entire view of the camera, and change the render engine to Cycles.
  2. Change the render resolution to 9464 x 4320 (I couldn't reproduce the issue with other render resoltuions)
  3. Ensure Adaptive Sampling is on. You can reduce the Max Samples parameter to something like 64 to speed up renders.
  4. Enabling Denoising for final renders and change the denoiser to OptiX with the passes set to Albedo and Normal
  5. Ensure Use Tiling is enabled and the tile size is less than the render resolution.
  6. Go to the Render Properties tab and enable ONLY these render passes.
  • Combined
  • Z
  • Diffuse Color
  • Emission
  • Ambient Occlusion
  1. Render the image and notice the artifact.

Here is a file with steps 1-6 done for you.
#93710 Simplified.blend

The artifact is the horizontal line near the top of this image:
#93710 - Simplified Artifact.jpg

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 472.12 **Blender Version** Broken: version: 3.0 Worked: 2.93.5, branch: master, commit date: 2021-10-05 12:04, hash: `a791bdabd0` **Short description of error** Render looks broken in 3.0 with denoising **Exact steps for others to reproduce the error** Download https://drive.google.com/file/d/10VwtBGw_wD3nBIFMGLUW8qooYDEs8sta/view?usp=sharing Render it with the settings in that exact same resolution with denoising enablebed. The denoised image hast some strange light shining on the humans in the very front row. the noisy image does not have that. It works as expected in 2.9 LTS This image shows the artifact. It's the "yellow" arms in the bottom of the image that only shows up after denoising. ![#93710 Denoising Artifacts.jpg](https://archive.blender.org/developer/F12693890/T93710_Denoising_Artifacts.jpg) --- Here is a simplified file and set of steps provided by @Alaska > 1. Create a new .blend file, add an object to it that fills the entire view of the camera, and change the render engine to Cycles. > 2. Change the render resolution to `9464 x 4320` (I couldn't reproduce the issue with other render resoltuions) > 3. Ensure `Adaptive Sampling` is on. You can reduce the `Max Samples` parameter to something like 64 to speed up renders. > 4. Enabling Denoising for final renders and change the denoiser to `OptiX` with the passes set to `Albedo and Normal` > 5. Ensure `Use Tiling` is enabled and the tile size is less than the render resolution. > 6. Go to the `Render Properties` tab and enable ONLY these render passes. > - Combined > - Z > - Diffuse Color > - Emission > - Ambient Occlusion > 7. Render the image and notice the artifact. > > Here is a file with steps 1-6 done for you. > [#93710 Simplified.blend](https://archive.blender.org/developer/F12694668/T93710_Simplified.blend) > > The artifact is the horizontal line near the top of this image: > ![#93710 - Simplified Artifact.jpg](https://archive.blender.org/developer/F12694636/T93710_-_Simplified_Artifact.jpg)
Author

Added subscriber: @DMan

Added subscriber: @DMan

#95814 was marked as duplicate of this issue

#95814 was marked as duplicate of this issue
Member

Added subscribers: @pmoursnv, @Alaska

Added subscribers: @pmoursnv, @Alaska
Member

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
Member

I am able to reproduce this issue on my setup. However I can't figure out what's wrong because if I enable Denoising Data so I can look at it and investigate what's wrong, the issue goes away.

Here is an image showing the artifacts (Notice that the people in the bottom portion of the image have yellow "glowing" arms):
#93710 Denoising Artifacts.jpg

CC @pmoursnv as it appears to be limited to the OptiX denoiser.

System Information
Operating system: Linux-5.15.0-2-amd64-x86_64-with-glibc2.32 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 495.44
Blender version: 3.1.0 Alpha, branch: master, commit date: 2021-12-04 01:26, hash: 5ef5a9fc24

I am able to reproduce this issue on my setup. However I can't figure out what's wrong because if I enable `Denoising Data` so I can look at it and investigate what's wrong, the issue goes away. Here is an image showing the artifacts (Notice that the people in the bottom portion of the image have yellow "glowing" arms): ![#93710 Denoising Artifacts.jpg](https://archive.blender.org/developer/F12693890/T93710_Denoising_Artifacts.jpg) CC @pmoursnv as it appears to be limited to the OptiX denoiser. **System Information** Operating system: Linux-5.15.0-2-amd64-x86_64-with-glibc2.32 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 495.44 Blender version: 3.1.0 Alpha, branch: master, commit date: 2021-12-04 01:26, hash: `5ef5a9fc24`
Member

Added subscriber: @Sergey

Added subscriber: @Sergey
Member

I will also CC @Sergey because upon further testing the issue mostly disappears if Use tiling is disabled or the tile size is increased to cover the entire image.

Note: I also tested with Blender 3.0 and the same thing I've noticed also occur there.

I will also CC @Sergey because upon further testing the issue mostly disappears if `Use tiling` is disabled or the tile size is increased to cover the entire image. Note: I also tested with Blender 3.0 and the same thing I've noticed also occur there.
Member

I have simplified the file and got some steps to reproduce it from scratch.

  1. Create a new .blend file, add an object to it that fills the entire view of the camera, and change the render engine to Cycles.
  2. Change the render resolution to 9464 x 4320 (I couldn't reproduce the issue with other render resoltuions)
  3. Ensure Adaptive Sampling is on. You can reduce the Max Samples parameter to something like 64 to speed up renders.
  4. Enabling Denoising for final renders and change the denoiser to OptiX with the passes set to Albedo and Normal
  5. Ensure Use Tiling is enabled and the tile size is less than the render resolution.
  6. Go to the Render Properties tab and enable ONLY these render passes.
  • Combined
  • Z
  • Diffuse Color
  • Emission
  • Ambient Occlusion
  1. Render the image and notice the artifact.

Here is a file with steps 1-6 done for you.
#93710 Simplified.blend

The artifact is the horizontal line near the top of this image:
#93710 - Simplified Artifact.jpg

I have simplified the file and got some steps to reproduce it from scratch. 1. Create a new .blend file, add an object to it that fills the entire view of the camera, and change the render engine to Cycles. 2. Change the render resolution to `9464 x 4320` (I couldn't reproduce the issue with other render resoltuions) 3. Ensure `Adaptive Sampling` is on. You can reduce the `Max Samples` parameter to something like 64 to speed up renders. 4. Enabling Denoising for final renders and change the denoiser to `OptiX` with the passes set to `Albedo and Normal` 5. Ensure `Use Tiling` is enabled and the tile size is less than the render resolution. 6. Go to the `Render Properties` tab and enable ONLY these render passes. - Combined - Z - Diffuse Color - Emission - Ambient Occlusion 7. Render the image and notice the artifact. Here is a file with steps 1-6 done for you. [#93710 Simplified.blend](https://archive.blender.org/developer/F12694668/T93710_Simplified.blend) The artifact is the horizontal line near the top of this image: ![#93710 - Simplified Artifact.jpg](https://archive.blender.org/developer/F12694636/T93710_-_Simplified_Artifact.jpg)
Patrick Mours self-assigned this 2021-12-09 12:37:03 +01:00
Member

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'

Changed status from 'Needs Developer To Reproduce' to: 'Confirmed'
Member

So the problem here is a traditional case of integer overflow. What is happening is that for denoising, Cycles loads the entire huge image into a GPU buffer. Since 1766549418 this now theoretically works with the OptiX denoiser by splitting up this image buffer into smaller tiles that are denoised separately. But there is a catch: the width, height and rowStrideInBytes values passed to the denoiser are 32-bit integers and unfortunately there is code to calculate the size of the entire image by multiplying height (or a y coordinate close to that) and rowStrideInBytes. In this case the result is larger than what a 32-bit integer can hold and therefore overflows, causing the denoiser to read/write data at bogus locations, which shows up as artifacts. rowStrideInBytes is affected by the width of the image and how many render passes are active, hence why the problem goes away if you reduce the width or disable enough render passes (including hidden render passes that one does not select in the GUI, e.g. enabling auto tiling adds a hidden render pass, adaptive sampling adds two hidden render passes). To fix this the calculation will need to be done in 64-bit (by casting to 64-bit before multiplying).

Unfortunately this needs fixing in both Cycles and inside the driver, so it's not a quick thing to do ...

So the problem here is a traditional case of integer overflow. What is happening is that for denoising, Cycles loads the entire huge image into a GPU buffer. Since 1766549418 this now theoretically works with the OptiX denoiser by splitting up this image buffer into smaller tiles that are denoised separately. But there is a catch: the `width`, `height` and `rowStrideInBytes` values passed to the denoiser are 32-bit integers and unfortunately there is code to calculate the size of the entire image by multiplying `height` (or a y coordinate close to that) and `rowStrideInBytes`. In this case the result is larger than what a 32-bit integer can hold and therefore overflows, causing the denoiser to read/write data at bogus locations, which shows up as artifacts. `rowStrideInBytes` is affected by the width of the image and how many render passes are active, hence why the problem goes away if you reduce the width or disable enough render passes (including hidden render passes that one does not select in the GUI, e.g. enabling auto tiling adds a hidden render pass, adaptive sampling adds two hidden render passes). To fix this the calculation will need to be done in 64-bit (by casting to 64-bit before multiplying). Unfortunately this needs fixing in both Cycles and inside the driver, so it's not a quick thing to do ...
Contributor

Added subscriber: @Raimund58

Added subscriber: @Raimund58

Added subscriber: @Wovchick

Added subscriber: @Wovchick

Added subscriber: @Renderbicks

Added subscriber: @Renderbicks

@pmoursnv, Think is better (for the time being, at least) copy an implementation of the tiled denoiser to optix/device_impl.cpp so that we don't bump driver version requirement.

Additionally to the integer overflow in the optixUtilDenoiserInvokeTiled we might have an overflow in the denoiser related kernels. I've tried addressing those, but is only the first tile which is denoised correctly. There is something I am missing and wouldn't mind a second pair of eyes. Attached current state of the patch. It is a bit excessive on int64 usage in the optixUtilDenoiserInvokeTiled, in theory should be enough to cast before multiplication, I was just trying to eliminate any doubt of me missing some overflow.

optix_int_overflow.patch

@pmoursnv, Think is better (for the time being, at least) copy an implementation of the tiled denoiser to `optix/device_impl.cpp` so that we don't bump driver version requirement. Additionally to the integer overflow in the `optixUtilDenoiserInvokeTiled` we might have an overflow in the denoiser related kernels. I've tried addressing those, but is only the first tile which is denoised correctly. There is something I am missing and wouldn't mind a second pair of eyes. Attached current state of the patch. It is a bit excessive on int64 usage in the `optixUtilDenoiserInvokeTiled`, in theory should be enough to cast before multiplication, I was just trying to eliminate any doubt of me missing some overflow. [optix_int_overflow.patch](https://archive.blender.org/developer/F12884273/optix_int_overflow.patch)
Member

I was able to get rid of the artifacts with just this patch and a driver that has the driver-side fixes (they made it into the last r510 release, so need at least Windows 511.79 or Linux 510.54):

--- "a/optix_denoiser_tiling.h"
+++ "b/optix_denoiser_tiling.h"
@@ -147,15 +147,15 @@ inline OptixResult optixUtilDenoiserSplitImage(
                                       std::min( tileWidth, input.width - copied_x );

             OptixUtilDenoiserImageTile tile;
-            tile.input.data               = input.data + ( inp_y - inputOffsetY ) * input.rowStrideInBytes
-                                            + ( inp_x - inputOffsetX ) * inPixelStride;
+            tile.input.data               = input.data + (size_t)( inp_y - inputOffsetY ) * input.rowStrideInBytes
+                                            + (size_t)( inp_x - inputOffsetX ) * inPixelStride;
             tile.input.width              = inp_w;
             tile.input.height             = inp_h;
             tile.input.rowStrideInBytes   = input.rowStrideInBytes;
             tile.input.pixelStrideInBytes = input.pixelStrideInBytes;
             tile.input.format             = input.format;

-            tile.output.data               = output.data + inp_y * output.rowStrideInBytes + inp_x * outPixelStride;
+            tile.output.data               = output.data + (size_t)inp_y * output.rowStrideInBytes + (size_t)inp_x * outPixelStride;
             tile.output.width              = copy_x;
             tile.output.height             = copy_y;
             tile.output.rowStrideInBytes   = output.rowStrideInBytes;

But had last tried this a while ago, and had since been waiting for the driver to release, so will need to recheck too.

I was able to get rid of the artifacts with just this patch and a driver that has the driver-side fixes (they made it into the last r510 release, so need at least Windows 511.79 or Linux 510.54): ``` --- "a/optix_denoiser_tiling.h" +++ "b/optix_denoiser_tiling.h" @@ -147,15 +147,15 @@ inline OptixResult optixUtilDenoiserSplitImage( std::min( tileWidth, input.width - copied_x ); OptixUtilDenoiserImageTile tile; - tile.input.data = input.data + ( inp_y - inputOffsetY ) * input.rowStrideInBytes - + ( inp_x - inputOffsetX ) * inPixelStride; + tile.input.data = input.data + (size_t)( inp_y - inputOffsetY ) * input.rowStrideInBytes + + (size_t)( inp_x - inputOffsetX ) * inPixelStride; tile.input.width = inp_w; tile.input.height = inp_h; tile.input.rowStrideInBytes = input.rowStrideInBytes; tile.input.pixelStrideInBytes = input.pixelStrideInBytes; tile.input.format = input.format; - tile.output.data = output.data + inp_y * output.rowStrideInBytes + inp_x * outPixelStride; + tile.output.data = output.data + (size_t)inp_y * output.rowStrideInBytes + (size_t)inp_x * outPixelStride; tile.output.width = copy_x; tile.output.height = copy_y; tile.output.rowStrideInBytes = output.rowStrideInBytes; ``` But had last tried this a while ago, and had since been waiting for the driver to release, so will need to recheck too.

In #93710#1312853, @pmoursnv wrote:
I was able to get rid of the artifacts with just this patch and a driver that has the driver-side fixes (they made it into the last r510 release, so need at least Windows 511.79 or Linux 510.54):

Have you also tested the latest Studio driver 511.65?

> In #93710#1312853, @pmoursnv wrote: > I was able to get rid of the artifacts with just this patch and a driver that has the driver-side fixes (they made it into the last r510 release, so need at least Windows 511.79 or Linux 510.54): Have you also tested the latest Studio driver 511.65?
Member

Like I said, you need at least 511.79 on Windows, 511.65 is too old.

Like I said, you need at least 511.79 on Windows, 511.65 is too old.

This issue was referenced by 8cdee3a6d4

This issue was referenced by 8cdee3a6d4306fa7cae73b9f7bcd761e90f39937

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
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
8 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#93710
No description provided.