Get 'Render' dependency graph

Hello.
I am starting to write an exporter in python. I want to export the meshes as triangle meshes, since the target render engine (Mitsuba 2) only supports triangles. I would also like to export the mesh with modifiers applied. Therefore, I want to access the mesh sent to the render engine (Cycles or Eevee for Blender). It seems to be the evaluated version of the mesh inthe final render dependency graph. However, I only see one way to get a depsgraph, which is bpy.context.evaluated_depsgraph_get() , that returns the viewport depsgraph (deg.mode = 'VIEWPORT' ). Looking at other exporters such as BlendLuxCore, it seems this depsgraph is passed to the bpy.types.RenderEngine objects upon F12/preview render. In my case, I am not (yet) writing a render engine inside blender, but only an exporter. How can I access/create the render depsgraph then? Before 1.8 one could do my_object.to_mesh(scene, True, 'RENDER'), but what about now?

There is no API function for this currently, it’s only available when rendering. It’s something we would like to add, but there is no specific timeframe for it.

Maybe a stupid question but isn’t there a mitsuba plugin for blender? Why not use that to export to Mitsuba?

There is one for Mitsuba 0.6, although it is not maintained anymore and I’m pretty sure it’s broken now. I’m developing one for Mitsuba 2, which was released a couple weeks ago

@brecht could I work on this feature or is it too complicated for new developers?

Well, honestly my question is even more relevant. If the function you need is available to render engines… why not just do a render engine instead of an exporter. This seems simpler than adding a new API call.

That’s indeed an option. However we would like to also be able to have a Mitsuba scene independently from blender, hence the intention to write an exporter.

You can do whatever you like inside the methods of a bpy.types.RenderEngine implementation. So you can write meshes to disk, create config files etc., basically write an exporter. You are not forced to create a fully integrated render engine.

The only drawback from a usability perspective is that you can’t offer a simple button/menu entry to export, the user has to switch the engine in the renderengine dropdown and press F12 or start a viewport render.
(Although, it might be possible to create a wrapper operator that switches the engine, starts the render, and restores the old engine selection - but I have not tested this).

1 Like

If you are writing an exporter and all you need is to apply modifiers and triangulation, you can just cheat off the .obj exporter it has options to do both those things.

Hi,
@brecht
Has anything changed in this topic? Is there any way to get depsgraph for RENDER mode in Blender 2.93?

No changes here as far as I know.

I’m assuming this is still not possible? If it’s not, is there a method we can use to calculate a velocity vector, so that we can at least do velocity based motion blur for viewport renders?