Shader: Clamp inputs of various nodes #120390
No reviewers
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120390
Loading…
Reference in New Issue
No description provided.
Delete Branch "Alaska/blender:clamp-other-shaders"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Clamp some of the inputs of the Glossy BSDF, Glass BSDF, Sheen BSDF,
and Subsurface Scattering nodes to improve consistency
between render engines and to avoid unexpected results.
Some parameters are left unclamped for artistic uses,
but there is a chance they will break with abnormal values.
Glossy BSDF:
Values above 1 are already handled gracefully, but I thought
I would clamp it anyway.
Glass BSDF:
Sheen BSDF:
somewhere else. This was just done for code consistency
(E.G. Some of these existed in EEVEE and OSL, but not SVM).
Subsurface Scattering:
And clamp the color input to 0..inf on all four.
The clamped used here aligns with the clamping used in
a15f9e49ec
I investigated this due to a report about the rendering issue with high brightness glossy BSDFs made here: #120349
There are concerns from some people that we are clamping some inputs unnecessarily, and removing the ability for some users to experiment with non-realistic values for artistic effects. I'm just bringing this point up for consideration.
I will note that some values don't need clamping some of the time. For example with the Glossy BSDF, Glass BSDF, and Subsurface Scattering node, the issues with colours brighter than 1 only occur in specific modes (Multiscatter GGX and Random Walk), while others are fine (E.G. GGX and Christen-Burley can handle these values just fine). So we can clamp the color input when using the modes that behave weirdly, but leave it unclamped on the modes that behave alright.
This approach wasn't taken with the Principled BSDF just for simplicity and consistency sake.
Shouldn't it affect NPR users?
Sorry, it's not clear what your question is. So I'll provide information that hopefully helps you.
Some people will use unrealistic values (E.G. A base color with a brightness greater than 1) as inputs for certain nodes for artistic effects. This pull request will remove the ability to do that on some nodes. This is being done to avoid situations where the shader breaks or provides unexpected results with the weird input values.
A discussion needs to be had about "Should we remove the ability to create these artistic effects, just to avoid broken shaders in specific situations?" Or "Should we be more fine grained with the inputs we clamp? For example with the Glossy BSDF, it breaks with high brightness color inputs, only when using Multiscatter GGX. So should we clamp the input for Multiscatter GGX and leave GGX unclamped? So if users want to create unrealistic effects, they can with the right settings."
As a user, I would ask that you keep clamping to a minimum. I would rather have more freedom, even if that means that I have the freedom to break things.
@Alaska Are there some issues which those values can cause if unclamped, like
nan
pixels?The thing is, with changes like this someone's render will start looking different, it will be perceived as a regression, and in own experience it creates more frustration than it brings solutions. So I'd be quite careful about introducing such changes.
I don't believe any of them cause NaN pixels. But some do produce unexpected results.
Here are some examples:
Glossy BSDF - Color input:
When large values are input into the Glossy BSDF color input, it produces extremely incorrect results (The black pixels are negative values). How large the value needs to be to cause this issue is dependent on the roughness. This same issue plagues the Glass BSDF.
This issue only occurs with Multiscatter GGX, so if we wanted too, we could only clamp this value when using Multiscatter GGX.
Subsurface scattering node - Color input:
When large values are input into the Subsurface scattering node color input, it turns dark, while reflecting more indirect light (it falls back to diffuse for indirect light). This is an unexpected result and isn't useful for anyone. So just clamp it to avoid bug reports about it. This issue only plagues random walk and random walk skin, so maybe we could only do clamping on random walk?
This same effect can be achieved with a simple light path node setup.
The clamping of roughness to 0..1 is mainly to align with EEVEE (Cycles supports negative roughness due to
sqr(roughness)
, while EEVEE didn't). These materials did not support roughnesses >1 anyway so clamping that is just to be "safe". If a user would like negative roughness back, they can add a absolute math node.Clamping negative SSS scale is just to be safe. Negative scale doesn't appear to do anything.
And clamping the negative color Sheen was just to be safe. Negative color Sheen doesn't do anything.
Just a quick recap of changes and their impact to make things clear:
Glossy BSDF:
Glass BSDF:
Sheen BSDF:
Subsurface Scattering:
When I say there are no changes in scenes, I mean I couldn't find any in my testing.
Many of the "this change does nothing and is just to be safe" changes were made to align with the Principled BSDF component. The Principled BSDF needed some of these changes due to issues with the layering system around the middle of Blender 4.0 development.
It would have been better to clamp everything from the beginning, but I'd rather not break compatibility with existing shaders much or making things inconvenient for NPR, even if they rely on undefined behavior.
I think clamping the roughness and radius is ok, but would rather leave colors completely unchanged.
The individual BSDF nodes are also a bit more low level than Principled BSDF and we don't need to be so strict I think.
@blender-bot build
Thanks for the changes.
It looks good, but there is a merge conflict to be resolved.
I have rebased against main.
But I've also clamped
Glossy BSDF
,Glass BSDF
,Sheen BSDF
,Subsurface Scattering
colour input to [0..inf].They were already clamped like this in EEVEE, and partially clamped like this in SVM. So I'm just adding extra clamps to make everything consistent.
However as a side effect of this change, we lose negative coloured glass in Cycles (EEVEE didn't support it). Just say if you'd like this reverted.
c104f44ceb
toa0cc68a220
@blender-bot build
Ok, let's do it like this.