libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.91k stars 1.83k forks source link

Feature request: Signed Distance Field for fonts and monocolor shapes #6419

Open akk0rd87 opened 2 years ago

akk0rd87 commented 2 years ago

I would like to know if it is possible to add this feature to SDL for support different drawing backends: opengl(es), Metal, Vulkan and etc.? It is cool technique for drawing scalable fonts and monocolor shapes without texture rasterization. All scaling is handled by GPU, not CPU.

See more: https://libgdx.com/wiki/graphics/2d/fonts/distance-field-fonts https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

slouken commented 2 years ago

This is already supported in SDL_ttf, checkout TTF_SetFontSDF()

akk0rd87 commented 2 years ago

I asked about SDF here and Sylvain_Becker pointed me to custom example for opengles only. And those code and shaders seems had written outside SDL, just as an example. It means it will be pain if someone wants to combine SDL_Renderer and code like this written by himself. Every change in src/render/ source may broke this compability.

I'm using my SDF shaders over opengles only and compability with SDL_Renderer was broken at least two times:

Second problem is that opengles is deprecated on ios, and I need to move SDF to metal. And I'm not sure if I can do it by myself.

1bsyl commented 2 years ago

yes, that would be possible if user can provide its own shaders to SDL. Currently shaders are specific to back-end, provided as source or binaries, so there are more platform code Hopefully with Ryan's universal shader language, that would make things easier.