[Addon] Mesh curvature to vertex colors

I made this script that calculates the average curvature on a vertex and then puts the data into vertex colors. If you have any suggestions, comments or bug reports, please send a message.

You can make separate concavity or convexity maps and bake them if you want, or combine them into one.

The addon creates “Curvature” vertex color entry if it doesn’t exist and uses that to save the data. To see and test the vertex colors, it’s good to create a shadeless material with vertex color paint turned on.

Download: https://raw.githubusercontent.com/amb/blender-scripts/master/mesh_curves.py
Repo: https://github.com/amb/blender-scripts

1 Like

Sounds neat. This seems like it could be very useful for quickly baking vertex colours for terrain mesh? If I’m not mistaken about how it’s supposed to function?

It’s more like dirty vertex colors and pointiness rolled into one. You have more options. You can either do a convex or a concave colors, or combine them into one. You can also invert the colors, for example fake AO by inverting concavity colors and using that to multiply the material intensity.

Sure you could use it for a terrain, if peaks and valleys are something you want to use. Sunlight and fluvial data, absolute slope and height are the variables I’ve used. Not so much curvature itself.

edit: I tried it with a map from World Machine and you get something like this after you create a material that multiplies height and the output from the addon (combined convexity and concavity)

At this point the addon is simple, as it only considers the immediate adjacent vertices for the calculations. It can’t ignore small bumps, if the face at that location is a bit differently adjusted.

1 Like

Ambi, thanks a lot, this is going to be handy.


Added Red/Green style output and dropdown menus for more coherent selection of various options. I consider the addon pretty much feature complete. If any bugs pop out or maybe performance improvements, is the work that’s remaining.

Heheh, I was just about to ask for colour options from black & white, specifically red and green! :smiley: You beat me to it! prepares a tin-foil hat, just incase

Very important tool. thank you a lot!

Hello , i have tried this cool addon, but maybe i am doing something wrong?
i can not edit the values. everything is grey, disabled? for sure a little checkboy which is not checked? :slight_smile:

@MindEversion: It looks like it writes the curvature vertex colors. To see them, you have to enable vertex color paint in the material->options tab. Or bake the vertex colors into a texture, perhaps.

I have no idea why it’s grayed out. If you get any error messages please do paste them. I’m also using 2.76 and the addon seems to be working fine. Try the addon with a simple, newly created Suzanne monkey head and see if it works out for you.

Personally I’m not using Cycles with the addon but adding a Input->Vertex colors node would seem to work in the render mode.

The addon is now 0.1.2 and comes with many performance improvements. Do report bugs and feature requests here, and private message me so I know when there are new messages to be read.

Normalized by edge length is now the default, I didn’t find it useful to keep the old algorithm as the newer is more accurate.

The addon is now at version 0.1.5. The performance was improved by over 10x, with completely refactoring the inner loop. It’s really quick now to iterate through the options. Any feature requests? Bugs? I’m thinking blur would be a nice option if people need it.

So, I have no clue how to get this add-on working. I mean, it’s there on Space bar menu, it does something and shows add-on’s UI. However, vertex color is 100% black and I don’t get how to make it to show in Object mode :confused:

Could you please explain the workflow ?

@motorsep: Switch to solid rendering mode, not material. Shift+A -> Mesh -> Add Monkey -> run script “Curvature to vertex colors” -> Go into vertex paint mode. The colors should be now visible. If it only shows black, something is wrong and it’s a bug.

If you have multiple vertex color data, you may have to select “Curvature” Vertex Colors under the Data tab in Properties.

I also posted an example nodes how you could use vertex colors with Cycles above.

Looks like Cycles doesn’t show the vertex colors in material mode. Shows only red to me. So there’s really nothing I can do with that, unless someone knows a node setup that does show vertex colors in material mode. It does work when rendered out, though.

Cool. Really nice work. I did a little exploration with python and curvature a little while ago. I can’t wait to browse your code and see what you came up with as my stuff was very hacky and pretty slow.https://github.com/patmo141/object_k_segmentation

Dang that’s nice stuff. I did not expect to see openCL action in there even though the comments say it doesn’t work. Your Numpy use blew my mind too.

Yep, that’s my issue too :confused:

@patmo141: Thanks for the kind words. :slight_smile:

The algorithm is pretty simple, it just compares the vertices on the edges connected to the primary vertex and gets the average rotational difference from dot product. If I remember it right.

This looks amazing!!!

Does this version work with Cycles 2.79?

I installed the addon,added Suzanne and duplicated the node layout for the emissive material but I cant see the menu or any results.

Indeed. It was broken. They seem to have changed the vertex color array from RGB to RGBA. The fixed version is at https://github.com/amb/blender-scripts/blob/master/mesh_curves.py

Very nice contribution, thank you very much

It reminds me of Pits and Peaks, a mascript that i used a lot in the past

Will give this a a spin and see how it compares to ‘set dirty colors’