Worn Edges Using A Distorted
Vertex Map
By Neil Blevins
Mar 15th
2008
The edges of a hard surface frequently get bumped, scraped and
otherwise beat up. This creates wear and tear, paint tends to flake
off, metal tends to wear down to it's lower layers. Here's a paint
example, notice how the edges of the paint worn off, exposing the metal
underneath...

This is a nice detail to add realism to your textures. Basically, you
create a paint material, you create a metal material, and then you hand
paint a mask to blend between the two, exposing the metal around the
edges of your object. But what if you have over 5000 objects in your
scene? Painting masks by hand is slow and cumbersome, it's cool for 3
or 4 objects, but not for thousands. So this tutorial discussed a
procedural method for producing masks like this using vertex maps.
Applying The Vertex Map
So in 3dsmax, you can select any vertex and assign that vertex a color
(most major 3d apps have similar functions). The resulting colors of
all your vertexes are referred to as a vertex map. This can be really
useful, because it lets you paint a map directly in the max viewport.
The only issue is that since each vertex only has 1 color, you need a
lot of vertexes to get small detail. Lets start with 2 cubes...

Notice the geometry I'm using. The first cube has 10 segments going in
each direction. The second cube has extra edges very near the corners
and a meshsmooth applied. See my Rounding
The Edges,
Chamfers And Fillets tutorial for more info on adding extra edges
for use with meshsmooth. To paint the worn areas by hand using vertex
colors, we'd need maybe 4 or 5 times the amount of geometry we see
here, which is way too much geometry to be practical. So instead, our
technique is to produce lower res vertex paint, and then add the
smaller details by warping the low res vertex paint with noise.
Now, we can manually pick the vertex colors, but again, for a huge
number of objects, manually assigning colors is slow, so lets automate
the process. Go to the Soulburn
Scripts Page and download the latest script pack. It contains a
script called cornerEdgeToVertexMap. What this does it selects all the
corner edges, and then converts them to a Vertex Map. After running the
script with it's default settings, this is the result we get...

Notice the way the vertex colors blend between each other. In the first
cube, the edge is black, the vertexes closer to the center are white,
so you get a smooth gradient between black and white. The same with the
second cube, except the meshsmooth modifier is blending the vertex
colors even further.
Distorting The Vertex Map
So now we have the corners baked into a vertex map, but they don't look
much like wear and tear, do they. To do this, we'll distort the vertex
map using 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. In this
case, we place a Vertex Map map in slot1 of the Warp Texture (which
accesses the vertex colors we baked into our mesh), and in slot 2 we
place Noise. Also, while not always necessary, it may be good to check
the "Clamp" checkbox in the Output rollout of the Warp Texture, to
ensure the result is between a value of 0 and 1.

Here's the noise we add...

And here's the rendered result.

It's getting there, but the noise is too undefined, and doesn't hug the
corners as much as we'd like. To do this, we need to clamp both the
noise and the vertex map.
Place the vertex map inside an output map, and then adjust the output
curve to look something like this...

Then go to the output curve of the noise and do something like this...

Now we render, much better

Note, for the purpose of this tutorial, I adjusted the noise and output
map values on each cube to get a slightly different visual effect. But
in practice, you'll generally want to use a single material applied to
all your objects, since adjusting the maps for each object will take
too long.
Making the Blend Material
Now lets use this mask to blend between two materials. Create a Blend
material, make the first material look like paint, and make the other
metal (for the example file, I'm making very simple materials, replace
with something much nicer from your own material library). In the mask
slot of the Blend material, place your Warp Texture. Here's the
rendered results...


Here's the max file
that made the image above, max8: vertex_map_wear.zip
More Complex Geometry
Here's a similar shader on a more complex piece of geometry, a mech
looking surface with lots of panels. Here's the original material...

here's the vertex map after running the script, and distorted with
noise...

And here's the final result after distorting the vertex map, and using
it to blend between a brighter and darker metal...

Disadvantage of the Technique
Since this technique is so geometry based, the one disadvantage of
using it is if you need to edit your geometry, it will greatly affect
the look of your shading effect. So if you expect a lot of geometry
edits after you've added this technique, be aware that you may have to
remake the vertex maps, or edit the geometry further to get the ideal
look to the shading technique.
Things To Try
Play with the noise settings, the warp amount, and the
clamping to get
the exact sort of effect you're after. Also, feel free to use this
technique on the "less important" parts of your model, or models off in
the distance, and hand paint a few maps for the larger, more important
parts. Hero object deserve a little more of that hand touch, but use
this technique for secondary and Tertiary stuff, it'll mean way less
work.
This site is ©2008 by Neil
Blevins,
All rights are reserved.
Back to NeilBlevins.com