Texturing a volumetric material inside a mesh with a rectagular coordinate system is straightforward. For example, a cube. The coordinates inside the cube's interior are rectangular and unique everywhere in the interior volume.
However, I want to be able to texture volumetric materials inside arbitrary meshes and keep the volumetric material density high only near the mesh surface (density dropping to zero for points deep inside a mesh and far away from all vertices).
I thought of using the 3rd coordinate in the Normal and UV coordinate systems, but I only get a density equal to zero in every set up I try. The first two coordinates in these systems lay tangent to the mesh surface. The third coordinate projects inward or outward from the mesh surface (depending on the normal orientation). I fear this third coordinate is not unique for points inside the mesh because a single point could trace back to the mesh surface along several normal vectors. But perhaps I'm missing an important part of UV(W) coordinates.
I've attached a .blend file I've worked on. This file contains a single mesh. This mesh is a irregular hole in the side of a cube. I have UV unwrapped only the irregular hole. I have applied a Voronoi texture to the surface of the hole and color-coded the texture with the regular UV coordinates ("u" in red and "v" in green). However, if you open the Mapping Node and rotate around X or Y, you see that the 3rd UV coordinate ("w") begins to appear in blue. This is how I know "w" is being calculated. What I am attempting to do is project the Voronoi texture inward into the cube's interior as long tubes of emission. These cylinders would be trimmed in length using a function of "w".
Do I understand UV coordinate correctly? Is "w" defined in the interior volume of the mesh? Is there another way to access or calculate the distance inward from the surface of the mesh and use that as a texture coordinate?