Sign in to follow this  
Aressera

Signed distance field conventions

Recommended Posts

Hi, I am using signed distance fields for font and GUI icon rendering and I was wondering what the consensus was on the sign convention for these types of images. The most mathematically consistent seems to make the background of the image positive, with the interior of the foreground negative, then the image represents the signed distance. Encoded from [0,1], this would mean outside is >0.5 and inside is <0.5. However, this is backwards from the usual alpha blending where smaller values indicate the background area, and therefore the alpha test must be reversed to get correct results. This isn't a problem if I handle it in the shader, but I wonder if it would be better to generate signed distance field such that inside = positive and outside = negative. Valve's original paper uses this convention, but I've seen other people use the opposite.

Side note: out of curiosity, has anyone ever tried SDF for alpha-tested foliage (e.g. packing the SDF in alpha channel of RGBA image)? Seems like it would produce nicer results.

Share this post


Link to post
Share on other sites

Valve, just like any other company uses this convention, because it fits well with their overall mathematical strategy.  The point to using any kind of technology isn't political, it's to understand the benefit it gives you.  For example, signed and unsigned notation became significant, because it originally was used to save computational space with lower amounts of bit computing.  If it does something for you, you should use or if you are using because somebody else used it, you should understand why they used it.  That would be a great question to ask them directly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this