I'm trying to implement something like an "inner glow".
That is, I have an image which defines the shape of an object, and then I want to create overlay that is a gradient that goes from the edge of the shape and into the shape itself. In programs like Photoshop and Krita, this is called an inner glow.
If I could first produce a texture which contained values that represented distance along the inward travel path from the edge, the rest would be easy.
I want this to happen in a shader, but any general insights about the problem would be helpful, I guess. One idea that I was working with, was to just blur the outline, and call the result shades around the edges the "distance", but this might be an unnecessarily expensive operation on the GPU, maybe not, I don't know.
A naive approach would be to check all distances to all other pixels, which comes out to something like 256⁴ square root calculations for a 256x256 pixel image. I believe that's not optimal. Also I don't know if that's even possible in a shader.