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…
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!
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!