Maciej Główka
Blog Games Contact

← Return to Blog Index

March 28, 2021

Excel based batch rendering in Blender

python blender

Recently I have been working on some product renderings that involve lots of different shader and studio setups for the same objects. Basically every object has multiple colour combinations eg. white-white, white-blue, white-red, blue-white and so on. Also different colours needed different lighting setups to look correctly in the renderings. So a friend (we work together on this project) suggested that maybe we should have some kind of automation for that.

We ended up with having an Excel (CSV) list of all the required setup combinations. Each row represents one rendering scenario and the columns go as follows:

  1. Enabled - '0' means it won't be rendered, '1' means it will - useful if we want to exclude a shot or re-render only a specific one
  2. Object- name of the Blender object to be rendered in this pass. All the target objects should be in one collection ('Objects' is the default collection name)
  3. Studio - name of the studio-setup collection that contains lights, background objects etc. All the studio collections should also be contained in a top level master collection ('Studios' being it's default name)
  4. Materials - a comma separated list of material names that should be applied to the rendered object. Should contain as many items as there are shader slots on the Blender objects.
  5. Camera - a camera name to be used

Some extra setup can be done at the top of the script itself. You can set variables such as setup file name, output directory (both relative to the current Blender file), objects collection name and finally studios collection name.
The Blender file has to be ordered accordingly to the above. So every rendered object should be exactly one Blender object (multiple materials possible) - they should be grouped in an 'Objects' collection. Each studio setup including light objects, backdrops, soft-boxes etc. should be a separate collection (so it can consist of multiple Blender objects). All those studio sub-collections should be grouped in a 'Studios' main collection. All the additional objects like cameras or things that should be always present can be located in a separate top-level collection.


That's it. I did not mean to create a completely universal batch script. For now it suits my needs, maybe will be useful for someone.
I have been running it on the current Blender version 2.92

← Sunlight hours analysis with Revit Analysis Visualisation Framework Pre-export file flattening in Blender→