Flipbook Compositing in Houdini

I’ve written about this topic before, but I wanted to revisit it with a better solution.

Previously, to create flipbooks in Houdini I had been rendering every frame of my sim, using a standalone python script to delete and renumber frames, then used a basic mosciac cop to stich the remaining frames together.

I decided I wanted to bring the solution entirely into Houdini, so had a look at adding some script-y bits to my cop setup to eliminate the tool.

I rendered only the frames I wanted by changing the increment on my mantra node. I’m going to refer to this number as N or the Nth frame. By rendering out every 3rd frame of a 48 frame long simulation, I got 16 images – perfect for a flipbook!

An important note – my first frame is frame 1, not frame 0. In order to correctly import the files in the cop, we need to start an image named 0001. I’ll explain why in the next section.


Once rendered, to get these frames into a flipbook I made a cop net with a file node attached to a mosaic node.


If I tried to load the files using the default image sequencing stuff, I’d have gotten an error, because it was looking for frames numbered 0000, 0001, 0002 etc., as the $F4 in the filepath means current frame number with four leading zeros.


My render was producing 0001, 0004, 0007 and so on. To make it look for these numbers, I had to replace the $F4 with that sequence. To get the leading zeros, I used the padzero() function, which takes a number of leading zeros and an integer.

To get the integer that would match up to my render sequence, I took the current frame, took one away from it, multiplied this by N then added one.

The cop moves through frames ($F), starting at 1 and incrementing by 1. This is very important, because the presumption that this was base 0 was breaking things for a while! The textport is your friend for finding these things…

​padzero(4, ($F-1)*N+1)

This gave us a complete file path that looked like this. The backticks are important, as they tell Houdini to evaluate that section as an expression. Otherwise, it will treat it as part of the string and produce an error as we don’t have a filepath with that name!

$HIP/render/flipbook_test.mantra_ipr.​padzero(4, ($F-1)*3+1)`.exr


I then set my mosaic up to take 16 images in a frame and 4 per line, and made myself a nice square texture sheet!




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 )

Connecting to %s