Skip to content

New Script: Easily render all render layers and render passes to files

April 26, 2013

It’s been a while since my last post,
but the scripting madness has only intensified (which is one of the reasons I had less time to blog).

For the last few months, I’ve been writing a few of scripts meant to facilitate production at PitchiPoy, especially the rigging aspect of it.

But these will be announced and released soon, with the PitchiPoy’s new (under construction) website. It’s actually quite exciting, as we’re going to have a full production blog, so that the studio will share the methods, techniques and of course scripts and tools used in the production of the animated feature “Baldy Heights” we’re working on.

Meanwhile, I’d like to update about one of the new scripts, and its development process.

Save Render Layers and Passes to Files

This one was written so that anyone could easily render out all the render passes on all render layers into separate files, to composite in any program they would like to use (e.g. GIMP / Photoshop / Nuke / AE).

It started by a request from one of our concept and texture artists, Niv Spigel, who prefers to use external programs for compositing. So far, he repeatedly had to save to individual rendered images manually through the image editor, or to manually create and connect the renderlayer node’s individual pass output connections to file output node’s inputs, both repetitive time consuming tasks.

To automate this, I tried 3 approaches, struggled with some limitations in the Python API and a bug, and eventually came up with the solution.

But before I’ll get into that, here’s a DOWNLOAD link to the script and USAGE and INSTALLATION instructions.

Instructions

To use the addon:
1. Install from the python file ( User Preferences –> Addons –> Install from file )
2. Open the node editor, choose to view the compositing nodes, and check “Use Nodes”.
3. Open the tools menu ( Shortcut key: T )
4. Choose a folder to save out your rendered images, through the Options Panel –> Render –> Output.
5. Click on the “Create File Nodes” button.
6. Render your scene.
7. Open your output folder and enjoy!

Dev Log:

Image / UV Editor API limitations

The first idea I had, is to automate the clicks the user performs when he saves all the rendered images in the image editor.

It quickly became evident that the image editor’s API is fairly limited, which explains why there’s hardly any add-ons at all that utilize it.

While the “save image” operator is available and probably works nicely, I found absolutely no way to change the render layer or pass in the image editor through the python API, and emulate what the user can do through the graphic interface:

Render Result Image: Render Layer and Pass UI

The Slot, Render Layer and Render Pass menus in the Image and UV Editor and the python code that generates them.
The UI is created via a template for image layers, and there seems to be no direct access to the individual UI elements (and thus the properties) of the slot, layer and pass through python.

File output nodes in the compositor

So after coming to terms with the above mentioned limitation, I moved on to creating file output nodes as a means for generating image files.

My first tactic was to use one file output node for each render pass in each layer, which was rather straightforward to write. but before I tested the code, I watched a short tut that explained how file output nodes are used, since I never used them before. The tut showed a nice feature that helps reduce the congestion in the compositor: file output nodes can have multiple file sockets:

Multiple file output sockets in the File Output Node

Multiple file output sockets in the File Output Node

With this considered, it made more sense to create just one file output node and connect all the layers and passes to it.

To add new file sockets, the only way (that I found) is to use the bpy.ops.node.output_file_add_socket() operator with the file output node selected and active.

This operator is available through the graphic interface in the button shown in the image above ( Image  / UV Editor –> Options panel (N key) ).

But the operator had a bug that prevented it from working at all.

Frack.

I reported the bug, and amazingly, Blender dev Brecht replied within 22 minutes, and 10 minutes later the bug was fixed and the changes committed to SVN (!!).

However I reverted back to creating a file output node for each pass and layer, since for most users the bugfix will only be available in the next version of blender.

Stuff I still need to add to the script:

1. A decent poll for the panel that will make sure the user checked the “use nodes” button.
* Updated: Done!

2. Maybe ditch the composite output node that I currently create to enable rendering (and producing image files) in case the user deleted all the compositing nodes before running the script.

3. Find some more elegant way to check which render passes are used, instead of checking each and every “use_renderpass” property of the render layer.

That sums the dev log up!

I’ll be writing soon about lots of new scripts developed for the PitchiPoy pipeline which include new complex rigtypes for rigify, rigging utilities that facilitate coloring bones and creating driven corrective shape keys, and some nice little scripts for bulk-applying modifiers, cleaning vertex groups, renaming objects, and resetting constraints. Until next time!

Advertisements
38 Comments
  1. Thank’s!!!
    שמח שיצרת את הסקריפט הזה, היה חוסך לי המון פעם…

    • מעולה 🙂
      זה בדיוק מה שהקונספטיסט שלנו אמר, והסיבה שכתבתי את הסקריפט
      בכיף

  2. great! great!!! This is a really useful addon for everything about rendering!!!! Thanks so much for sharing!

  3. M.R. permalink

    There´s an error occuring when clicking ´Create File Nodes´ saying:

    File “my scripts folder”, line 257, in execute
    links=tree.links
    AttributeError: ´NoneType´ object has no attribute ´links´
    location::-1

    I did create an output folder and I activated ´Use Nodes´

    What´s my mistake?

  4. is it working in 2.67rc1?, can’t get it to work, i get an error in line 267 saying that the node type R_LAYER is undefined…
    😦

    but i love what you’re doing, i’ve been wanting this for a loooooong time.

    • Hmmm… Haven’t tested it on 2.7 yet actually… Will do.
      What operating system are you using?

    • OK, I downloaded 2.67RC1 and it seems that there are still bugs in the python API.

      The python console doesn’t work at all, and the line that triggers the error you’ve experienced is due to some malfunctioning of the node editor’s API.

      I’m sure they’ll fix it in the next release candidate or the final version.

  5. Herbert van der Wegen permalink

    Why not just use a layered EXR file? Photoline, for example, supports this, and all the render passes are loaded up in layers. For Photoshop you will need a (costly) plugin, though.

    • After effects just really sucks at reading EXR files.

    • Yeah, that’s exactly the problem –
      Photoshop doesn’t support it out of the box.

      At the beginning using a multilayer EXR is exactly what I recommended,
      then I hoped maybe Gimp supports it and would enable a conversion to PSD (but it doesn’t)

      So the only option was to automate the distribution to different files.

      • Herbert van der Wegen permalink

        Luckily Photoline supports multi-layered EXR Blender files out of the box 🙂
        All in 96bit, and it also supports saving those files for import back in Blender.

        Gimp cannot support 32bit per channel images, so I would not expect EXR support soon, if ever. Photoline can save the layered EXR directly to a layered PSD, btw. For less than the cost of that Photoshop EXR plugin.

      • That’s good to know, thanks Herbert!

  6. Hey man, i’m testing out your script in 2.68 seems to work, 2 things, one are you going to add the thing so it only creates one file output node instead of one for each output socket?.
    And second, can you make it write the files in a folder of their own, for instance if my scene is called project and i have renderlayer1, the passes would render into /project/renderlayer1/combined /project/renderlayer1/z /project/renderlayer1/alpha etc, so for putting in AE its quicker and more organized

    All the best, and thanks for the great work!

    • Hi Luciano,

      Yeah, I believe I’ll update the script to work with a single file output (with backward compatibility, so that it will use multiple outputs if the versions doesn’t support a single output), and to support folders.

      Not sure how soon these features will be added but I’ll announce it here when it’s done.

      Cheers

      • Great to hear that!!!, what about the subfolders, do you think it’s possible?,
        i’m gonna give it a try myself and see if that can be my little contribution to your script =)

      • I made it!, i needed to fix it for some renders that are currently ongoing =).
        Here so now here its what it does:

        SceneName/RenderLayer_RenderPass/RenderLayer_RenderPass####.ext
        that way you can drag and drop the renderlayer_renderpass folder to AE (multiple at a time if you need), and ae will know they’re file sequences right away.

        Here it is:
        https://www.dropbox.com/s/hgbepzsut9vlpf0/save_all_renderlayers_and_passes_inFolders.py

      • Well done Luciano!
        I’ll have a look at it ASAP and update the code (and credit you for your input of course). I also updated the code a bit to make sure it works with future versions and to generalize the pass generation.

      • Well done Luciano!
        I just tested the script and it works nicely!
        I’ll update it to have the shorter and more generalized handling of render passes and include the changes you made.

        I’ll update here when its up.

        Cheers

  7. cool thank you!, if i can be of any help lemme know…
    now i want to implement stuff like add a certain node or nodegroup to certain passes (i.e. there is a node group that will turn the vector pass from blender to a vector pass that you can input in RSMB), so we’ll see if i can do some research during the weekend =) tell me what you think .

    • Sounds cool, and like a fairly straightforward change to make in the code.

      You can probably send various outputs into the file output node’s input (probably any RGB output).
      You can also take the latest version of the script to see how I added the checkbox that toggles between save to folder and save all files together modes, and add another checkbox for your new feature.

      This post might help with getting to know the node editor’s API:
      https://bioblog3d.wordpress.com/2013/02/28/armature_parenting_trees/

      Lemme know how its going 🙂

  8. Thanks for sharing this informative blog about 3D Image Rendering. It s very helpful blog.

  9. Moris permalink

    I’m using Blender 2.69 and I get this error: fake_module: addon missing ‘bl_info’ gives bad performance!: then it shows the path the addon.
    And the addon doesn’t appear in the add on Tab. I would love to use this addon.

    • Hi Moris,
      Thanks for reporting this.
      Please complete a bug report here so that I’ll have the full details of your system.
      I’ll try to have a look at this and fix it as soon as possible.

      • Moris permalink

        Thank you, I just submitted a bug report. Hope it helps.
        🙂
        M

      • Thanks Moris,
        I’ll have a look at it as soon as I can.
        Cheers

  10. electronicpulse permalink

    hey man, have you updated the addon lately?

    Cheers!

    • Hi Luciano!

      Not really, not since Nov 2013.

      I did get some comments from users since and it seemed to work in recent versions (except a new bug report I havn’t had time to fix), but if there’s an issue, your’re welcome to let me know.

Trackbacks & Pingbacks

  1. Add-on: Save Render Layers to Image Files | BlenderNation
  2. Links of Interest – May 2, 2013 | Chris Hilbig.com - BETA edition
  3. Update to “Save Renderlayers and Passes to Files” script – now supports subfolders | BioBlogical - BioLogic's 3D & Design blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: