EEVEE: color mix node set to "darken" wont work anymore with fac < 1 #70605

Closed
opened 2019-10-07 15:51:37 +02:00 by richard schweiger · 11 comments

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.31

Blender Version
Broken: version: 2.81 (sub 10), branch: master, commit date: 2019-09-09 20:20, hash: 3e81c1c1d5
Worked: (optional)

Short description of error
color mix node in eevee set to darken wont result in correct output, when fac is lower than 1

Exact steps for others to reproduce the error
add a colormix to the surface shader's color (for example). set the mix mode to darken. choose white as color1 and a dark color as color2. gradually change the factor value. you see a different behaviour in cycles, where the white output at factor 0 darkens when raising the factor to 1.
in eevee at factor 1 its correct, but it only turns black, as you lower the factor to 0. It should turn white, like in cycles.

**System Information** Operating system: Windows-7-6.1.7601-SP1 64 Bits Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.31 **Blender Version** Broken: version: 2.81 (sub 10), branch: master, commit date: 2019-09-09 20:20, hash: `3e81c1c1d5` Worked: (optional) **Short description of error** color mix node in eevee set to darken wont result in correct output, when fac is lower than 1 **Exact steps for others to reproduce the error** add a colormix to the surface shader's color (for example). set the mix mode to darken. choose white as color1 and a dark color as color2. gradually change the factor value. you see a different behaviour in cycles, where the white output at factor 0 darkens when raising the factor to 1. in eevee at factor 1 its correct, but it only turns black, as you lower the factor to 0. It should turn white, like in cycles.

Added subscriber: @office

Added subscriber: @office
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

I can confirm the issue. The behavior is different between Cycles and Eevee when changing the factor.

darken_color_bug.blend

I can confirm the issue. The behavior is different between Cycles and Eevee when changing the factor. [darken_color_bug.blend](https://archive.blender.org/developer/F7815977/darken_color_bug.blend)
Jacques Lucke self-assigned this 2019-10-14 11:01:40 +02:00
Member

Eevee:

void mix_dark(float fac, vec4 col1, vec4 col2, out vec4 outcol)
{
  fac = clamp(fac, 0.0, 1.0);
  outcol.rgb = min(col1.rgb, col2.rgb * fac);
  outcol.a = col1.a;
}

Cycles:

ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2)
{
  return min(col1, col2) * t + col1 * (1.0f - t);
}

I believe the cycles version makes more sense. Will create a patch.

Eevee: ``` void mix_dark(float fac, vec4 col1, vec4 col2, out vec4 outcol) { fac = clamp(fac, 0.0, 1.0); outcol.rgb = min(col1.rgb, col2.rgb * fac); outcol.a = col1.a; } ``` Cycles: ``` ccl_device float3 svm_mix_dark(float t, float3 col1, float3 col2) { return min(col1, col2) * t + col1 * (1.0f - t); } ``` I believe the cycles version makes more sense. Will create a patch.
Member

Added subscriber: @brecht

Added subscriber: @brecht
Member

On the other hand, when comparing this to the light function, the more eevee-style solution is used by cycles as well.

Eevee:

void mix_light(float fac, vec4 col1, vec4 col2, out vec4 outcol)
{
  fac = clamp(fac, 0.0, 1.0);
  outcol.rgb = max(col1.rgb, col2.rgb * fac);
  outcol.a = col1.a;
}

Cycles:

ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2)
{
  return max(col1, col2 * t);
}

@brecht, which one of the darken functions is the correct one? I think it makes sense that if the factor is zero, the output is exactly the first color. I think the factor should just be a mix factor between the first color, and the mixed color. With this definition mix_dark, mix_light and svm_mix_light are wrong.

On the other hand, when comparing this to the `light` function, the more eevee-style solution is used by cycles as well. Eevee: ``` void mix_light(float fac, vec4 col1, vec4 col2, out vec4 outcol) { fac = clamp(fac, 0.0, 1.0); outcol.rgb = max(col1.rgb, col2.rgb * fac); outcol.a = col1.a; } ``` Cycles: ``` ccl_device float3 svm_mix_light(float t, float3 col1, float3 col2) { return max(col1, col2 * t); } ``` @brecht, which one of the darken functions is the correct one? I think it makes sense that if the factor is zero, the output is exactly the first color. I think the factor should just be a mix factor between the first color, and the mixed color. With this definition `mix_dark`, `mix_light` and `svm_mix_light` are wrong.

thanks for giving this a closer look! photoshop would have the layers opacity as "factor". hence factor would just mix between col1 and the result of the col1&col2 blend, like brecht said. that is what i as a user would expect (due to photoshops layeropacity)... but i dont wanna bother you. thank you!

thanks for giving this a closer look! photoshop would have the layers opacity as "factor". hence factor would just mix between col1 and the result of the col1&col2 blend, like brecht said. that is what i as a user would expect (due to photoshops layeropacity)... but i dont wanna bother you. thank you!

@JacquesLucke I think the Cycles version should be used for dark. You can change light in both to work similar.

@JacquesLucke I think the Cycles version should be used for dark. You can change light in both to work similar.

This issue was referenced by blender/cycles@04b93ebff0

This issue was referenced by blender/cycles@04b93ebff0e461ec4e109114a3055d63de7c599f

This issue was referenced by 2a9b162d94

This issue was referenced by 2a9b162d94576d0182661179cf0500cfbc85236f
Member

Changed status from 'Open' to: 'Resolved'

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