Ambient Occlusion Rust
By Neil Blevins
April 8th
2008
This lesson outlines a technique for using Ambient Occlusion to produce
rust on your objects. First, read up on what Ambient Occlusion
is here.
If you look at photos of rust, one thing
you'll quickly notice is how a lot of rust appears in areas that are
hidden from
the elements (wind, rain, etc). Areas where objects intersect. Hard to
reach areas that
remain damp because they don't get sun to dry them off. Ambient
Occlusion is a technique to determine how much of a particular surface
sees of the sky, so while it's usually used for lighting (like
producing shadows in a skydome), Ambient Occlusion is also perfect for
defining the
areas of your object that would naturally rust.


First, lets make a teapot and ground surface, and use mentalray's
"Ambient/Reflection Occlusion" Map (note, pretty much all raytracers
have
a similar map, for example, brazil 2 has a "Brazil2 Occlusion" Map that
does exactly the same thing, so feel free to use whatever renderer
you'd prefer for this lesson). We will use the map to blend
between a rust surface and a yellow paint surface.
Here's the yellow paint by itself...

Here's the rust by itself, fashioned using fractal noise in the bump
and the color
is a photo manipulation of real rust...

And here's the ambient occlusion map results...

Now, use the ambient occlusion map as the mask between the two other
materials as part of a Blend Material. You get the following results.

So this is ok, the rust is showing up in the occluded areas of the
mesh. But the rust appears too even. This is because your ao
map is too even. Ideally, you'd like to take the edge and roughen it
up. My first thought was to use the Warp
Texture plugin. Warp Texture was written by John Burnett, and what
it does is takes any map and distorts it using another map. However,
the warp map not only doesn't work with mentalray, but it also won't
work for ambient occlusion because the warp texture cannot warp a
raytraced effect.
The next logical thing to try is, why not use the ambient occlusion map
to
define an areas where noise appears? You can do this by placing a
fractal noise in the first slot of a mix map, make the second slot
white, and then in the mix slot place your ao map.

Here's the resulting mask

This is better, and is good for some sorts of rust (specifically rust
that's generally blurry).

But if you look at the second photo, some
rust has a much more defined edge. How do we get this sort of effect?
One way to try and fix that is to clamp your ao, which makes the edge
harder. You can do this by changing the spread spinner (for this
example, I used a spread of 0.05 instead of the default 0.5). But this
just makes the shape of the ao harder, and you get an ugly edge.

You could also try clamping your fractal noise, but this also doesn't
solve the problem, you still see that ao edge.

After a lot of discussion on cgtalk, Master Zap
came up with a decent solution to the problem. Instead of clamping the
noise and the ao separately, then combining them, combine the noise and
the ao, and then clamp the result.
So take your mix map, the one that mixes between the non clamped noise
and the non clamped ao,
and adjust the output curve to a clamped value...

Here's the resulting mask...

And the final result...

This is much better looking.
A few notes... Use different types of procedural noise. Darktree by
DarkSim or the
Essential Textures by Digimation have some noises that are more complex
than the standard fractal noise. Also, instead of a single noise, you
can try mixing several noises together at different sizes to get
variety. Here's an example of that...

Also note, while this technique is good as a building block for further
rust, or for objects you will see off in the distance, it is not a
recommended way
to add rust to hero objects, since the results are not easy to control,
and may not show the variety in rust that a hero object requires.
Also, you could try using max's "Render To Texture" feature to render
out your ao rust into maps, which you can then edit in photoshop. It's
a nice way to get part of the way there procedurally, and then add the
final details by hand. But if you have a LOT of objects, this isn't
recommended since you'll have to uv map all the objects and keep around
a ton of maps assigned to the objects. Also, if you have to do modeling
edits on your object after shading them, you'll mess up the results of
your ao baking. Another reason you may wish to use the "Render To
Texture" feature is
that ao is a slow process to capture, and it's a lot faster to read a
precomputed bitmap than it is to calculate ao on the fly.
Here's the max file
that made the image above, max2008, using mentalray: ambient_occlusion_rust.zip
This site is ©2008 by Neil
Blevins,
All rights are reserved.
Back to NeilBlevins.com