Material appears as black in cycles #103066

Closed
opened 2022-12-09 12:57:24 +01:00 by quvr · 11 comments

System Information
Operating system: Windows 10
Graphics card: AMD

Blender Version
Broken: 3.4
Worked: none

Short description of error
After updating blender to 3.4 I've been working on optimizing my complex shader to use the newly introduced mix float and mix vector modes in the mix node. However I noticed that my shader shows as black in Cycles after changing all mix color nodes to float and vector where appropriate. I stripped down everything to investigate the cause and came up with a simple file that shows the problem.

What I think is causing problems is the lack of optimizations for mix float, mix vector, and map range nodes as described here

When executing shaders, a special optimization is applied to Mix Shader nodes. If Factor evaluates to 0 or 1, any nodes that are only reachable via the unused branch of the mix are not evaluated.

This can substantially reduce the performance cost of combining multiple materials in one shader with a Color Attribute, texture, or other input used as a switch.

Screenshots of the issue
Mix float - shows black
1670585414.png
Map Range - Nothing
1670585418.png
Mix Color - Texture is visible
1670585422.png
Lowering factor - Shows black as on other nodes
1670585425.png

Besides, If i remove "separate rgb" nodes the bug disappears.
In real scenario I'm using those mix nodes to switch between 20 different textures so the mix factor is always 0 or 1 and do not mixes anything. The mentioned optimization helps with this drastically.
In the file I left only 2 image texture nodes just to showcase

Also I'm testing all of this on a 4gb ram laptop so maybe i hit some hardware limit. But that doesn't explain why everything works fine if using mix color nodes everywhere.

Exact steps for others to reproduce the error
bug.blend
Open the file, switch to rendered view in Cycles
It should be displayed as black as on the screenshots.

Go into the "Texture" node group and switch the output from the mix float node to map range, then to the mix color
If output connected to the mix color, texture should be visible as it should
In the "Sample" node group you can switch mix vector to mix color and bug will disappear too.

**System Information** Operating system: Windows 10 Graphics card: AMD **Blender Version** Broken: 3.4 Worked: none **Short description of error** After updating blender to 3.4 I've been working on optimizing my complex shader to use the newly introduced mix float and mix vector modes in the mix node. However I noticed that my shader shows as black in Cycles after changing all mix color nodes to float and vector where appropriate. I stripped down everything to investigate the cause and came up with a simple file that shows the problem. What I think is causing problems is the lack of optimizations for mix float, mix vector, and map range nodes as described [here ](https://docs.blender.org/manual/en/latest/render/cycles/optimizations/nodes.html#run-time-optimizations) > When executing shaders, a special optimization is applied to Mix Shader nodes. If Factor evaluates to 0 or 1, any nodes that are only reachable via the unused branch of the mix are not evaluated. > > This can substantially reduce the performance cost of combining multiple materials in one shader with a Color Attribute, texture, or other input used as a switch. **Screenshots of the issue** Mix float - shows black ![1670585414.png](https://archive.blender.org/developer/F14046553/1670585414.png) Map Range - Nothing ![1670585418.png](https://archive.blender.org/developer/F14046554/1670585418.png) Mix Color - Texture is visible ![1670585422.png](https://archive.blender.org/developer/F14046556/1670585422.png) Lowering factor - Shows black as on other nodes ![1670585425.png](https://archive.blender.org/developer/F14046555/1670585425.png) Besides, If i remove "separate rgb" nodes the bug disappears. In real scenario I'm using those mix nodes to switch between 20 different textures so the mix factor is always 0 or 1 and do not mixes anything. The mentioned optimization helps with this drastically. In the file I left only 2 image texture nodes just to showcase Also I'm testing all of this on a 4gb ram laptop so maybe i hit some hardware limit. But that doesn't explain why everything works fine if using mix color nodes everywhere. **Exact steps for others to reproduce the error** [bug.blend](https://archive.blender.org/developer/F14046582/bug.blend) Open the file, switch to rendered view in Cycles It should be displayed as black as on the screenshots. Go into the "Texture" node group and switch the output from the mix float node to map range, then to the mix color If output connected to the mix color, texture should be visible as it should In the "Sample" node group you can switch mix vector to mix color and bug will disappear too.
Author

Added subscriber: @Quver

Added subscriber: @Quver
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

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

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

Cycles: out of SVM stack space, shader "Material.001" too big.

Your shader exceeded its maximum complexity. This is a known limitation. Your only option is to try to simplify the shader.

> Cycles: out of SVM stack space, shader "Material.001" too big. Your shader exceeded its maximum complexity. This is a known limitation. Your only option is to try to simplify the shader.
Author

It works fine if you use mix color nodes instead of float. It's said in the description. It's weird that mixing floats turns out heavier than mixing colors...
Also it's far from complex because the original shader uses 20 image texture nodes inside each node group and it works too.

It works fine if you use mix color nodes instead of float. It's said in the description. It's weird that mixing floats turns out heavier than mixing colors... Also it's far from complex because the original shader uses 20 image texture nodes inside each node group and it works too.
Member

Added subscriber: @brecht

Added subscriber: @brecht
Member

I see what you mean. That's because only the Color Mix node implements constant folding in Cycles. But still, that's not exactly a bug.
@brecht Would you say this should be confirmed?

I see what you mean. That's because only the Color Mix node implements constant folding in Cycles. But still, that's not exactly a bug. @brecht Would you say this should be confirmed?

This issue was referenced by 0b706237b0

This issue was referenced by 0b706237b09006f59a1a3b619d69d49d3c80b482

This issue was referenced by 312e42708f

This issue was referenced by 312e42708f8073ef0882d11376c30dee5ac1aef8

I'll improve the constant folding since it's simple.

I'll improve the constant folding since it's simple.

Changed status from 'Archived' to: 'Resolved'

Changed status from 'Archived' 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
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#103066
No description provided.