Page MenuHome

EEVEE: color mix node set to "darken" wont work anymore with fac < 1
Open, Confirmed, MediumPublic

Description

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

Details

Event Timeline

Jacques Lucke (JacquesLucke) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Mon, Oct 14, 10:54 AM

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

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.

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 Van Lommel (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!

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