Houdini PDG, Automated simulation and Rendering

General / 25 August 2020

One click sim to mp4

G'day how're you goin? Really gotta say you oughtta check out this PDG business in Houdini. I've got a nice setup going on here that allows me to sim my whole scene and get a render with barely any effort. There are multiple ROP geo nodes that need to be done in a specific sequence. Without PDG, I'd be going to them individually and making sure they're rendered out and updated. Thank god for automation!


Top left in the image below caches the static collision geometry, while top right caches deforming collision geo.

Partitioning logic

The next segment handles some of the dependency logic and ends up with the result of everything before being required to complete before anything after can start. "Wait for all" ensures everything above is done before anything below can begin, and "partition by index" combined with the "filter by range" above ensures everything is matched up properly for each frame. I've used "attribute create" combined with "sort" and "mapbyindex" to reindex the partitions as well convert them to work items. I needed to reindex so the indexes started at zero rather than one thousand. That was a side effect of the "partition by frame" upstream and would cause issues downstream if I left it as is.

Simulation

Next step was the simulation. This is a rain sim and for multiple reasons, I wanted to cache the main droplets, splashes, and running water seperately. The simulation needed to run first, but the other steps could be done in parallel. The image below shows my setup for fetching the ROP node and alerting the simulation upon its completion. The "OP Notify" node points to the "File" node and tells it to refresh when a newly completed frame is ready. This ensures it's not using outdated information later on in the chain and also updates everything in the viewport immediately.


Render

After all that, it's as simple as attaching to a "ROP Mantra" node, linking that to a compositing node for post processing, and compiling into a video with ffmpeg at the end! (Don't forget the "wait for all").

Conclusion

PDG really is a useful tool to get a hang of for any Houdini artist, it can do much more than I've shown here. For example, you can use it to automate a connection between Houdini, Maya, and Nuke + anything else that supports Python. I wrote this up mainly because the documentation for PDG is a bit scarse so I reckon the more resources the better. I know I didn't get into amazing detail so if you need me to explain anything, just reach out. Thank you for reading, and catch you next time!