Applying Compositing to Real Renders

I applied the logic I discussed in my last post to some real renders today! I’ll speak a bit more about my simulation and lighting setup in another post, but I’d like to mention a few additions to the expression and a couple of gotchas that I found.

The simulation that I’d created was far too small at the beginning for me to want in my sheet – I was trying to create something that was fairly generic and didn’t have too much movement inside of the flipbook as this would be done in the particle system in engine.

Because of this, I wanted to start my render partway in, and of course, I didn’t want 240 images in my sheet, so I only used every third image.

8

To load in the rendered images for the composite, I took my previous file loading logic, but added the start frame – 1 to it. This allowed me to offset the number that the node stepped though.

N = frame increment , S = start frame

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

2

This didn’t work for me originally, until I found a wee gotcha. As I’d rendered the image from frame 49, the file node was defaulting to a frame range between 49 and 240. To correct this, I overrode the frame range to do 1 – 64, one frame for each of my flipbook frames.

1

This worked brilliantly, but the final images came out very dark. I’m not sure if this was due to my light setup or something common to Houdini (I have heard others mention using gamma adjustment before rendering out) but I’d like to find out!

3

To correct this I upped the gamma and the levels slightly.

5

This is my final result! A 2k 64 frame flipbook, created from a 240 frame simulation.

Smoke_Pos.jpg

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.

7

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

8

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.

$HIP/render/flipbook_test.mantra_ipr.$F4.exr

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

9

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!

10

 

Houdini Flipbook Texture

I finally have a texture sheet!

Using my frame removal script, I got the right number of images and then popped them into a file node. I then setup a mosaic and a rop output node.

24

Unfortunately I had an odd issue where I couldn’t get more than 25 images on a sheet without getting odd artifacts and frames dissapearing. I’m not sure if this was something to do with the limitations of Houdini apprentice.

25

The final image was also low res and full of watermarks – at least its there though!

26

Houdini Basic Smoke Setup and Frame Removal Script

I wanted to have a go at getting a simulation from houdini into a flipbook texture for use in UE4. To do that I’ve made an incredibly simple billowy smoke that I can play around with in engine.

I started with a basic off the shelf billowy smoke, generated from a sphere with a mountain modifier, and then made some tweaks to make it more suitable for a flipbook texture.

12

The basic shelf tool smoke looked like this.

3

I added a basic three point light setup to bring out the individual shapes . This wasn’t great as I don’t have a great deal of experience with the artistic side of lighting, all I’ve really done with is annoy lighting artists about budgets! This is something I’d like to work on when I have some time. I made this base setup into a digital asset so I can come back to it quickly later.

456

I then made a few improvements to the rendering of the sim – upping the stochasic and pixel samples, as well as changing the volume filter to reduce noise on the edges of the smoke.

7

89101113

After this, it was time to edit the simulation. I started by setting the boyancy lift on the pyrosolver to 0, to create a growing sphere shape that would be easier to work with in engine.

14

I made the container size unlimited, then upped the temp diffuse and viscosity. I added the lift back in and set the direction to 1,1,1, giving me a strong upwards draft in all directions. I also upped dissipation to create more shapes within the sim and get large variance in my texture sheet.

17

1918

I then set up a camera that animated away from the sim over time in order to get the sim to take up as much space on the screen as possible. This will help to reduce the amount of overdraw produced by the final in engine simulation as there will be less wasted transparent space.

There were 128 frames in my original sim, I took every second frame to make an 8×8 texture sheet with 64 frames. The issue with however was that the mosaic setup expected to see each frame named in sequence. 001,002 not 002, 004.

I renamed the files by writing a quick python script – thank goodness I didn’t need to do this by hand!

20

Unfortunately the original renders were not square, so I couldn’t put these into a sheet. While I waited for the new render, I elaborated on the script so that it would also delete the number of frames you wanted. Also neatened things up a bit!

23

The render still isn’t finished, so I’ll show the new texture sheet in another blog post!

Houdini Python Environment Setup

I’ve been spending some time in Houdini recently, so thought I’d share how to setup your python environment for best results when working with your own scripts and sharing them with others.

Getting Environment Variables and Folder Locations

You might have noticed that a lot of file paths in Houdini look something like:

2

This is because Houdini is getting locations from your environment variables, so that it can point to everyone’s home folder regardless of where that may be.

To view these we can open a textport window and use the echo command.

1

For example, the text below will print your user directory.

echo $HIP

3

If you see a variable like this that you don’t recognize, try using echo to find out what it is!

 

Editing Environment Variables

You can edit environment variables for Houdini by changing the .env file found in your Houdini 16.0 folder. To get this folder type in the textport:

echo $HOME

In this file you can define whatever variables you might like. A list of environment variables can be found in the official documentation. 

4

As an example, here I’ve set my python version to use 2.7.

5

Where do Python Scripts Live? 

To import your own python scripts into Houdini’s python editor, the scripts must be stored in the home directory. Navigate to the home directory and create a folder called “Python 2.7 Libs” (or whatever is appropriate to your python version). You’ll need to open Houdini again every time you make a change to this folder, but if you restart you should now be able to import your own scripts!

8

Editing Environment Variables for Multiple Users

This is all great, but what about multiple users working with version control? How do we share scripts and digital assets between users?

The best way to do this is to set the $HSITE variable in windows. This points to a home directory that contains a “Houdini 16.0” (or other version) folder. This folder can be versioned and contains your python library, digital assets and environment variables. With HSITE set and the folder kept up to date, these settings can be shared between users.

To do this, go to System in your control panel, open “Advanced System Settings” and click the Environment Variables button.

6

With this open, click new and enter “HSITE” as your variable name and the directory containing the “Houdini 16.0” folder as the value.

7

Houdini will now take all scripts, assets and variables from this location!