Shader Color Mix Node doesn't work with monochromatic colors #123934
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
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 & 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
Asset System
Module
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#123934
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 551.61
Blender Version
Broken: version: 4.1.1, branch: blender-v4.1-release, commit date: 2024-04-15 15:11, hash:
e1743a0317bc
Worked: N/A
Short description of error
It seems that there are parameters for which the color mixing doesn't work.
Exact steps for others to reproduce the error
Make a new scene with this node setup:
On the screenshot, the color for the box is almost white, which is fine.
The B color is this:
However, if I change the saturation to 0, no visible mixing of colors takes place at all.
My intuition is that this should work with any color, including monochromatic colors. A saturation of 0.0001 works, a saturation of 0 doesn't work. In this case I really wanted to mix a color with plain complete white (part of this tutorial: https://www.youtube.com/watch?v=m1PkSViBi-M), but it doesn't work with any gray color (saturation 0), either.
If in this case the B color came from another computation that came out monochromatic by chance, exactly those pixels would be color-mixed wrong while their direct, subtly non-monochromatic neighborhood would be color-mixed right.
Kind regards
A quick search (without really retracing the code paths) brings me to this code path:
source\blender\nodes\shader\nodes\node_shader_mix_rgb.cc
-> constantMA_RAMP_COLOR
That constant is used in
source\blender\compositor\nodes\COM_MixNode.cc
:convert_prog = new MixColorOperation();
The file
source\blender\compositor\operations\COM_MixOperation.cc
Has:
MixColorOperation::execute_pixel_sampled
(calledupdate_memory_buffer_row
in toplevel)And there, there's:
if (colS != 0.0f) {
Then,
colS
is used inhsv_to_rgb
in that branch.The file
source\blender\blenlib\intern\math_color.c
has that function.And in it, the parameter
float s
is used for multiplication, so it should be fine with 0.It seems to me like the check for 0.0f could be removed.
It probably makes sense in MixHueOperation where it is also present, to use the "other hue" instead of resetting it, but not in MixColorOperation, where it causes this visible discontinuity and precludes using certain colors resulting from mixing colors.
Looking at it again today, my choice "Color" for the mixing mode was wrong. Selecting the Data Type "Color" and Blending Mode "Mix" yields the correct results!
Closing ticket, sorry. :)