Painting Vtx Colors By Distance Across Surface

python
maya

#1

Hey folks,

I’ve previously written a tool to paint vertex colors with distance-based color attenuation, tapping into Maya’s soft-selection UI to provide visualization and controls. I’m now looking at a similar problem, where the functionality to attenuate color values is based on distance as measured across the surface of a mesh from the selected vertices.

I’ve got some ideas I’m toying with, but I thought I’d tap into the greater tech art hive brain to see what thoughts you fine folks have about the problem. I have the surrounding tech all worked out, I’m using Maya API to batch apply vertex colors to greatly improve performance, I have all the color attenuation stuff written out and ready to rock and roll. Mostly just trying to explore high-performance ways of calculating the distance between vertices across the mesh surface.

Thanks in advance!


#2

The pain in the ass part here is topology : the ‘shortest’ trip in Euclidean space, projected onto the geo, way be hellacioulsy long.

I’d try the A* pathfinding algorithm, with mesh vertices as the nodes and mesh edges as the node graph edges. If the mesh is triangulated, that will give you the shortest path across the mesh from any vert to any other. There are python examples out there, for example this one:

https://www.redblobgames.com/pathfinding/a-star/implementation.html

Most A* examples are for regular grids, but a grid is just a specialzed form of graph. Mesh, same thing.


#3

I think there is a way to actually get the rich selection from soft select to follow topology instead of volume. So you might just be able to reuse that, if you’re still using it to visualize.

Otherwise @theodox’s idea would be a solid solution.