Curvature to Vertex Color Modifier using Max Creation Graph

By - - 3ds Max

One popular request on the Autodesk 3ds Max Feedback site is the curvature mapWhile 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. CurvatureComputes 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. SmoothVertexColorsA 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. VertexColorGrayScaleToColorA 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. 

For more information on Vertex Colors, and an arguably better explanation of mapping channels in general, I suggest reading the topic Understanding Texture Coordinates and Vertex Colors in the MAXScript help.

I hope you find the samples useful, and I'd love to hear what type of MCG tools you come up with that do magic with vertex colors! 



Published In
  • 3ds Max
  • Film & VFX
  • Games
  • Design Visualization
To post a comment please login or register
| 3 years ago
Hi Alex and Hot Knife. Thanks for the encouragement. Those compounds are in the sample pack. Check it out at: I'll add a node that it is required first.
Edited by christopher-diggins 3 years ago
| 3 years ago
Thanks - always hard to know if I'm doing something wrong or stupid with new tech'
Edited by Hot Knife 3 years ago
| 3 years ago
@Hot Knife: Thanks for your message. I believe the original download is missing 3 compounds (which I'm sure Chris is going to update): GtEqZ.maxcompound IfGtEqZ.maxcompound MapVertexDataToFaceVertices.maxcompound I've put them in a zip file: [URL][/URL] You might need to manually open SmoothVertexColors.maxtool and reconnect the TriMesh output of SetAverageVertexColorsAcrossFaces compound with the input of SetAverageVertexColorAcrossSharedCorners compound. (then Save + Evaluate) That should do the trick. @Chris: AMAZING WORK!
Edited by Alex Horst 3 years ago
| 3 years ago
Hi - looks great. Unfortunately only Curvature.Maxtool builds here. Getting this error : Opened file C:/Users/Mother/Autodesk/3ds Max 2016/Max Creation Graph/Tools/Curvature/SmoothVertexColors.maxtool Unknown node type SetAverageVertexColorsAcrossSharedCorners Connection has invalid destination port 0 Validation failed for C:/Users/Mother/Autodesk/3ds Max 2016/Max Creation Graph/Tools/Curvature/SmoothVertexColors.maxtool : Error occurred deserializing node: Can't find operator SetAverageVertexColorsAcrossSharedCorners All Compounds are in C:\Users\Mother\Autodesk\3ds Max 2016\Max Creation Graph\Compounds\Curvature The Curvature Mod' builds but the other two fail - which is odd.
Edited by Hot Knife 3 years ago