Cycles/EEVEE: Clamp various shader inputs on the Principled BSDF #112774

Manually merged
Brecht Van Lommel merged 2 commits from Alaska/blender:clamp-layers into main 2023-09-25 19:53:53 +02:00
Member

Clamp various shader inputs in the Principled BSDF to avoid
physically incorrect materials, and to fix some discrepancies
between Cycles SVM, Cycles OSL, and EEVEE.

Clamp various shader inputs in the Principled BSDF to avoid physically incorrect materials, and to fix some discrepancies between Cycles SVM, Cycles OSL, and EEVEE.
Alaska added the
Module
Render & Cycles
label 2023-09-23 14:31:29 +02:00
Alaska added 1 commit 2023-09-23 14:31:46 +02:00
Alaska requested review from Brecht Van Lommel 2023-09-23 14:31:53 +02:00
Alaska requested review from Lukas Stockner 2023-09-23 14:32:03 +02:00
Alaska requested review from Weizhen Huang 2023-09-23 14:32:11 +02:00
Alaska added 1 commit 2023-09-23 14:47:27 +02:00
Author
Member

A quick list of the benefits of each clamp:

  • Subsurface
    • Fixes a discrepancy between Cycles SVM compared to Cycles OSL/EEVEE. SVM allowed negative values while the others didn't.
  • Specular
    • Fixes negative values producing negative reflections.
  • Roughness/Sheen Roughness/Coat Roughness
    • Fixes a discrepancy between Cycles and EEVEE. Cycles would render like min(abs(roughness), 1.0), while EEVEE would render like max(roughness, 0.0)
  • Specular Tint
    • Fixes a discrepancy between Cycles and EEVEE with extreme values and fixes some weird results with extreme values.
  • Sheen/Coat
  • Emission Strength
    • Fixes a discrepancy between Cycles SVM and OSL (OSL didn't support negative values). The other alternative is to allow OSL to support negative values.
  • Alpha
    • Fixes weird results with Cycles when below 0, and fixes a discrepancy between Cycles and EEVEE when it's below 0.

Note: Not all clamping is needed in all places (SVM, OSL, and EEVEE), because some of this is already handled when processing the relevant closures. But I put the clamps in all three places just so it's clear, with the exception of clamping Subsurface in OSL.

A quick list of the benefits of each clamp: - Subsurface - Fixes a discrepancy between Cycles SVM compared to Cycles OSL/EEVEE. SVM allowed negative values while the others didn't. - Specular - Fixes negative values producing negative reflections. - Roughness/Sheen Roughness/Coat Roughness - Fixes a discrepancy between Cycles and EEVEE. Cycles would render like `min(abs(roughness), 1.0)`, while EEVEE would render like `max(roughness, 0.0)` - Specular Tint - Fixes a discrepancy between Cycles and EEVEE with extreme values and fixes some weird results with extreme values. - Sheen/Coat - https://devtalk.blender.org/t/principled-v2-feedback-discussion-thread/24997/487 - Emission Strength - Fixes a discrepancy between Cycles SVM and OSL (OSL didn't support negative values). The other alternative is to allow OSL to support negative values. - Alpha - Fixes weird results with Cycles when below 0, and fixes a discrepancy between Cycles and EEVEE when it's below 0. Note: Not all clamping is needed in all places (SVM, OSL, and EEVEE), because some of this is already handled when processing the relevant closures. But I put the clamps in all three places just so it's clear, with the exception of clamping Subsurface in OSL.
Alaska changed title from Cycles/EEVEE: Clamp various shader inputs to Cycles/EEVEE: Clamp various shader inputs on the Principled BSDF 2023-09-24 01:27:20 +02:00

This was incorporated in #112848, with two changes:

  • Clamp subsurface to 0..1
  • Clamp specular_tint >= 0, but allow > 1
This was incorporated in #112848, with two changes: * Clamp subsurface to 0..1 * Clamp specular_tint >= 0, but allow > 1
Brecht Van Lommel manually merged commit a03ee1af81 into main 2023-09-25 19:53:53 +02:00
First-time contributor

Please don't clamp negative values unnecessarily. Sometimes, physically incorrect results are an artistic choice, and I've used negative values to achieve interesting effects in various projects.

Please don't clamp negative values unnecessarily. Sometimes, physically incorrect results are an artistic choice, and I've used negative values to achieve interesting effects in various projects.
First-time contributor

I am a stylized 3D artist and my work depends on "breaking" some of the shaders. Bad idea, please don't assume everyone wants "physically correct" output. It hinders creativity.

I am a stylized 3D artist and my work depends on "breaking" some of the shaders. Bad idea, please don't assume everyone wants "physically correct" output. It hinders creativity.
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
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#112774
No description provided.