[Bf-python] OpenGL drawing for render engines

Matt Ebb matt at mke3.net
Tue Jun 26 11:58:37 CEST 2012


Hi,

I'm looking to do some custom drawing in the 3D View as part of a
render API plugin. In this particular case, it's to visualise lights,
for example spot light cone angles/sizes/etc.

Working around this, trying to force the render engine's lights to
mimic blender's existing light properties is not adequate for several
reasons, the most significant being that what's built in to blender
doesn't encompass the range of functionality provided by other
renderers, such as orthographic shadow maps on distant lights. It
would be great to be able to draw this info into the 3D View myself,
depending on the custom engine-specific data attached to the object.

I've done some testing, and using the region POST_VIEW callback, I can
successfully draw custom OpenGL, looping over all lights in bpy.data
but the problem is the user experience around it, especially in the
case of a render plugin, is not good. I've tried a few things and as
far as I can tell, this is only really possible as part of an
operator, that must be manually run. On top of this, it's only valid
for a certain area/region, which means if a user adds a new 3D View,
the operator must be run again.

If anyone has any hacks/ideas for how this can be worked around or
improved, I'd love to hear. While I'd be happy with something that
just works for my use case, I'd also suggest that a good way to
implement this would be as a custom object drawing callback
(disclaimer: I have no idea how easy this would be to create).

It's quite commonplace in other applications to allow plugins to do
custom openGL drawing per object - in many pipelines this is used to
represent custom object/geometry types that the host application
doesn't natively support, or to display a representation of geometry
that will be loaded or generated at render time, without having to
load that geometry into the host application's scene database. It'd
also be useful for render engines of course! Something like this would
probably be a better longer term solution.

Anyway, any thoughts/ideas/hacks welcome!

thanks,

Matt



More information about the Bf-python mailing list