freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SDF format


From: Jan Alexander Steffens
Subject: Re: SDF format
Date: Mon, 28 Dec 2020 22:30:42 +0100

On Sun, Dec 27, 2020, 20:41 Anuj Verma <anujv@iitbhilai.ac.in> wrote:
Hello Alexei,

> [...] I went searching for *practical* examples on the internet and
> found very few.

There are quite a few examples on youtube, and most of them use 8-bit
buffers to represent SDF.

> This blog post
> https://blog.mapbox.com/drawing-text-with-signed-distance-fields-in-mapbox-gl-b0933af6f817
> and some others refer to OpenGL textures as the next step, Their
> format is unclear to me but it seems that we should align.


I don't think we have to align the format with OpenGL. We can convert
the SDF data to any format in OpenGL, so I don't think we need to align.
In the blog you mentioned the OpenGL texture format is probably GRAY8.

> The blog post that I mentioned is okay with GRAY8 unevenly split at 192,
> which brings the question of units too. The units or scale of SDF do not
> seem to be important.


For most cases negative values are simply ignored, therefore uneven splitting
is okay. But, that might not be the case in every scenario. The units are not
important, as long we can create acceptable interpolation to render text.

> Finally, I am not sure if you realize that FreeType gray coverage
> [...] I wonder if we really need 16 bits for acceptable
> interpolation. Probably not.

I do know about the FreeType's antialiased rendering, the 'bsdf' renderer
takes advantage of the coverage values to generate SDF.

As for the number of bits, even behdad told me that 8 bits is enough to
And even some other SDF generators use 8 bits to represent the final SDF
output data :
I did test 8 bit SDF today, and the final rendering output is
similar to 16 bit. For my testing I used 3.5 fixed point representation,

Finally, we can definitely use 8 bit output to represent SDF and render
acceptable text using it. Now, we can either eliminate the current 16 bit
output, or, we can keep both 16 and 8 bit output. What do you think will be
the better option ? I think we should keep a single output (probably 8 bit)
and later add an option to directly output floating point data (if we decide
to add floating point calculations to FreeType)

Anuj

Isn't the renderer implementing a multi-channel SDF scheme? I thought I saw multi-channel mentioned in a commit message.

I stumbled upon multi-channel at  https://github.com/Chlumsky/msdfgen where the readme seems to imply simple 8-bit single-channel SDFs aren't satisfactory.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]