Skip to content

SDF fonts: possible solution for downscaling #830

Description

@yard

Hi guys,

I've been recently playing around with rasterizing the fonts with msdf textures in playcanvas. SDF is well-known for its ability to handle upscaling well, but performs poorly when it comes to downscaled shapes. There are solutions using supersampling of various sorts, but they don't seem to be quite universal and require a lot of adjustments.

An idea: why don't we use alpha channel to store original glyph's pixel opacity and fall back to it when font size is lower than the char size in msdf map? Bitmap fonts look pretty good when chars are rendered at the scale of 1 and below (and thanks to bilinear filtering we even get a poor man's AA).

Looks like alpha channel is not used in msdf calculations in any way, so we can use it to render glyphs as if we had a bitmap font. The threshold can be controlled by material's parameter "enabling" the alpha channel to provide pixel opacity for low font sizes.

P.S. Could you please hint me which tool is supposed to be used to create JSON and PNG files for Playcanvas fonts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: uiUI related issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions