I'm trying to make a photoshop-like Bevel effect in HLSL.
The hard part is finding the distance of a point from the closest edge (where alpha=0)
Anyone have any ideas how to do this ?
Best,
SW
I'm trying to make a photoshop-like Bevel effect in HLSL.
The hard part is finding the distance of a point from the closest edge (where alpha=0)
Anyone have any ideas how to do this ?
Best,
SW
It took a while but I worked out a solution. The proper way to do this is by using multi-pass filters. The first pass a shader blurs the image horizontally, the second pass vertically, and the third pass renders the bevel by using the gradients in the alpha channel that was generated by the first two passes.
You can try a sampling-based approach. In pixel shader (for each pixel) you need to sample the pixels in a circle with radius equal to the bevel radius. If the current pixel is lit (alpha=1) then you can take the minimum distance to unlit samples (alpha=0) and calculate a fading factor: factor = min_dist / bevel_radius
. Then you can calculate some gradient color based on this factor.