4
$\begingroup$

For my next project (game) I would like to use Blender for making pre-rendered assets. I'm fairly new to Blender.

  • I'm looking for a way to do a batch render and export of multiple assets with a single command. I'm aware of the Blender command line options but I suspect it's not going to be enough.
  • I need to be able to do the batch render repeatedly, as I iterate on the look and dimensions of the assets and add new ones.
  • I need all renders to use the same camera setup (angle, lens etc) without having to re-create the setup manually for each asset.

My current idea is this:

  • Make some assets. Adjust scale and orientation the same way for each. Separate .blend file for each asset.
  • Make a "template" scene where I setup the exact camera I need for all renders. Also perhaps the "passes" for rendering shadows separately could be setup here?
  • Write a Python script which loads the template, then iterates over the asset .blend files and renders each one using the template setup.
  • Add more assets
  • Re-run Python script, it finds new assets in the directory and renders them
  • Optimization: Python script will check timestamps of .blend files and only re-render if there's been a change.
  • Debug feature: Python script takes a parameter which lowers the sampling parameter, to make quick renders during development. Final renders use higher sampling value.

Is this reasonable or is there a better way to approach this?

My ideal answer:

  • Says yes or no for each requirement/assumption, with few words of explanation
  • Suggests alternatives in the form of links to Blender manual or tutorials
  • That's it.
  • DISCLAIMER: I'm not at all expecting anybody to write "the script" for me as an answer, just asking about the general idea. I will be happy to dive into that and learn how to do it, as long as I know I'm going in the right direction.

Thanks!

UPDATE: attaching three simple scenes as an example: BLENDER42764.zip

The right direction..

$\endgroup$
2
+50
$\begingroup$

It should be pretty well possible. You should choose wether to try to script everything in Python inside of Blender or to use an external script which calls blender with a prepared blend file set up with all of your materials, background, camera and lighting...

As I see Blender as an amazing all-in-one tool with a complete rendering pipeline I will say a few words about the first approach, but the second should easily be adaptable.

It's no problem to "spawn" objects via python commands in Blender, even linked ones from other files. Probably at the location of a placeholder Empty. Generally spoken you can just enlarge your Info Area (where the File menu is located) and see all the actions you do in the interface as the corresponding Python function. Just copy these lines and adapt them into a script meeting your needs.

You could either use a Python loop to iterate through your assets and import every single asset one after another, start a render with a distinct output filename and delete the asset again. Or you can import them all into one scene and animate their visibility (only showing one each frame) which allows you to render all assets as an image sequence. But the result should be the same.

You could use the os filesystem functions to check for changes and hold a timestamp variable or compare timestamps of your render outputs and your asset timestamps.

Your mentioned debug feature is just a setting of your render samples amount. You can script your output folder splitting up into different folders according to your samlpes settings.

$\endgroup$
0
$\begingroup$

My other answer is not exactly about this topic, but it should give you some hints of how to do some scripting with Blender and work with external files and arguments...

$\endgroup$
  • $\begingroup$ Why is somebody downvoting this answer? Could you give some reasons? $\endgroup$ – Samoth Dec 18 '15 at 16:22
  • $\begingroup$ Not me, I found the scripts you referred very informative. Thanks! $\endgroup$ – Tomas Andrle Dec 18 '15 at 18:17
  • 1
    $\begingroup$ @Samoth it is probably because it is a link only answer. Those are very discouraged. It would be better, to copy the necessary parts of your answer here, and then explain how to use it for batch rendering. $\endgroup$ – David Dec 20 '15 at 0:09
  • 1
    $\begingroup$ This really sucks on this site. If people want those details, they might help out and copy the details themselves or at least give that hint as a comment. But this is all about reputation and too few people upvote on specific topics. And when you ask a specific question you are really happy to at least get a link and some help as Thomas wrote. Finally, it's even an internal link. And programmers usually don't repeat themselves... So it's just discouraging. $\endgroup$ – Samoth Dec 20 '15 at 7:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.