3 ms·
My novice take is that the author is using a low-res RGB texture and then cleverly combining it with some custom GPU code to generate an extremely high-res mono
by drcode 7y ago
My novice take is that the author is using a low-res RGB texture and then cleverly combining it with some custom GPU code to generate an extremely high-res monochrome texture at the memory cost of the low-res texture.
- pcwalton 7y agoSigned 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.
- corysama 7y agoIt'll work on arbitrary geometry the same as any other texture. The Valve technique starts with "distance to the edge" encoded in each pixel of the texture. Bilinear filtering turns that into a piecewise-linear approximation of the true value for each interpolated point. Thresholding that gives you a black or white depending on if a given point is inside or outside of the threshold distance from the edge. Thus, you get hard, straight edged results at pixel resolution regardless of resolution of the font texture. This technique extends Valve's by combining multiple piecewise-linear approximations to work around the limitations of approximating corners that are not aligned with the texel grid.