Python gpu bgl image drawing alpha problem #81289

Closed
opened 2020-09-29 12:52:19 +02:00 by Philipp Oeser · 11 comments
Member

System Information
Operating system: Linux-5.8.4-200.fc32.x86_64-x86_64-with-fedora-32-Thirty_Two 64 Bits
Graphics card: GeForce GTX 970M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 450.66

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-29 07:53, hash: 32d4a67017
Worked: 2.90.1
Caused by 536c2e0ec9

Short description of error
When drawing images with alpha using Python gpu bgl, alpha looks wrong

Exact steps for others to reproduce the error
Python gpu bgl image drawing alpha.blend

  • Open file
  • Execute script
  • Move mouse over 3D Viewport and rotate slightly to cause a refresh
  • Blender logo should appear over the Cube
  • Notice how alpha is drawn wrong, looks like this
    image.png
    Should look like this
    image.png

Script is from here (only enabling GL_BLEND added)
https://docs.blender.org/api/master/gpu.html#d-image

Probably related: blender/blender-addons#80730 (BGL deprecation)

**System Information** Operating system: Linux-5.8.4-200.fc32.x86_64-x86_64-with-fedora-32-Thirty_Two 64 Bits Graphics card: GeForce GTX 970M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 450.66 **Blender Version** Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-09-29 07:53, hash: `32d4a67017` Worked: 2.90.1 Caused by 536c2e0ec9 **Short description of error** When drawing images with alpha using Python gpu bgl, alpha looks wrong **Exact steps for others to reproduce the error** [Python gpu bgl image drawing alpha.blend](https://archive.blender.org/developer/F8935631/Python_gpu_bgl_image_drawing_alpha.blend) - Open file - Execute script - Move mouse over 3D Viewport and rotate slightly to cause a refresh - Blender logo should appear over the Cube - Notice how alpha is drawn wrong, looks like this ![image.png](https://archive.blender.org/developer/F8935644/image.png) Should look like this ![image.png](https://archive.blender.org/developer/F8935641/image.png) Script is from here (only enabling GL_BLEND added) https://docs.blender.org/api/master/gpu.html#d-image Probably related: blender/blender-addons#80730 (BGL deprecation)
Author
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Author
Member

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

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

Added subscriber: @fclem

Added subscriber: @fclem
Author
Member

CC @fclem

CC @fclem
Author
Member

Added subscriber: @VilemDuha

Added subscriber: @VilemDuha
Member

Did a bit more deep-dive and in my tests:

drawing the first image or rectangle does work wrong. (both basically the same to what's here for 2d image and 2d rectangle: https://docs.blender.org/api/current/gpu.html)

however, this happens only for the very first image/rectangle drawn.

If I first draw one image , both rectangle and image work.
So there's something inside the image draw function that fixes the ogl settings -after it's been drawn. Sorry, oGL is really not my area, so this is amateur bug hunting ;)

Also, none of these helped in any reasonable way:
bgl.glClearColor(0.0, 0.0, 0.0, 0.0)

bgl.glEnable(bgl.GL_BLEND)
  
Did a bit more deep-dive and in my tests: drawing the first image or rectangle does work wrong. (both basically the same to what's here for 2d image and 2d rectangle: https://docs.blender.org/api/current/gpu.html) however, this happens only for the very first image/rectangle drawn. If I first draw one image , both rectangle and image work. So there's something inside the image draw function that fixes the ogl settings -after it's been drawn. Sorry, oGL is really not my area, so this is amateur bug hunting ;) Also, none of these helped in any reasonable way: bgl.glClearColor(0.0, 0.0, 0.0, 0.0) ``` bgl.glEnable(bgl.GL_BLEND)
Author
Member

Ah, I've seen you've gotten around this by blender/blender-addons@768a8cfc35, still this should be fixed or documented though

Ah, I've seen you've gotten around this by blender/blender-addons@768a8cfc35, still this should be fixed or documented though
Member

Yes, and I feel ashamed for the super-hacky fix, which I remove once the fix is there or find out a better way. I just don't know what other OGL settings to reset, probably setting some OGL defaults would fix the issue.

Yes, and I feel ashamed for the super-hacky fix, which I remove once the fix is there or find out a better way. I just don't know what other OGL settings to reset, probably setting some OGL defaults would fix the issue.
Author
Member

Dare setting this to High, not sure if we can be in this "half-broken" state until Vulkan is here, just checking what the plan is here @fclem ?

Dare setting this to High, not sure if we can be in this "half-broken" state until Vulkan is here, just checking what the plan is here @fclem ?

This issue was referenced by f12b0373f3

This issue was referenced by f12b0373f322b710b9fa5cebb67bdf363ff90e9f

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Clément Foucault self-assigned this 2020-10-08 16:38:00 +02: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#81289
No description provided.