• Advertisement
Sign in to follow this  

Signed distance field conventions

This topic is 368 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement

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
Sign in to follow this  

  • Advertisement