3 ms·
Signed distance fields for vector rendering are based on the fact that you can perfectly† reconstruct the distance to any straight line via bilinear interpolati
by pcwalton 7y ago
Signed distance fields for vector rendering are based on the fact that you can perfectly† reconstruct the distance to any straight line via bilinear interpolation between samples of the Euclidean distance. On GPU, the texture sampling hardware provides that bilinear interpolation.
The trouble with using this property to encode and render polygons is that sometimes to render polygons properly you need to consider the distance to two or more edges simultaneously in the course of processing a pixel. A single-channel signed distance field just accepts the artefacts that result from this. A three-channel signed distance field, on the other hand, allows each texel to record the distance to two edges simultaneously. (The extra channel basically exists just to specify the Boolean operation to be performed on the two edge differences.) This enhances the quality, especially around sharp edges.
Note that rendering of general polygons with any sort of signed distance field remains an approximation, because of the limited number of edges per texel as explained above. SDFs are not general vector renderers and should not be treated as such.
† Modulo quantization error from the fact that you're encoding distance into an 8-bit channel.