jeinselen/VF-BlenderAutosaveRender

Viewport Render Animation breaks {serial} tag

Closed this issue · 3 comments

Alumx commented

If you set Output to "//Output\test {serial}/" and render Viewport Animation, it'll fail to create a folder with appropriate number
image

Also Is it possible to auto-save viewport renders too?

Hey @Alumx!

Blender does not invoke the render_init and render_complete handlers when rendering the viewport. Short answer; from what I can tell, it's simply not possible to write a plugin that works natively with the render.opengl operator, only the render.render operator.

However, there may be some workarounds.

  1. Custom script

If you manually sequence the existing plugin functions with a python call to the render.opengl operator, it should behave enough like the Blender handler system to work. Blender will freeze during the entire operation, just like when triggering a standard render from the Python API. You'd also need to set up a script for each of the three viewport rendering options (image, animation, and keyframes).

import bpy
import VF_autosaveRender

VF_autosaveRender.autosave_render_start(bpy.context.scene)
bpy.ops.render.opengl(animation=True)
VF_autosaveRender.autosave_render(bpy.context.scene)
  1. Use Proxy Render

If you're only capturing camera viewpoints and just need a quick Workbench render shortcut, VF-BlenderProxyRender might do the trick. It uses the standard rendering system in Blender, but temporarily sets the engine to Workbench along with a few other settings, and works correctly with other plugins like VR_autosaveRender that depend on event handlers. As mentioned above, the Blender interface will freeze while rendering, but generally it's pretty fast (so long as your Workbench settings aren't crazy).

As of Blender 2.7.3, the autosave_render function has been renamed to autosave_render_end for better clarity.

Updated script to render a viewport image:

import bpy
import VF_autosaveRender

VF_autosaveRender.autosave_render_start(bpy.context.scene)
bpy.ops.render.opengl()
VF_autosaveRender.autosave_render_end(bpy.context.scene)

To render an animation: bpy.ops.render.opengl(animation=True)
To render keyframes: bpy.ops.render.opengl(animation=True, render_keyed_only=True)

Triggering a render from Python will freeze Blender as it waits for the operation to complete; the Python API is not thread-safe and I haven't found a way around this limitation.

Closing: Blender API limitation