Issues with HDRIs and render result pixel values that exceed half float limits #98575

Open
opened 2022-06-03 14:06:53 +02:00 by Christoph Lohr · 47 comments

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

Blender Version
Broken: version: 3.1.2, branch: master, commit date: 2022-03-31 17:40, hash: cc66d1020c
(Also tested in latest 3.3 Alpha)

Short description of error
Some lookdev HDRI's give the scene a colored tint, that also does not disappear after lowering the strength

Exact steps for others to reproduce the error
I imported this HDRI to preview lighting in my Eevee scene: https://polyhaven.com/a/lenong_2

At first, this looks okay in blender:
Normal_bright.png

But after lowering the strength, you will notice that there is a yellow light that should not be there, as well as a white spot from where the sun used to be, even if strength=0
Normal_dark.png

I found a workaround by adjusting the exposure of the HDRi in advance by -1 in affinity photo. This makes the image only a tiny bit darker, but the end result is as you would expect it.
No yellow light, no sun.
Fixed_dark.png

I tried this with another HDRi from HDRIhaven (from another creator, this one specifically https://polyhaven.com/a/ehingen_hillside) and the issue also existed there.

Here is the blend file for testing:
HDRI_Test.blend
And the HDRI fixed by me
lenong_2_1k_fixed.hdr

**System Information** Operating system: Windows-10-10.0.22000-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.15 **Blender Version** Broken: version: 3.1.2, branch: master, commit date: 2022-03-31 17:40, hash: `cc66d1020c` (Also tested in latest 3.3 Alpha) **Short description of error** Some lookdev HDRI's give the scene a colored tint, that also does not disappear after lowering the strength **Exact steps for others to reproduce the error** I imported this HDRI to preview lighting in my Eevee scene: https://polyhaven.com/a/lenong_2 At first, this looks okay in blender: ![Normal_bright.png](https://archive.blender.org/developer/F13130576/Normal_bright.png) But after lowering the strength, you will notice that there is a yellow light that should not be there, as well as a white spot from where the sun used to be, even if strength=0 ![Normal_dark.png](https://archive.blender.org/developer/F13130583/Normal_dark.png) I found a workaround by adjusting the exposure of the HDRi in advance by -1 in affinity photo. This makes the image only a tiny bit darker, but the end result is as you would expect it. No yellow light, no sun. ![Fixed_dark.png](https://archive.blender.org/developer/F13130593/Fixed_dark.png) I tried this with another HDRi from HDRIhaven (from another creator, this one specifically https://polyhaven.com/a/ehingen_hillside) and the issue also existed there. Here is the blend file for testing: [HDRI_Test.blend](https://archive.blender.org/developer/F13130598/HDRI_Test.blend) And the HDRI fixed by me [lenong_2_1k_fixed.hdr](https://archive.blender.org/developer/F13130600/lenong_2_1k_fixed.hdr)
Author

Added subscriber: @Thane5

Added subscriber: @Thane5

#101652 was marked as duplicate of this issue

#101652 was marked as duplicate of this issue

#101186 was marked as duplicate of this issue

#101186 was marked as duplicate of this issue

#98959 was marked as duplicate of this issue

#98959 was marked as duplicate of this issue

#98780 was marked as duplicate of this issue

#98780 was marked as duplicate of this issue

Added subscriber: @deadpin

Added subscriber: @deadpin

I can confirm that "something" is wrong for both Eevee and Cycles, but not for version 3.1.2, and not exactly matching the problem described.

Currently using:
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 511.09

  • I was not able to reproduce the "yellow" problem in any version using Strengths of 0.1, 0.01, or 0.
  • However, I am observing black pixels for the overexposed portions of the sun in 3.2 and 3.3 that wasn't present in 3.1.2.
. 3.1.2 3.2 beta 3.3 alpha
Eevee issue_3.1.2-eevee.png issue_3.2-eevee.png issue_3.3-eevee.png
Cycles issue_3.1.2-cycles.png issue_3.2-cycles.png issue_3.3-cycles.png
I can confirm that "something" is wrong for both Eevee and Cycles, but not for version 3.1.2, and not exactly matching the problem described. Currently using: Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 511.09 - I was not able to reproduce the "yellow" problem in any version using Strengths of 0.1, 0.01, or 0. - However, I am observing black pixels for the overexposed portions of the sun in 3.2 and 3.3 that wasn't present in 3.1.2. | . | 3.1.2 | 3.2 beta | 3.3 alpha | | --- | --- | --- | --- | | Eevee | ![issue_3.1.2-eevee.png](https://archive.blender.org/developer/F13133023/issue_3.1.2-eevee.png) | ![issue_3.2-eevee.png](https://archive.blender.org/developer/F13133025/issue_3.2-eevee.png) | ![issue_3.3-eevee.png](https://archive.blender.org/developer/F13133027/issue_3.3-eevee.png) | | Cycles | ![issue_3.1.2-cycles.png](https://archive.blender.org/developer/F13133030/issue_3.1.2-cycles.png) | ![issue_3.2-cycles.png](https://archive.blender.org/developer/F13133032/issue_3.2-cycles.png) | ![issue_3.3-cycles.png](https://archive.blender.org/developer/F13133034/issue_3.3-cycles.png) |
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

I can't reproduce either issues in 3.3.

I can't reproduce either issues in 3.3.
Author

Interesting that you found these black spots. I tested it again with both 3.1 and 3.3 (alpha) on my laptop, and there none of the issues were present.

For my own sanity i also tested it again on my main PC, this time with clean Blender installations of 3.1/3.3. Sadly the yellow glow issue was unchanged.

Interesting that you found these black spots. I tested it again with both 3.1 and 3.3 (alpha) on my laptop, and there none of the issues were present. For my own sanity i also tested it again on my main PC, this time with clean Blender installations of 3.1/3.3. Sadly the yellow glow issue was unchanged.

Added subscriber: @mano-wii

Added subscriber: @mano-wii

I can't reproduce the problem either.
It must be something specific on NVidia GPUs.

@Thane5, from the web page shown (https://polyhaven.com/a/lenong_2`), what specs of the download HDRI (EXR, 4k...)? And does that make any difference?

I can't reproduce the problem either. It must be something specific on NVidia GPUs. @Thane5, from the web page shown (https://polyhaven.com/a/lenong_2`), what specs of the download HDRI (EXR, 4k...)? And does that make any difference?
Author

HDR/EXR makes no difference. Higher resolutions make the yellow glow slightly weaker, but at 4k it is still very clearly visible (So far i my tests were at 1k).

HDR/EXR makes no difference. Higher resolutions make the yellow glow slightly weaker, but at 4k it is still very clearly visible (So far i my tests were at 1k).

Added subscriber: @brecht

Added subscriber: @brecht

The black pixels have values exceeding 65504, which is the maximum that can be stored in half float. Render results are stored as half float textures for display, and the way such high values are treated may depend on the driver. We may need to manually clamp it, though it would be unfortunate to pay the performance cost for that.

For image textures, an option to use full float in Eevee was added in #73086 (Eevee: strange discrepancy in handling of 32 bit floating point textures). We should check if that still works, but it's intentional that this defaults to half float as that works and reduces memory for most textures.

The black pixels have values exceeding 65504, which is the maximum that can be stored in half float. Render results are stored as half float textures for display, and the way such high values are treated may depend on the driver. We may need to manually clamp it, though it would be unfortunate to pay the performance cost for that. For image textures, an option to use full float in Eevee was added in #73086 (Eevee: strange discrepancy in handling of 32 bit floating point textures). We should check if that still works, but it's intentional that this defaults to half float as that works and reduces memory for most textures.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Can confirm.

@brecht: would you consider this a TODO then?

Can confirm. @brecht: would you consider this a TODO then?

I think it could be considered a bug.

I think it could be considered a bug.
Brecht Van Lommel changed title from Brighness issue with some HDRIs in Eevee to Issues with HDRIs and render result pixel values that exceed half float limits 2022-06-07 13:20:15 +02:00
Member
Added subscribers: @Leftunderatree, @EAW, @Harvester, @PratikPB2123, @Fernando-Alcala

Here on:

Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.96

Blender version: 3.2.0, branch: master, commit date: 2022-06-08 10:22, hash: e05e1e3691

Using the provided sample scene and HDRi, I cannot reproduce those two issues, the black spot on the Sun, and the yellow tint nor in Eevee neither in Cycles. Yes, there is some "yellowness" at lower exposure values but nothing comparable to the level experienced by those user.

Here on: Operating system: Windows-10-10.0.19043-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 512.96 Blender version: 3.2.0, branch: master, commit date: 2022-06-08 10:22, hash: `e05e1e3691` Using the provided sample scene and HDRi, I cannot reproduce those two issues, the black spot on the Sun, and the yellow tint nor in Eevee neither in Cycles. Yes, there is some "yellowness" at lower exposure values but nothing comparable to the level experienced by those user.

Yes, there appear to be some differences in how the drivers or GPUs deal with half float clamping.

Yes, there appear to be some differences in how the drivers or GPUs deal with half float clamping.

Added subscriber: @SebBlender

Added subscriber: @SebBlender

Added subscriber: @pmoursnv

Added subscriber: @pmoursnv

@pmoursnv, the NVIDIA OpenGL driver does not appear to clamp to the half float max value when uploading a float buffer to be stored as half float on the GPU, instead setting the value to zero. Other drivers do seem to clamp it. Do you know if that would be considered a driver bug?

We can do the clamping ourselves, but would prefer to avoid the performance impact of that. Or perhaps we can do the conversion to half float ourselves with SIMD optimizations, which maybe has similar performance to what the driver is doing, not sure if that conversion happens CPU or GPU side.

@pmoursnv, the NVIDIA OpenGL driver does not appear to clamp to the half float max value when uploading a float buffer to be stored as half float on the GPU, instead setting the value to zero. Other drivers do seem to clamp it. Do you know if that would be considered a driver bug? We can do the clamping ourselves, but would prefer to avoid the performance impact of that. Or perhaps we can do the conversion to half float ourselves with SIMD optimizations, which maybe has similar performance to what the driver is doing, not sure if that conversion happens CPU or GPU side.
Member

The driver does perform the usual float2half conversion, which for values exceeding the half maximum results in half infinity, and that is what is stored in the texture. During the gpu_shader_display_transform_frag shader that is translated to zero however (specifically inside "OCIO_to_display" function, where a 3D LUT is applied, which doesn't work for infinity since that doesn't translate into meaningful LUT coordinates) and so it ends up showing as zero on screen.
I wouldn't consider this a driver bug, since the OpenGL spec does not actually specify clamping behavior here (section 8.5 in the OpenGL 4.6 core spec specifies that clamping occurs when the data format is floating-point and the texture internalformat is an integer format or normalized fixed-point format, but nothing for when it is a floating-point format). So in my opinion the driver behaves correctly here.
To fix it is probably sufficient to simply filter out infinity values inside the gpu_shader_display_transform_frag shader.

The driver does perform the usual float2half conversion, which for values exceeding the half maximum results in half infinity, and that is what is stored in the texture. During the gpu_shader_display_transform_frag shader that is translated to zero however (specifically inside "OCIO_to_display" function, where a 3D LUT is applied, which doesn't work for infinity since that doesn't translate into meaningful LUT coordinates) and so it ends up showing as zero on screen. I wouldn't consider this a driver bug, since the OpenGL spec does not actually specify clamping behavior here (section 8.5 in the OpenGL 4.6 core spec specifies that clamping occurs when the data format is floating-point and the texture internalformat is an integer format or normalized fixed-point format, but nothing for when it is a floating-point format). So in my opinion the driver behaves correctly here. To fix it is probably sufficient to simply filter out infinity values inside the gpu_shader_display_transform_frag shader.

Added subscribers: @fclem, @Jeroen-Bakker

Added subscribers: @fclem, @Jeroen-Bakker

Thanks, I should have figured out it ends up as infinity.

For displaying images with color management we can clamp in the shader quite easily. For Eevee/Workbench it may not be ideal to add clamping for every texture read, and since interpolation/mipmapping happens before we can clamp the results may not be good.

Probably we should clamp before when uploading the texture to the GPU, but maybe @fclem or @Jeroen-Bakker has a different idea.

Thanks, I should have figured out it ends up as infinity. For displaying images with color management we can clamp in the shader quite easily. For Eevee/Workbench it may not be ideal to add clamping for every texture read, and since interpolation/mipmapping happens before we can clamp the results may not be good. Probably we should clamp before when uploading the texture to the GPU, but maybe @fclem or @Jeroen-Bakker has a different idea.
Member

Added subscriber: @Alaska

Added subscriber: @Alaska
Contributor

Added subscriber: @Raimund58

Added subscriber: @Raimund58

Added subscriber: @Zeastin

Added subscriber: @Zeastin
Member

Added subscriber: @Eary

Added subscriber: @Eary
Member

I cannot speak from cycles PoV, but from shaders perspective I would add clamping in the shaders as inf and nan triggers undefined behavior on OpenGL. Data pre-processing on the CPU might be less performant as it adds another data translation pass.

I cannot speak from cycles PoV, but from shaders perspective I would add clamping in the shaders as inf and nan triggers undefined behavior on OpenGL. Data pre-processing on the CPU might be less performant as it adds another data translation pass.

I don't think clamping in the shader will work well since it would happen after interopolation/mipmapping, so pixels that don't exceed the limit would be affected or there may be NaNs.

I don't think clamping in the shader will work well since it would happen after interopolation/mipmapping, so pixels that don't exceed the limit would be affected or there may be NaNs.
Member

You’re right, think we could add clamping to the gpu texture creation image_gpu unit. Would also need a helper function in imbuf to clamp a part of rect_float.

In some cases additional buffer should be created to not modify the original data. Fe opener files that do not need any conversion to scene ref. Also for raw and data spaces….

You’re right, think we could add clamping to the gpu texture creation image_gpu unit. Would also need a helper function in imbuf to clamp a part of rect_float. In some cases additional buffer should be created to not modify the original data. Fe opener files that do not need any conversion to scene ref. Also for raw and data spaces….
Member

Added subscriber: @LABS

Added subscriber: @LABS

This issue was referenced by 0386737097

This issue was referenced by 0386737097716870236d5e480f8ae1ec13e0b7a7

This issue was referenced by 872a45f42b

This issue was referenced by 872a45f42bc5a582fac59e9cd24239ee25821bff
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Jeroen Bakker self-assigned this 2022-10-12 08:56:44 +02:00
Member

Hi @Thane5

could you check on the latest builds tomorrow if this issue has been fixed, or that we need some more tweaking?
Thanks!

Hi @Thane5 could you check on the latest builds tomorrow if this issue has been fixed, or that we need some more tweaking? Thanks!

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'

The fix only affected the image engine used for display in the image editor, but this is also an issue for image textures.

The fix only affected the image engine used for display in the image editor, but this is also an issue for image textures.
Author

I opened the files above in a build from today (14.10.2022) and the issue is still present

I opened the files above in a build from today (14.10.2022) and the issue is still present
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'
Member

Thx @fclem ! (closing this was caused by the backporting to LTS)

Thx @fclem ! (closing this was caused by the backporting to LTS)
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:12:35 +01:00

I had this exact issue of the sun disc turning black at the end of a cycles render. After reading in this thread about certain values reaching infinity/NaN etc., I decided to lower the value of the sun intensity setting of the Nishita Sky Texture. I don't know why it works, but lowering the intensity setting until renders look right fixed it for me (a value of less than 2 in my case).

I had this exact issue of the sun disc turning black at the end of a cycles render. After reading in this thread about certain values reaching infinity/NaN etc., I decided to lower the value of the sun intensity setting of the Nishita Sky Texture. I don't know why it works, but lowering the intensity setting until renders look right fixed it for me (a value of less than 2 in my case).
Jeroen Bakker added this to the EEVEE & Viewport project 2023-04-06 08:07:52 +02:00
Jeroen Bakker removed their assignment 2023-04-06 08:07:59 +02:00
Jeroen Bakker added this to the 3.6 LTS milestone 2023-04-06 08:08:05 +02:00
Jeroen Bakker self-assigned this 2023-04-06 08:08:46 +02:00
Jeroen Bakker removed this from the 3.6 LTS milestone 2024-03-18 13:53:59 +01:00
Jeroen Bakker removed their assignment 2024-03-18 13:54:03 +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 Assignees
17 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#98575
No description provided.