Blending Factor Slider in Image Editors not working #101795

Open
opened 2022-10-13 12:57:07 +02:00 by Steffen Dünner · 9 comments

System Information
Operating system: Linux-5.15.0-50-generic-x86_64-with-glibc2.35 64 Bits
Graphics card: NVIDIA GeForce RTX 2070 Super/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 520.61.05

Blender Version
Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-10-13 10:26, hash: cbe1c1474b
Worked: (newest version of Blender that worked as expected)

Short description of error
The "Blending Factor" slider in the Mask Display options doesn't work (= the image outside the masked area stays black).

image.png

The same display option works as expected in the Movie Clip Editor's mask mode.

Exact steps for others to reproduce the error

  • Open Blender
  • Press F11 to open an Image Editor
  • Open an existing image or create a new e.g. a Color Grid
  • Switch the Image Editor to mask mode and draw a closed shape.
  • Go to the Mask Display menu and select the "Overlay" option and set it to "Combined"
  • Move the Blending Factor slider -> Nothing happens.
**System Information** Operating system: Linux-5.15.0-50-generic-x86_64-with-glibc2.35 64 Bits Graphics card: NVIDIA GeForce RTX 2070 Super/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 520.61.05 **Blender Version** Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-10-13 10:26, hash: `cbe1c1474b` Worked: (newest version of Blender that worked as expected) **Short description of error** The "Blending Factor" slider in the Mask Display options doesn't work (= the image outside the masked area stays black). ![image.png](https://archive.blender.org/developer/F13672711/image.png) The same display option works as expected in the Movie Clip Editor's mask mode. **Exact steps for others to reproduce the error** - Open Blender - Press F11 to open an Image Editor - Open an existing image or create a new e.g. a Color Grid - Switch the Image Editor to mask mode and draw a closed shape. - Go to the Mask Display menu and select the "Overlay" option and set it to "Combined" - Move the Blending Factor slider -> Nothing happens.

Added subscriber: @SteffenD

Added subscriber: @SteffenD
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

It seems this option was missed because the mask is drawn using the overlay engine for image editors as opposed to space draw methods.

It seems this option was missed because the mask is drawn using the overlay engine for image editors as opposed to space draw methods.
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Added subscribers: @Sergey, @Jeroen-Bakker

Added subscribers: @Sergey, @Jeroen-Bakker
Member

As far as I understand mask drawing is handled differently for image editor and for movie clip editor.
@Jeroen-Bakker implemented mask drawing(7cd6f667e3) in overlay engine which is used by image editor. And blend_factor is not considered there to change the alpha value.


blend_factor added in eca0c95d51
cc @Sergey

As far as I understand mask drawing is handled differently for image editor and for movie clip editor. @Jeroen-Bakker implemented mask drawing(7cd6f667e3) in overlay engine which is used by image editor. And `blend_factor` is not considered there to change the alpha value. - - - `blend_factor` added in eca0c95d51 cc @Sergey

@Jeroen-Bakker Need your help in aligning the "legacy" mask drawing and the overlay drawing. This is what i have so far: P3253: (An Untitled Masterwork)

diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc
index 0fcbe5ab07d..c8b6557d327 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc
@@ -150,6 +150,7 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata)
   pd->edit_uv.mask = sima->mask_info.mask ? (Mask *)DEG_get_evaluated_id(
                                                 draw_ctx->depsgraph, &sima->mask_info.mask->id) :
                                             nullptr;
+  pd->edit_uv.mask_blend_factor = sima->mask_info.blend_factor;
 
   pd->edit_uv.do_uv_stretching_overlay = show_overlays && do_uvstretching_overlay;
   pd->edit_uv.uv_opacity = sima->uv_opacity;
@@ -391,7 +392,9 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
   if (pd->edit_uv.do_mask_overlay) {
     const bool is_combined_overlay = pd->edit_uv.mask_overlay_mode == MASK_OVERLAY_COMBINED;
     DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS;
-    state |= is_combined_overlay ? DRW_STATE_BLEND_MUL : DRW_STATE_BLEND_ALPHA;
+    state |= (is_combined_overlay && pd->edit_uv.mask_blend_factor == 1.0f) ?
+                 DRW_STATE_BLEND_MUL :
+                 DRW_STATE_BLEND_ALPHA;
     DRW_PASS_CREATE(psl->edit_uv_mask_ps, state);
 
     GPUShader *sh = OVERLAY_shader_edit_uv_mask_image();
@@ -404,7 +407,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
                                                     pd->edit_uv.image_aspect[1]);
     pd->edit_uv.mask_texture = mask_texture;
     DRW_shgroup_uniform_texture(grp, "imgTexture", mask_texture);
-    const float4 color = {1.0f, 1.0f, 1.0f, 1.0f};
+    const float4 color = {1.0f, 1.0f, 1.0f, pd->edit_uv.mask_blend_factor};
     DRW_shgroup_uniform_vec4_copy(grp, "color", color);
     DRW_shgroup_call_obmat(grp, geom, nullptr);
   }
diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh
index b1118e084a6..afb22f31ff1 100644
--- a/source/blender/draw/engines/overlay/overlay_private.hh
+++ b/source/blender/draw/engines/overlay/overlay_private.hh
@@ -404,6 +404,7 @@ typedef struct OVERLAY_PrivateData {
     Mask *mask;
     eMaskOverlayMode mask_overlay_mode;
     GPUTexture *mask_texture;
+    float mask_blend_factor;
   } edit_uv;
   struct {
     bool transparent;

. It seems a nice beginning, but, unfortunately, blending does not match in clip and image editors: Screenshot 2022-10-14 at 12.19.54.png

@Jeroen-Bakker Need your help in aligning the "legacy" mask drawing and the overlay drawing. This is what i have so far: [P3253: (An Untitled Masterwork)](https://archive.blender.org/developer/P3253.txt) ``` diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.cc b/source/blender/draw/engines/overlay/overlay_edit_uv.cc index 0fcbe5ab07d..c8b6557d327 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -150,6 +150,7 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) pd->edit_uv.mask = sima->mask_info.mask ? (Mask *)DEG_get_evaluated_id( draw_ctx->depsgraph, &sima->mask_info.mask->id) : nullptr; + pd->edit_uv.mask_blend_factor = sima->mask_info.blend_factor; pd->edit_uv.do_uv_stretching_overlay = show_overlays && do_uvstretching_overlay; pd->edit_uv.uv_opacity = sima->uv_opacity; @@ -391,7 +392,9 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) if (pd->edit_uv.do_mask_overlay) { const bool is_combined_overlay = pd->edit_uv.mask_overlay_mode == MASK_OVERLAY_COMBINED; DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS; - state |= is_combined_overlay ? DRW_STATE_BLEND_MUL : DRW_STATE_BLEND_ALPHA; + state |= (is_combined_overlay && pd->edit_uv.mask_blend_factor == 1.0f) ? + DRW_STATE_BLEND_MUL : + DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->edit_uv_mask_ps, state); GPUShader *sh = OVERLAY_shader_edit_uv_mask_image(); @@ -404,7 +407,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) pd->edit_uv.image_aspect[1]); pd->edit_uv.mask_texture = mask_texture; DRW_shgroup_uniform_texture(grp, "imgTexture", mask_texture); - const float4 color = {1.0f, 1.0f, 1.0f, 1.0f}; + const float4 color = {1.0f, 1.0f, 1.0f, pd->edit_uv.mask_blend_factor}; DRW_shgroup_uniform_vec4_copy(grp, "color", color); DRW_shgroup_call_obmat(grp, geom, nullptr); } diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index b1118e084a6..afb22f31ff1 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -404,6 +404,7 @@ typedef struct OVERLAY_PrivateData { Mask *mask; eMaskOverlayMode mask_overlay_mode; GPUTexture *mask_texture; + float mask_blend_factor; } edit_uv; struct { bool transparent; ``` . It seems a nice beginning, but, unfortunately, blending does not match in clip and image editors: ![Screenshot 2022-10-14 at 12.19.54.png](https://archive.blender.org/developer/F13677152/Screenshot_2022-10-14_at_12.19.54.png)
Member

const float4 color = {1.0f, 1.0f, 1.0f, pd->edit_uv.mask_blend_factor};

I also tried this initially but got mixed results for alpha Channel
And no changes for "Combined" overlay

> const float4 color = {1.0f, 1.0f, 1.0f, pd->edit_uv.mask_blend_factor}; I also tried this initially but got mixed results for alpha Channel And no changes for "Combined" overlay
Philipp Oeser removed the
Interest
EEVEE & Viewport
label 2023-02-09 15:12:13 +01:00
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#101795
No description provided.