Page MenuHome

Highlight selected face option causes overall fade overlay
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: Intel(R) HD Graphics 400 Intel 4.4.0 - Build 20.19.15.5070

Blender Version
Broken: version: 2.83 (sub 3), branch: master, commit date: 2020-02-14 23:40, hash: rB92a56bbe6a98
Worked: (optional)

Short description of error
In edit mode when the Highlight Selected Faces option is ON, there's overall faded overlay in the mesh. Happens in all render engine, solid or viewport rendered mode and even in 2.82.

Exact steps for others to reproduce the error
Here's a test file so you don't have to make it.
Just turn on/off the option.

Highlight Selected Faces ON


Highlight Selected Faces OFF

Event Timeline

Campbell Barton (campbellbarton) changed the task status from Needs Triage to Confirmed.Feb 17 2020, 9:27 AM
Campbell Barton (campbellbarton) changed the task status from Confirmed to Needs Information from User.Feb 17 2020, 9:30 AM

That option is only supposed to toggle the highlight of the selected faces. But it fades the entire geometry when the option is on. It shouldn't happen at all. This is why I reported it as a bug.
It happens in 2.82 release as well but it's subtle.

Campbell Barton (campbellbarton) changed the task status from Needs Information from User to Confirmed.EditedFeb 20 2020, 10:52 AM
Campbell Barton (campbellbarton) changed the subtype of this task from "Report" to "Bug".

Confirmed the opacity of the overlay increased in 2.83 (master).

From your report:

Happens in all render engine, solid or viewport rendered mode and even in 2.82.

As you saying this should not be any overlay? or that it should match 2.82?

The change in master is caused by rB804e90b42d72: DRW: Color Management improvement.

The blending function in source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl isn't handling alpha properly.

This resolves the overlay issue but causes a black background.

diff --git a/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl
index e8323520af5..dc6e68415bd 100644
--- a/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl
@@ -33,8 +33,8 @@ void main()
 
   vec4 overlay_col = texture(overlays_texture, texCoord_interp.st);
 
-  fragColor *= 1.0 - overlay_col.a;
-  fragColor += overlay_col;
+  fragColor.xyz = (fragColor.xyz * (1.0 - overlay_col.a)) + (overlay_col.xyz * overlay_col.a);
+  fragColor.a = min(fragColor.a + overlay_col.a, 1.0);
 
   if (display_transform) {
     linearrgb_to_srgb(fragColor, fragColor);

@Campbell Barton (campbellbarton) The blending IS done properly. This was done on purpose. The issue is that now we are doing blending in linear space for correctness which change pretty much all UI colors which use alpha blending. So we should patch the theme instead of the blending function.

@Clément Foucault (fclem) are you sure about this? Using linear color didn't impact alpha handling in other areas of Blender IIRC.

Blending color in linear space shouldn't have to change alpha strength.

A white overlay on a black surface seems much lighter than it should be.

  • The default theme alpha of 7.06% alpha results in 29.41% white.
  • Increase the alpha to 18.43% for 50.00% white.

Toggle edit-mode on this file.

Alpha handling is totally dependent on colorspace. In your example 0.07(linear) ^ (1.0/2.2) is almost 0.3(srgb). Because everything is now rendering in linear space all blending is also done in this space. Which is why brighter colors are more blended by alpha blending than before (visually speaking but linear values are correct).

A 50% white in linear (radiometrically speaking) is not perceived as Half grey by human eye.

This is also why I did a trick to blend background colors to have perceptually pleasing gradient (i interpolated in non linear space).

But here we cannot have a one liner patch because the blending is done in linear space by opengl and compositing is done much further than where this happens.
We cannot autopatch theme because it depends on the perceived color.

Reminder that this move to linear colors is to make things move in the direction of HDR support / better AA / better colormanagement in general.

Even with the difference between perceptual-brightness/RGB-value the change in brightness seemed very strong.

Although changing the face overlay color to black doesn't have the same impact.

Committed tweak to the theme to reduce the intensity for bright colors.

Speaking of face overlays, it was turned to white.
White overlay makes vertices/edges selection dim due to lower contrast with brighter faces, so we changing it to black in theme settings.
We also constantly keeping highlight edges checkbox in mesh edit mode overlays turned on to percept selection properly.