Cycles: NaN pixels in Glossy and Transmissive Passes with roughness values near 0.0266 #125750

Closed
opened 2024-08-01 04:35:01 +02:00 by AgentA1cr · 5 comments

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: Quadro K5100M/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 426.78

Blender Version
Broken: version: 4.2.0, branch: blender-v4.2-release, commit date: 2024-07-16 06:20, hash: a51f293548ad
Worked: Unknown. I've checked as far back as 3.6

Short description of error
In the Cycles engine, Roughness values between 0.026592 and 0.026679 cause Not a Number pixels to appear in the Direct and Indirect Glossy and Transmissive passes.
Similar to blender/blender#108125. Unlike that bug, this one appears in both CPU and GPU rendering. It appears in the Glossy passes with or without Transmission>0, but only appears in the Transmission passes when Transmission>0.
image
image

Exact steps for others to reproduce the error
Open attached .blend file. (Glossy Glitch Test.blend)
Render Image
Open Compositing tab
A large number of pixels are NaN, as shown by the node network.

**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: Quadro K5100M/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 426.78 **Blender Version** Broken: version: 4.2.0, branch: blender-v4.2-release, commit date: 2024-07-16 06:20, hash: `a51f293548ad` Worked: Unknown. I've checked as far back as 3.6 **Short description of error** In the Cycles engine, Roughness values between 0.026592 and 0.026679 cause Not a Number pixels to appear in the Direct and Indirect Glossy and Transmissive passes. Similar to blender/blender#108125. Unlike that bug, this one appears in both CPU and GPU rendering. It appears in the Glossy passes with or without Transmission>0, but only appears in the Transmission passes when Transmission>0. <img width="750" alt="image" src="attachments/724d52ab-4ace-46d1-8775-27d6f6f86bba"> <img width="842" alt="image" src="attachments/3cbaa076-dd5d-4996-beeb-8cadfb0446f8"> **Exact steps for others to reproduce the error** Open attached .blend file. ([Glossy Glitch Test.blend](/attachments/53fc87e6-cc93-4f0c-8011-cb179b6bb5a5)) Render Image Open Compositing tab A large number of pixels are NaN, as shown by the node network.
AgentA1cr added the
Type
Report
Severity
Normal
Status
Needs Triage
labels 2024-08-01 04:35:02 +02:00
Member

I tested a few different configurations and here are my observation.

CPU Rendering on Windows with a AMD Ryzen 5 5600: Has the issue
GPU Rendering on Windows with a AMD RX 7800XT: Has the issue

CPU Rendering on Linux with a AMD Ryzen 5 5600: No issue
CPU Rendering on macOS with a M1 Pro: No issue
GPU Rendering on macOS with a M1 Pro: No issue
GPU rendering on Windows with a NVIDIA RTX 4090: No issue
GPU Rendering on Windows with a Intel Arc A750: No issue

If there is a configuration that could be tested but that isn't listed (E.g. GPU rendering on Linux, it just means I didn't test it)

I tested a few different configurations and here are my observation. CPU Rendering on Windows with a AMD Ryzen 5 5600: Has the issue GPU Rendering on Windows with a AMD RX 7800XT: Has the issue CPU Rendering on Linux with a AMD Ryzen 5 5600: No issue CPU Rendering on macOS with a M1 Pro: No issue GPU Rendering on macOS with a M1 Pro: No issue GPU rendering on Windows with a NVIDIA RTX 4090: No issue GPU Rendering on Windows with a Intel Arc A750: No issue If there is a configuration that could be tested but that isn't listed (E.g. GPU rendering on Linux, it just means I didn't test it)
Alaska added
Module
Render & Cycles
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-08-01 05:39:33 +02:00
Member

I've done some debugging into this.

The issue originates from this line of code:

return alpha2 / (M_PI_F * sqr(1.0f + (alpha2 - 1.0f) * cos_NH2));

# alpha2 = 5.01428076e-07
# cos_NH2 = 1.00000048
# Which basically results in 0.0000005 / 0.0 which becomes infinity or NaN.

return alpha2 / (M_PI_F * sqr(1.0f + (alpha2 - 1.0f) * cos_NH2));

The code gets there through the path of:

integrate_surface_bsdf_bssrdf_bounce()
surface_shader_bsdf_sample_closure()
bsdf_sample()
bsdf_microfacet_ggx_sample()
bsdf_microfacet_sample()
bsdf_D()

I should note that bsdf_D is only called if the material is !m_singular. And m_singular is basically alpha_2 < 5.0e-7. Considering that alpha_2 is right on the verge of this threshold, I think that increasing the threshold may be the way to fix this issue.

Edit: Increasing the threshold probably isn't the best approach. The minimum threshold I found that worked without issues was 8e-7, which is high enough to create a sudden change when transitioning from low roughness to something higher than that value.

I've done some debugging into this. The issue originates from this line of code: ``` return alpha2 / (M_PI_F * sqr(1.0f + (alpha2 - 1.0f) * cos_NH2)); # alpha2 = 5.01428076e-07 # cos_NH2 = 1.00000048 # Which basically results in 0.0000005 / 0.0 which becomes infinity or NaN. ``` https://projects.blender.org/blender/blender/src/commit/c5023681412b122f3b16624881a5d0f84f85b917/intern/cycles/kernel/closure/bsdf_microfacet.h#L518 The code gets there through the path of: ``` integrate_surface_bsdf_bssrdf_bounce() surface_shader_bsdf_sample_closure() bsdf_sample() bsdf_microfacet_ggx_sample() bsdf_microfacet_sample() bsdf_D() ``` I should note that `bsdf_D` is only called if the material is `!m_singular`. And `m_singular` is basically `alpha_2 < 5.0e-7`. Considering that `alpha_2` is right on the verge of this threshold, I think that increasing the threshold may be the way to fix this issue. Edit: Increasing the threshold probably isn't the best approach. The minimum threshold I found that worked without issues was `8e-7`, which is high enough to create a sudden change when transitioning from low roughness to something higher than that value.
Contributor

For these particular values the NaN can be avoided by rewriting that line as:

return alpha2 / (M_PI_F * sqr((1.0f - cos_NH2) + alpha2 * cos_NH2));

That looks like an overall improvement to floating point precision in any case, but I don't know if that is enough. I don't have access to a system with the issue at the moment.

For these particular values the NaN can be avoided by rewriting that line as: `return alpha2 / (M_PI_F * sqr((1.0f - cos_NH2) + alpha2 * cos_NH2));` That looks like an overall improvement to floating point precision in any case, but I don't know if that is enough. I don't have access to a system with the issue at the moment.
Member

@david494 Thanks for the suggestion. We've identified the main thing for the fix (cos_NH2 should be 1.0 at the maximum). Once that is merged, feel free to open a new pull request for increased precision.

@david494 Thanks for the suggestion. We've identified the main thing for the fix (cos_NH2 should be 1.0 at the maximum). Once that is merged, feel free to open a new pull request for increased precision.
Member

@david494 I believe your suggestion would fix #114940, would you like to make a PR and change BSDF_ROUGHNESS_SQ_THRESH to 2e-10?

@david494 I believe your suggestion would fix #114940, would you like to make a PR and change `BSDF_ROUGHNESS_SQ_THRESH` to `2e-10`?
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-08-02 16:29:09 +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
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
4 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#125750
No description provided.