GL_BLEND ignores texture alpha channel #79491

Closed
opened 2020-08-03 19:20:25 +02:00 by Mikhail Rachinskiy · 13 comments

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 860M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.48

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-08-03 05:14, hash: 144f780c71
Worked: 2.83

Short description of error
Using bgl.glEnable(bgl.GL_BLEND) in 2.91 and 2.90 with image shader has no effect on alpha channel display.
gl_blend.png

Exact steps for others to reproduce the error

  • Open attached blend file.
  • Run script.

gl_blend.blend

**System Information** Operating system: Windows-10-10.0.18362-SP0 64 Bits Graphics card: GeForce GTX 860M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.48 **Blender Version** Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-08-03 05:14, hash: `144f780c71` Worked: 2.83 **Short description of error** Using `bgl.glEnable(bgl.GL_BLEND)` in 2.91 and 2.90 with image shader has no effect on alpha channel display. ![gl_blend.png](https://archive.blender.org/developer/F8742015/gl_blend.png) **Exact steps for others to reproduce the error** - Open attached blend file. - Run script. [gl_blend.blend](https://archive.blender.org/developer/F8742020/gl_blend.blend)
Author
Member

Added subscriber: @MikhailRachinskiy

Added subscriber: @MikhailRachinskiy
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

Confirmed, checking...

Confirmed, checking...
Member

Added subscribers: @JacquesLucke, @ideasman42

Added subscribers: @JacquesLucke, @ideasman42
Member

This changed in cfa788cf9a.

Seems like you need an additional call with something like

bgl.glClearColor(0.0, 0.0, 0.0, 0.0)

prior to calling your

bgl.glClear(bgl.GL_COLOR_BUFFER_BIT)

I assume this is not a bug, but maybe @JacquesLucke or @ideasman42 have an opinion?

This changed in cfa788cf9a. Seems like you need an additional call with something like ``` bgl.glClearColor(0.0, 0.0, 0.0, 0.0) ``` prior to calling your ``` bgl.glClear(bgl.GL_COLOR_BUFFER_BIT) ``` I assume this is not a bug, but maybe @JacquesLucke or @ideasman42 have an opinion?
Author
Member

Thanks, it does fix the issue, but it violates OpenGL spec , where it says glClearColor has to be initialized with 0.

And if it's not a bug, then it better be mentioned in Python API section of 2.90 release notes.

Thanks, it does fix the issue, but it violates [OpenGL spec ](http://docs.gl/gl3/glClearColor), where it says `glClearColor` has to be initialized with 0. And if it's not a bug, then it better be mentioned in [Python API ](https://wiki.blender.org/wiki/Reference/Release_Notes/2.90/Python_API) section of 2.90 release notes.
Member

Added subscribers: @christian.rauch, @brecht, @EAW

Added subscribers: @christian.rauch, @brecht, @EAW
Member

Reading D7599: correctly draw UI with enabled alpha channel, it seems possible that cfa788cf9a was committed based upon a miscommunication/misunderstanding.

This is a work-in-progress workaround for the buffer format selection issue on Wayland with Intel Iris GPUs (https://developer.blender.org/D6567#182240).

The workaround enables the alpha channel for the EGL context such that ARGB2101010 is selected instead of XRGB2101010.

The Blender UI is not drawn correctly in this configuration because many colour settings use an alpha value of 0 instead of 1. I was able to trace and rectify some of the colour settings but I was not able to find the origin of colour settings for "3D Viewport" and "Graph Editor". These views, and potentially other UI elements, still use a transparent background.

Could you point me to where the background colour for these remaining views is set?

So there was a bug with alpha handling
1: only in a specific version of a driver, and
2: only on a specific GPUs, while
3: only using a specific Windowing system (Wayland),
4: That had already been fixed upstream.

The original issue (wrong buffer format selection on Intel Iris) has been fixed in Mesa 20.0.7 (https://www.mesa3d.org/relnotes/20.0.7.html). Ubuntu 20.04.2 will probably use this or a newer version. Do you want to wait until the fix has been released into Ubuntu, or do you want to merge this workaround now and revert later?

In any case, I think the alpha channel corrections for the Blender UI are still valid, independent if the alpha channel is now activated in the EGL context or not.

It was designed to be temporary until the fixed driver in Ubuntu 20.4.1 is released, which will be on August 6 2020.

It seems that @christian.rauch wanted to change the Blender UI handling of alpha to be initialized to 1.0f on Wayland, but instead that change was committed in a way that affects Blender on all systems. It wasn't #ifdefed.

@brecht did sign off on the "other clear color changes," but it isn't clear (pun unavoidable😉) whether he thought they were suppose to be only for Wayland or the entire code base.

I am curious as to how the rest of the window managers handle UI drawing since glClearColor initializing alpha to 0.0 has been in the code since before 2.5 (see line 213).


I just realized your example @MikhailRachinskiy is from Blender's API documentation. https://docs.blender.org/api/master/gpu.html#generate-a-texture-using-offscreen-rendering
So if this change was intentional, that would need to be updated too.

Reading [D7599: correctly draw UI with enabled alpha channel](https://archive.blender.org/developer/D7599), it seems possible that cfa788cf9a was committed based upon a miscommunication/misunderstanding. >This is a work-in-progress workaround for the buffer format selection issue on Wayland with Intel Iris GPUs (https://developer.blender.org/D6567#182240). > >The workaround enables the alpha channel for the EGL context such that ARGB2101010 is selected instead of XRGB2101010. > >The Blender UI is not drawn correctly in this configuration because many colour settings use an alpha value of 0 instead of 1. I was able to trace and rectify some of the colour settings but I was not able to find the origin of colour settings for "3D Viewport" and "Graph Editor". These views, and potentially other UI elements, still use a transparent background. > >Could you point me to where the background colour for these remaining views is set? So there was a bug with alpha handling 1: **only** in a specific version of a driver, **and** 2: **only** on a specific GPUs, while 3: **only** using a specific Windowing system (Wayland), 4: [That had already been fixed upstream.](https://developer.blender.org/D6567#182240) >The original issue (wrong buffer format selection on Intel Iris) has been fixed in Mesa 20.0.7 (https://www.mesa3d.org/relnotes/20.0.7.html). Ubuntu 20.04.2 will probably use this or a newer version. Do you want to wait until the fix has been released into Ubuntu, or do you want to merge this workaround now and revert later? > >In any case, I think the alpha channel corrections for the Blender UI are still valid, independent if the alpha channel is now activated in the EGL context or not. It was designed to be temporary until the fixed driver in Ubuntu 20.4.1 is released, which will be on August 6 2020. It seems that @christian.rauch wanted to change the Blender UI handling of alpha to be initialized to 1.0f on Wayland, but instead that change was committed in a way that affects Blender on all systems. It wasn't `#ifdef`ed. @brecht did sign off on the ["other clear color changes](https://developer.blender.org/D7599#194733)," but it isn't clear (pun unavoidable😉) whether he thought they were suppose to be only for Wayland or the entire code base. I am curious as to how the rest of the window managers handle UI drawing since `glClearColor` initializing alpha to 0.0 has been in the code since before [2.5](https://developer.blender.org/diffusion/B/browse/master/source/blender/windowmanager/intern/wm_window.c;a1c8543f2acd7086d412cb794b32f96794b00659$213?follow=created) (see line 213). --- I just realized your example @MikhailRachinskiy is from Blender's API documentation. https://docs.blender.org/api/master/gpu.html#generate-a-texture-using-offscreen-rendering So if this change was intentional, that would need to be updated too.

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Brecht Van Lommel self-assigned this 2020-08-05 11:31:44 +02:00

If you call glClear without glClearColor, that is a bug in the Python script. The Python API makes no guarantee that all OpenGL state is set to defaults when Python scripts are executed.

If you call `glClear` without `glClearColor`, that is a bug in the Python script. The Python API makes no guarantee that all OpenGL state is set to defaults when Python scripts are executed.

This issue was referenced by 229fe01a15

This issue was referenced by 229fe01a152124308ad8552e6b792b9ebdaeec5a

Maybe I can clear up some misconceptions around the UI alpha channel to avoid confusion for future issues referring to this.

There are two dependant issues, which are reflected by the two commits in https://developer.blender.org/D7599:

  1. There was a driver bug related to the buffer selection on Wayland, which could be worked around by activating the alpha channel.
  2. The Blender UI would draw transparent UI elements if the alpha channel is used in Wayland (EGL), X11 (GLX), Windows (WGL), macOS (CGL), or any other OpenGL configuration in a compositing window manager.

In #79491#990899, @EAW wrote:
So there was a bug with alpha handling
1: only in a specific version of a driver, and
2: only on a specific GPUs, while
3: only using a specific Windowing system (Wayland),
4: That had already been fixed upstream.

There was a bug with the buffer format selection on Wayland for a specific Intel GPU driver (point 1). This is not related to the alpha channel (point 2). While the Wayland bugfix (1) would be obsolete for users of never iris drivers, the alpha channel bug (2) will be present for any system that enables the alpha channel in the OpenGL configuration.

In any case, I think the alpha channel corrections for the Blender UI are still valid, independent if the alpha channel is now activated in the EGL context or not.

It seems that @christian.rauch wanted to change the Blender UI handling of alpha to be initialized to 1.0f on Wayland, but instead that change was committed in a way that affects Blender on all systems. It wasn't #ifdefed.

No, I wanted the alpha to be correctly initialised to 1.0 for all OpenGL configurations on EGL, GLX, WGL, CGL (point 2). An #ifdef just for Wayland does not make sense, since all other OpenGL configurations would still suffer from transparent UI elements with alpha channel.

I am curious as to how the rest of the window managers handle UI drawing since glClearColor initializing alpha to 0.0 has been in the code since before 2.5 (see line 213).

An old bug is still a bug :-) It may be that this issue did not show before, since you will only see transparent windows with more modern window compositors.

Maybe I can clear up some misconceptions around the UI alpha channel to avoid confusion for future issues referring to this. There are two dependant issues, which are reflected by the two commits in https://developer.blender.org/D7599: 1. There was a driver bug related to the buffer selection on Wayland, which could be worked around by activating the alpha channel. 2. The Blender UI would draw transparent UI elements if the alpha channel is used in Wayland (EGL), X11 (GLX), Windows (WGL), macOS (CGL), or any other OpenGL configuration in a compositing window manager. > In #79491#990899, @EAW wrote: > So there was a bug with alpha handling > 1: **only** in a specific version of a driver, **and** > 2: **only** on a specific GPUs, while > 3: **only** using a specific Windowing system (Wayland), > 4: [That had already been fixed upstream.](https://developer.blender.org/D6567#182240) There was a bug with the buffer format selection on Wayland for a specific Intel GPU driver (point 1). This is not related to the alpha channel (point 2). While the Wayland bugfix (1) would be obsolete for users of never `iris` drivers, the alpha channel bug (2) will be present for any system that enables the alpha channel in the OpenGL configuration. > >>In any case, I think the alpha channel corrections for the Blender UI are still valid, independent if the alpha channel is now activated in the EGL context or not. > > It seems that @christian.rauch wanted to change the Blender UI handling of alpha to be initialized to 1.0f on Wayland, but instead that change was committed in a way that affects Blender on all systems. It wasn't `#ifdef`ed. No, I wanted the alpha to be correctly initialised to 1.0 for all OpenGL configurations on EGL, GLX, WGL, CGL (point 2). An `#ifdef` just for Wayland does not make sense, since all other OpenGL configurations would still suffer from transparent UI elements with alpha channel. > > I am curious as to how the rest of the window managers handle UI drawing since `glClearColor` initializing alpha to 0.0 has been in the code since before [2.5](https://developer.blender.org/diffusion/B/browse/master/source/blender/windowmanager/intern/wm_window.c;a1c8543f2acd7086d412cb794b32f96794b00659$213?follow=created) (see line 213). An old bug is still a bug :-) It may be that this issue did not show before, since you will only see transparent windows with more modern window compositors.
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
6 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#79491
No description provided.