Is it possible to use the openGL quick render for rendering from the command line?
e.g. something like blender -b <file> -E opengl -f 1
Is it possible to use the openGL quick render for rendering from the command line?
e.g. something like blender -b <file> -E opengl -f 1
It is possible, in a round-about way. Operator render.opengl() needs OpenGL display context, i.e. Blender's window, to be opened. Hence, we can't do UI-less rendering using -b command switch. We'll need to do it through a script:
import bpy
import sys # read argument from sys.argv
from bpy.app.handlers import persistent
@persistent
def do_render_opengl(dummy):
bpy.ops.render.opengl(animation=True, view_context=False)
bpy.ops.wm.quit_blender()
bpy.app.handlers.load_post.append(do_render_opengl)
It is to be executed like this:
blender -P render_opengl.py <file>.blend
Executing wm.quit_blender() is necessary, because otherwise Blender doesn't automatically close when render finishes. We also wrap the rendering code in load_post handler, to make sure the right context is loaded up before rendering. This is especially important if the scene's name is non-default. Otherwise Blender creates new scene Scene and renders it, instead of the scene we want.
The script above is to render preview animation. To render preview image and specify frame range, modify it to read argument from sys.argv (I've written code that does it before) and assigning appropriate values to bpy.context.scene.frame_*.
view_contextin the script toTrue. I set it toFalseso it renders through active camera, irrespective of view settings, but it doesn't play well with antialiasing. – Adhi Aug 26 '13 at 02:45load_post, is due to you calling the script before loading the file. Changing the order of the arguments, works as expected. – Aldrik Aug 26 '13 at 14:36