Python API: gpu.texture.from_image() fails with image sequences #121919

Open
opened 2024-05-17 18:18:35 +02:00 by Lukas W · 4 comments

System Information
Operating system: Ubuntu 23.10
Graphics card: nVidia GeForce MX150

Blender Version
Broken: 4.1.1, 4.0.2, 3.5.1, 3.3.18, 3.1.2, probably also versions in between
Worked: 3.0

Short description of error

gpu.texture.from_image(image) produces a bright pink texture if image.source == 'SEQUENCE'

Exact steps for others to reproduce the error

  1. Create a new file and switch to the Scripting workspace.
  2. Create a new Text datablock and paste the following code (from the documentation of the gpu module, adapted slightly to draw into the text editor).
import bpy
import gpu
from gpu_extras.batch import batch_for_shader

IMAGE_NAME = "Untitled"
image = bpy.data.images[IMAGE_NAME]
texture = gpu.texture.from_image(image)

shader = gpu.shader.from_builtin('IMAGE')
batch = batch_for_shader(
    shader, 'TRI_FAN',
    {
        "pos": ((100, 100), (200, 100), (200, 200), (100, 200)),
        "texCoord": ((0, 0), (1, 0), (1, 1), (0, 1)),
    },
)

def draw():
    shader.bind()
    shader.uniform_sampler("image", texture)
    batch.draw(shader)

bpy.types.SpaceTextEditor.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL')
  1. Open any image sequence in the image editor and set the source to "Image Sequence" and the appropriate number of frames
  2. Edit 'IMAGE_NAME' in the code to reflect the name of the new image
  3. Run the code.
  4. Note, that instead of the image, a pink square appears on the bottom left of the text editor area. Also the message "GPUTexture: Blender Texture Not Loaded!" appears in the system console.
**System Information** Operating system: Ubuntu 23.10 Graphics card: nVidia GeForce MX150 **Blender Version** Broken: 4.1.1, 4.0.2, 3.5.1, 3.3.18, 3.1.2, probably also versions in between Worked: 3.0 **Short description of error** gpu.texture.from_image(image) produces a bright pink texture if image.source == 'SEQUENCE' **Exact steps for others to reproduce the error** 1. Create a new file and switch to the Scripting workspace. 2. Create a new Text datablock and paste the following code (from the documentation of the gpu module, adapted slightly to draw into the text editor). ```Py import bpy import gpu from gpu_extras.batch import batch_for_shader IMAGE_NAME = "Untitled" image = bpy.data.images[IMAGE_NAME] texture = gpu.texture.from_image(image) shader = gpu.shader.from_builtin('IMAGE') batch = batch_for_shader( shader, 'TRI_FAN', { "pos": ((100, 100), (200, 100), (200, 200), (100, 200)), "texCoord": ((0, 0), (1, 0), (1, 1), (0, 1)), }, ) def draw(): shader.bind() shader.uniform_sampler("image", texture) batch.draw(shader) bpy.types.SpaceTextEditor.draw_handler_add(draw, (), 'WINDOW', 'POST_PIXEL') ``` 3. Open any image sequence in the image editor and set the source to "Image Sequence" and the appropriate number of frames 4. Edit 'IMAGE_NAME' in the code to reflect the name of the new image 5. Run the code. 6. Note, that instead of the image, a pink square appears on the bottom left of the text editor area. Also the message "GPUTexture: Blender Texture Not Loaded!" appears in the system console.
Lukas W added the
Status
Needs Triage
Severity
Normal
Type
Report
labels 2024-05-17 18:18:36 +02:00
Iliya Katushenock added the
Interest
Python API
Interest
Images & Movies
labels 2024-05-17 21:37:30 +02:00
Author

I have bisected major Blender versions and determined that this broke somewhere between versions 3.0 and 3.1.2

I have bisected major Blender versions and determined that this broke somewhere between versions 3.0 and 3.1.2
Author

f6e2c9bc97 "Image editor: not updating after image operation." introduced in 3.1.1 looks suspicious, but I cannot easily install any other minor versions than those I have already tested.

f6e2c9bc97d "_Image editor: not updating after image operation._" introduced in 3.1.1 looks suspicious, but I cannot easily install any other minor versions than those I have already tested.
Author

Workaround: Use image.gl_load(frame=bpy.context.scene.frame_current) before running gpu.texture.from_image(image)

Workaround: Use `image.gl_load(frame=bpy.context.scene.frame_current)` before running `gpu.texture.from_image(image)`
Member

Hi, thanks for the report. Can confirm. f6e2c9bc97 doesn't look related (That commit handle updates after the flip/invert/scale operations)

Workaround didn't work for me.

cc @Jeroen-Bakker

Hi, thanks for the report. Can confirm. `f6e2c9bc97 ` doesn't look related (That commit handle updates after the flip/invert/scale operations) Workaround didn't work for me. cc @Jeroen-Bakker
Pratik Borhade added
Module
Viewport & EEVEE
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-05-20 08:19:30 +02:00
Bart van der Braak added
Type
Bug
and removed
Type
Report
labels 2024-08-14 13:00:50 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
2 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#121919
No description provided.