Curvature Based Edge Wear
By Neil Blevins
Created On: Mar 15th
Updated On: Jan 24th 2016
to read this tutorial in Russian.
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
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 discusses two
procedural methods for producing details like these.
Worn Edges Using A 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
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. NOTE for MAYA users: Chris
Granados has been nice enough to write a
version of cornerEdgeToVertexMap for Maya using Python. Visit Chris'
blog for more info.
Now back to max, what cornerEdgeToVertexMap does is 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.
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 (Please note, this map is not compatible with
mentalray, although if you are using mentalray, there appears to be a
similar plugin available here). 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.
Open the Warp Texture map and click on the Vertex map. Now
click on the map type button on the upper right (which currently says
Vertex). In the maps list choose Output and choose "Keep old map
submaterial". 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
If you're using
mentalray, or just don't want to use a 3rd party
plugin, there is another way to distort your Vertex Map with Noise. Its
identical to the technique I describe in my Occlusion
Rust tutorial. Place a
fractal noise in the first slot of a mix map, make the second slot
white, and then in the mix slot place your Vertex Map. Then clamp the
curve inside your mix map in the output area. It gets you almost
identical results to the
Warp Texture method.
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 (or mix map, if you
used the second warping technique). Here's the
Here's the max file
that made the image above, max8: vertex_map_wear.zip
Here's a similar
shader on a more complex piece of geometry, a mech
looking surface with lots of panels.
A few disadvantages
of the vertex color technique...
- Since this technique is so geometry based, 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 run the cornerEdgeToVertexMap script, be aware that
you may have to
remake the vertex maps. And you may need to add some extra geometry
beforehand to make sure you have enough geometry to get the results you
want from the cornerEdgeToVertexMap script.
- As mentioned before, WarpTexture doesn't work with mentalray if
that's the renderer you intend to use. In which case, use the clamped
technique instead of the warp texture technique.
- Also, due to a limitation in the Vertex Color map, you cannot use
technique to do bump maps in standard max, only diffuse maps or
displacement maps. If
you really need a bump map, see the tutorial Texture
Baking: Baking Patterns To Use In An Incompatible Render and use
this workflow to bake your vertex map into a series of bitmaps that can
be used as a
bump map. Or, if you have vray, you can use vray's VrayColor2Bump to
convert the warp texture into a bump...
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
Here's a video showing me using a vertex wear map on a robot tread...
Worn Edges Using CurveMap
A second way to produce similar results is using BoomerLab's
Curvemap. Rather than baking the curvature into a vertex map, this
produces the curvature at rendertime. Here's the interface...
As you can see, it will do black at concave and convex edges, flat
areas are white. I turn up Gain and KFactor to get nice sharp edges.
Then you can distort the map by placing your noise into the distortion
slot, or by using a clamped Mix like described above.
Advantages of this technique...
Disadvantages of the technique...
- No baking step necessary to write the curve data to the vertex
- Editing your geometry doesn't mess up your vertex map since the
curve data is calculated at rendertime.
- Curvemap doesn't work with mentalray if
that's the renderer you intend to use.
- Curvemap doesn't work with VrayRT.
- Costs $60 for the plugin (although personally I consider this a
Here's a video showing me using the Boomer Labs Curvemap on the
Worn Edges Using Vray's DirtMap
A third way to get curvature type effects is using the
VrayDirt map with Invert Nornmal turned on, or the VrayCurvature map
added in Vray 3.2. However, using these techniques have some major
disadvantages, especially when dealing with objects that have both
large details and tiny details. Watch the view below for more
information on these 2 techniques...
Anyways, give all the techniques a try and see which you prefer!
This site is ©2016 by Neil
All rights are reserved.
Back to NeilBlevins.com