5
$\begingroup$

I'm using bpy.types.SpaceView3D.draw_handler_add and the gpu/bgl/blf library to draw some labels in the 3D view. The handler is created like this:

self._handle = bpy.types.SpaceView3D.draw_handler_add(self.draw_callback,
                                                      (context,),
                                                      'WINDOW',
                                                      'POST_PIXEL')

This draws everything fine when in Solid, Wireframe or LookDev shading mode, but shows nothing when in Rendered shading mode - for both Cycles and Eevee.

solid shading mode

rendered shading mode

Is it possible to draw on top of the rendered shading mode in python? Maybe using the new Overlays system?

$\endgroup$

1 Answer 1

3
$\begingroup$

Ok, I'm an idiot.

For future googlers, if you're using POST_PIXEL it should draw on top of all shading modes no problem.

The reason it wasn't working for me was because, hiding in my code, I had:

if context.space_data.shading.type == 'RENDERED':
    return

i.e. at some point in the past I deliberately prevented it from drawing on top of rendered shading mode, probably to be consistent with other overlays in Blender 2.7.

$\endgroup$
1
  • $\begingroup$ As future googler, I would say is useless, because it is very specific :-) $\endgroup$
    – Crantisz
    Commented Jan 9, 2022 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .