5
$\begingroup$

Is there some algorithm that keeps details when creating mipMaps for SDF? For example group of 4 pixels when only one is above threshold will lose this pixel with bilinear and creating mipMaps with 'max' of those values will add noise. When purpose of SDF is keeping the same image in lower resolution what is the best way to downsample this image?

For generating SDF i use 8SSEDT

$\endgroup$

2 Answers 2

3
$\begingroup$

When you are making an SDF, you commonly have infinitely detailed data (like, bezier curves making up a letter) that you are making into an SDF image of a specific size.

If you make one that is 64x64, the first mip will be 32x32. The right way to make that mip is to do the original process of creating the SDF texture from the source data, but do it at 32x32 instead of 64x64. Repeat for the other mips.

It will break down at lower resolutions though, but that is just the nature of how SDFs work. The more correct, but slower way is to do super sampling. Take multiple samples at different places in the pixel and average the result.

$\endgroup$
3
$\begingroup$

From what I've found, signed distance fields are not suited for minification (drawing the text on fewer pixels on screen than it covers in the texture), no matter how you mip-map them. Their main use case is magnification, and they shine here, because you don't need to increase the size of the distance field texture when the renderered object increases in size on screen.

To render (e.g. text) with signed distance fields:

  • the texture should be large enough so that it represents the full geometric detail of the object you're trying to render. A good rule of thumb is that each line/stroke of your glyphs in the texture should be at least 2 pixels wide.
  • the object that you draw on screen with a distance field-based texture should be larger on screen that in the texture (e.g. a glyph that covers 64x64 pixels in the distance field texture should cover at least 64 pixels in each direction on screen)

If those properties don't hold for your use case then better use a directly rasterized texture - not a distance field - , as those mip-map much better.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.