Page MenuHome

Images drawn with the Python gpu module no longer draw on top in the Image Editor
Confirmed, NormalPublic

Description

System Information
Operating system: Linux-5.4.43-x86_64-Intel-R-_Core-TM-_i7-7500U_CPU_@_2.70GHz-with-slackware-14.2 64 Bits
Graphics card: Mesa Intel(R) HD Graphics 620 (KBL GT2) Intel 4.6 (Core Profile) Mesa 20.1.0

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, hash: rBf470a02afaea, commit date: 2020-09-20 05:59
Worked: version: 2.91.0 Alpha, branch: master, hash: rB66078594d130

Short description of error
When drawing images with the python gpu module, they will no longer draw on top of the region's contents or of other python rendering.
This problem happens in the Image Editor, but not the Sequence Editor.

Before:
(2 square images and a circle are drawn with Python, 'POST_PIXEL' in the Image Editor, which shows a rectangular image)

After:
(the circle, drawn first, shows on top. The Image Editor's image also shows on top)

Exact steps for others to reproduce the error
See the attached .blend file.

Event Timeline

Could this be related to the depth tricks that the image editor currently uses? https://wiki.blender.org/wiki/Source/EEVEE_%26_Viewport/Draw_Engines/Image_Engine#Depth_Buffer
What happens when you draw with DEPTH_ALWAYS on? Or with write depth.

Currently when drawing via python it draws directly to the overlay buffer. https://wiki.blender.org/wiki/Source/EEVEE_%26_Viewport/GPU_Module/GPUViewport when transferring to display it might not have the correct data inside the buffers.

I will check later today with renderdoc to see what is happening and what needs to be corrected/documented.
Thanks!

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Sep 21 2020, 3:36 PM

The circle is rendered with gl_depth 0, write depth is on and depth function is less equal.
The textures are rendered with gl_depth 1, write depth is on and depth function is less equal.
The image of the image editor is drawn using gl_depth of 0.75 as part of the new draw pipeline.

Looking at https://developer.blender.org/diffusion/B/browse/master/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl the gl_depth is set to 1 for images so they always render in the background.
This was introduced by https://developer.blender.org/rB648924333234a1fd0fee91851bb7ad8bc8639f3a what seems to be out dated as we have done several overhauls in this area. (workbench refactor, overlay engine refactor, color management pipeline).

A heads up, drawing images in POST_VIEW doesn't work at all in the 2.92 Image Editor, could this be related? I've tried various z positons without success in this case though it works fine in 2.91.