Worn Edges Using A Distorted Vertex Map
By Neil Blevins
Created On: Mar 15th 2008
Updated On: Oct 16th 2014

Go here 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 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. 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.

Distorting The Vertex Map Using Warp Texture

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 as 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 too long.

Distorting The Vertex Map Using A Clamped Mix

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.



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 (or mix map, if you used the second warping technique). 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

A few disadvantages of the 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.

Here's a video showing me using a vertex wear map on a robot tread...

Make sure to watch in HD!


This site is ©2014 by Neil Blevins, All rights are reserved.
Back to NeilBlevins.com