Skip to content

Instantly share code, notes, and snippets.

@brockpalen
Last active July 11, 2022 21:09
Show Gist options
  • Save brockpalen/4bf2bdede0fb9cbb1572 to your computer and use it in GitHub Desktop.
Save brockpalen/4bf2bdede0fb9cbb1572 to your computer and use it in GitHub Desktop.
#run blender in batch, take all settings from those saved in the .blend file
#http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Command_Line
blender -b blender.blend -o //imagename -F PNG -x 1 -f 1
#brockp@umich.edu
#blender 2.71
# BMW1M-MikePan.blend
# http://blenderartists.org/forum/showthread.php?239480-2-6x-Cycles-render-benchmark
# run with: blender -b --python bmw.py
import bpy
#read our input blend
bpy.ops.wm.open_mainfile(filepath="BMW1M-MikePan.blend")
#Switch Engine to Cycles
bpy.context.scene.render.engine = 'CYCLES'
#tell blender to use CUDA / GPU devices
bpy.context.user_preferences.system.compute_device_type = 'CUDA'
#set CYCLES render system GPU or CPU
# GPU, CPU
bpy.data.scenes["Scene"].cycles.device='GPU'
#### THIS IS IMPORTANT FOR PERFORMANCE, see link
#for GPU rendering set the tile size large
# http://adaptivesamples.com/2013/11/05/auto-tile-size-addon-updated-again/
# GPU = 256x256
# CPU = 16x16
bpy.context.scene.render.tile_x = 256
bpy.context.scene.render.tile_y = 256
#set the format we want our image saved as, and file name/location
bpy.context.scene.render.image_settings.file_format = 'PNG'
bpy.data.scenes['Scene'].render.filepath = './bmw'
#pull the trigger
bpy.ops.render.render(write_still=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment