Is there a way to access the (possibly interpolated) vertex attribute of the closest vertices in a shader node, given a 3D position? In a CPU-based program, I'd use a k-d tree and search for the nearest neighbors, but how do I do this in a shader node graph?
Context: I have a texture node (Voronoi) from which I use the "Position" output to segment my material into Voronoi cells: I would like to use a vertex attribute (stored in a vertex color) to determine whether a whole cell should be "on" or "off", i.e. the vertex attribute acts as a "threshold" of sorts. Is there a way to sample the (closest) vertex color at a specific 3D position?
The only idea I had so far was to interpolate the vertex color into a volume and then sample from that volume at the position given by the Voronoi texture... is that possible?
(For reference, I have a related question that gave rise to this one. I have created this new one because the other one is much more general: Blending two procedural "reptile-scale" textures - at scale edges)