Image of the viewport can no longer be obtained via glReadPixels in Python. Gives strange results since 2.83 #80471
Labels
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
9 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#80471
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Arch Linux 5.8.5-arch1-1
Graphics card: Intel i7-8665U
Blender Version
Broken: since 2.83
Worked: till 2.82
Short description of error
In Python, we get an image of the viewport from within an registered draw handler routine using:
viewport = bgl.Buffer(bgl.GL_INT, 4)
bgl.glGetIntegerv(bgl.GL_VIEWPORT, viewport)
width = int(viewport[2])
height = int(viewport[3])
image = np.zeros([height, width, 4],dtype=np.uint8)
buffer = bgl.Buffer(bgl.GL_BYTE, image.shape, image)
bgl.glReadPixels(0, 0, width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE, buffer)
It worked fine till 2.82, as shown here
However, it gives blackish colors of the objects in the viewport since 2.83:
Added subscriber: @mgrewe
Offloading of rendered viewport gives strange results since 2.83to Image of the viewport obtained via Python gives strange results since 2.83Added subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Needs User Info'
Just checking if I understand this correctly:
I've put your code [not exactly the same, left numpy out of play here for the time being] into an operator which seems to give correct results here (no black/unshaded object afaict):
#80471.blend
Does this fail for you as well?
If not, please provide a .blend file with your code failing -- with the complete code to run from the Text Editor (including saving the image or dumping the data into a blender Image datablock)
Hi Philipp,
thanks for the reply. Please find an updated blend file attached which should give what I tried to describe above. You might need to toggle "Generated Image".
#80471.blend
2.82:
2.90:
Added subscriber: @fclem
This is expected. We separated the overlay drawing and the render in 2.83. So glReadPixels will return the overlays color only (because the callbacks are rendered on the overlay framebuffer).
We still have to figure how to give access to the render color buffer.
It is unpractical for us to give access to the final framebuffer as it is now the window framebuffer.
Changed status from 'Needs User Info' to: 'Confirmed'
Thanks for investigation. I hope the access can be done fast as we use it as an option to stream the viewport in a time-critical application. Pl. let me know if I can be of any help, e.g. testing. Cheers, Martin
Image of the viewport obtained via Python gives strange results since 2.83to Image of the viewport can no longer be obtained via glReadPixels in Python. Gives strange results since 2.83Added subscriber: @chafouin
Added subscriber: @JoseConseco
Added subscriber: @unwave
Hi all, just wanted to push this since a way to get the viewport image is still needed.
Is there maybe another way to get access to the rendered image? I want to avoid offscreen rendering due to additional overhead.
Added subscriber: @p2or
Added subscriber: @Will-43
As far as I know, it is possible to access frambeuffer through the drawing callbacks and the gpu module.
Therefore I believe we can consider this report resolved.