Shader Color Mix Node doesn't work with monochromatic colors #123934

Closed
opened 2024-06-29 02:12:22 +02:00 by Mason · 2 comments

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:
image

On the screenshot, the color for the box is almost white, which is fine.
The B color is this:
image

However, if I change the saturation to 0, no visible mixing of colors takes place at all.
image

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

**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: ![image](/attachments/b8f65b3b-0040-4124-b209-4d78cd63e100) On the screenshot, the color for the box is almost white, which is fine. The B color is this: ![image](/attachments/e02ff03d-733b-47bb-a4c2-9f1ac9e5ce56) However, if I change the saturation to 0, no visible mixing of colors takes place at all. ![image](/attachments/163cd669-e53a-4732-b064-9369aefb0fd8) 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
Mason added the
Type
Report
Severity
Normal
Status
Needs Triage
labels 2024-06-29 02:12:22 +02:00
Author

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 -> constant MA_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 (called update_memory_buffer_row in toplevel)

And there, there's: if (colS != 0.0f) {
Then, colS is used in hsv_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.

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` -> constant `MA_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` (called `update_memory_buffer_row` in toplevel) And there, there's: `if (colS != 0.0f) {` Then, `colS` is used in `hsv_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.
Author

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. :)

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. :)
Mason closed this issue 2024-06-29 11:53:39 +02:00
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2024-06-29 11:53:42 +02:00
Sign in to join this conversation.
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
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#123934
No description provided.