Thursday, April 23, 2009

3 channel dirt passes

Another technical post about using multiple channels in one image to allow more control in post production, this time with dirt maps (I know some people/software use the term to refer to ambient occlusion maps, but I'm talking here about actual dirt or grime).

The basic premise here being 2-fold: 1) the use dirt maps to create a more realistic look, rather than worrying about bump maps and the like, and 2) to be able to use generic dirt maps to create a bunch of different looks in the final render by combining them in one rgb pass.
I'm going on the basic premise here that often in production you don't actually need bump maps to rough up a surface. Adding dirt to the specular/color components is often just fine to create a rough surface look. This technique is actually applicable if you do use bump maps, you'd just add another pass of three combined bump maps in the color channels (more later).

So what am I talking about? Let's say we have the following image:
(click for larger images)
and we want to dirty it up to get something like this:

Just a bit of dirt to give it some texture or character.
If you knew what you wanted, etc. you could just add the dirt maps to the spec shader, tweak it out to get what you want and render. But the way I'm approaching this allows for loads of changes in post and requires little thought in 3D. This isn't necessarily for every shot or production, but its really useful when you just want to generally dirty stuff up.
Here's how we do it, again using multiple channels to hold multiple images.

This scene in Maya is super simple: Just a sphere and some lights.

I've got three different dirt maps that vary in the size and "frequency" of the dirt (it's basically just black and white images of splotches and splooches if you know what I mean). Here's what they look like mapped onto the sphere:

So I have 3 B&W dirt maps. I map them individually to the R, G and B color channels of a material or surface shader. (one to R, one to G, etc) This will give me a false color image with 3 different images in each of the color channels which I'll pull apart later in post. I also have my spec shader and my color shader.

If I was clever, I would have done the combining of the images in photoshop to get something like this:

Then I would map each channel to the corresponding channel in the dirt material. But I'm wasn't clever here and used each image separately in Maya. No real difference, just more parts.
Then I'll set up my render layers. One for color, one for spec, and one for the dirt.

And here are my renders. Again the dirt will be pulled apart to give us more options in post.

So onto Shake (though, of course, After Effects or Nuke or whatever could be used). . .
The idea is that I'll use each channel of the dirt map separately and get 3 dirt maps from this, which I'll use to muck up both the color and the spec passes.
The basic operation I'll use in Shake is a "reorder" which just puts one channel into all of the other channels (ex. red channel into red, green and blue channels). I keep the alpha. I use a "compress" node to dial up the blacks and whites to the values I want (like transparency but just with color).

Here is the comp below. I've pulled two of the channels of the dirt on the left side, multiplied them together (we want only the dark bits) and multiplied them to the spec pass. This roughs up the spec. Then on the right side, I just copied the dirt nodes, changed the compression a bit and multed them to the color pass to dirty that up a bit also. Then I "added" the dirtied spec to the dirtied color.

Here are the passes once I've tweaked them in Shake (color, spec, dirt):

Once again, here is the final result, with the spec added to the color and both roughed up by the dirt maps.

I know it seems like a lot of work to do this in post rather than doing it in the render, but in fact, once you get the hang of it, it's actually easier and certainly more flexible. For example, I can instantly change both the look and intensity of the dirt right in Shake.

If I wanted to include bump mapping in this, I would simply create three bump nodes in Maya with a basic texture and map the color ouputs of those into the R, G and B channels of another shader (say, a surface shader) to get a "super bump" pass. I could then dial up and down any of the three bump maps in post the same way.
As I said, this isn't always the most efficient technique for every job, but if you export out the dirt map shader, you can instantly add grunge to any object you like and then have some more specific control in post.

No comments:

Post a Comment