Curvature to Vertex Color Modifier

One popular request on the Autodesk 3ds Max is the curvature map. While you can’t create procedural texture maps with Max Creation Graphs (at least not now) you can create modifiers that set the vertex color map and then use the vertex color map to drive materials.

In the zip file there are three tools and a few supporting compounds. To use the simply unzip the file into your MCG user folder (%userprofile%/Autodesk/3ds Max 2016/Max Creation Graph) and restart 3ds Max. Alternatively you can go into the MCG editor and select “Operators > Reload Operators” and then “Build > Evaluate all Tools”.

In the package are three MCG modifiers:

1. Curvature – Computes curvature at each face-vertex based on the angle between the vertex normal and the face normal. The value is clamped at 90 degrees +/- a delta (default 10), converted to a gray scale value, and stored in the vertex color channel.

2. SmoothVertexColors – A modifier that smooths the vertex colors in two steps: a. Gives each face the same vertex color across the face. b. At each vertex averages the vertex color based on the vertex color of each contributing corner.

3. VertexColorGrayScaleToColor – A modifier for visualizing gray scale vertex colors. It converts gray-scale values in the vertex color channel to RGB where 0,0,0 is red, 0.5,0.5,0.5 is green, and 1.0,1.0,1.0 is blue.

I’m also sharing with you a scene ( with the modifiers and a simple material applied to the Stanford dragon.

Under the hood

In order to understand what is going on in the MCG graphs, the key is to first understand how the TriMesh structure is organized as a set of immutable (unchanging) data-channels.


Data channels are arrays of data associated with different mesh elements: faces, vertices, face-vertices (i.e. the corners of each face), and edges. Data channels can have different types (Int32, Boolean, Single, Vector3, etc.) and can be either direct or indirect. A direct data channel mean the data buffer has the same length as the associated number of elements, and can be indexed in the same manner. An example of this are the material IDs data channel.

An indirect data channel has two arrays: the data buffer and an index buffer. The index buffer is the same length as the number of elements, and is used to lookup data elements. The most common example of this is the topology data channel. The topology data channel has a vertex buffer and an index buffer. The index buffer is the same length as the number of face-vertices (i.e. corners of faces). This is how most 3D APIs represent triangular meshes.  We say that the topology channel is an indirect data channel of type “Vector3” that is associated with face-vertices.

In 3ds Max a common category of data channel is called a MapChannel. In MCG the map channel is an indirect data channel of type Vector3 that is associated with face-vertices. Map channels are exposed to 3ds Max users via the Channel Info Utility which is one way to understand them better.

About Vertex Colors

Despite the somewhat misleading name vertex colors are a general purpose mechanism to store Vector3 data (triples of floating point values) with particular face-vertices. A face-vertex is a corner of a triangle. There are exactly N*3 face-vertices in a TrIMesh, where N is the number of face. This is usually different than the number of vertices, because multiple faces can share a vertex.

BUG ALERT: due to a bug in the current version of MCG, the vertex data channel data buffer must have exactly N*3 data elements.

Article by Christopher Diggins originally appeared here. 

Leave a Reply

Your email address will not be published. Required fields are marked *