Page 1 of 1

Distance-Field Text Rendering

Posted: Mon Jun 30, 2014 16:56
by Alundra
Hi,
I have a feature request : Distance Field Text Rendering.
That post already talked about : viewtopic.php?f=10&t=4448.
But no real answer at the end about if it's accepted or not.

Re: Distance-Field Text Rendering

Posted: Mon Jun 30, 2014 17:26
by Ident
Discussed here already: viewtopic.php?f=2&t=6707

Resources: http://www.valvesoftware.com/publicatio ... cation.pdf
https://code.google.com/p/libgdx/wiki/D ... FieldFonts

This feature would probably take around a hundreds hours of work (more or less depending on the specifics) to implement in a specific Renderer of CEGUI. If you are interested in paying one of our developers for a contracted work on that matter, feel free to contact us.
Please only serious offers. This page can be used as reference for how much a work hour would approximately cost, considering this is requires advanced graphics programming in case it is requested to be implemented in Valve's way. It can also be implemented simpler, in which case the offer could be lower of course. Still consider that no one of us will pay for minimum wages.

It might be easier to achieve what you exactly want, but since you didnt tell us specifics I can't respond to that.

Re: Distance-Field Text Rendering

Posted: Mon Jun 30, 2014 18:19
by Alundra
It's just a feature request to help you to be the best GUI system, actually I don't need it but it can be the best for you to keep font high quality and outline effect surely.
Since CEGUI is an open source project, what you say kill the principe of open source community who is to give resource to all in a free way to learn and use.
The real big time is in the distance field generation because the pixel shader is straightforward. In the link, the distance is stored in alpha of texture.

Code: Select all

float4 main(in VS_OUTPUT IN) : SV_TARGET
{
  float rawAlpha = tex2D(TextureSampler, IN.TilingCoords).a;
  clip(rawAlpha - (0.5f-delta));
  return float4(fillColour, smoothstep(0.5f-delta,0.5f+delta,rawAlpha));
}

Distance-Field generation : http://perso.telecom-paristech.fr/~bloc ... elsson.pdf
BSD-License : https://code.google.com/p/signed-distan ... generator/
Another source code : http://www.gbuffer.net/vector-textures
The result using it and without is impressive.

Re: Distance-Field Text Rendering

Posted: Mon Jun 30, 2014 20:06
by Ident
Alundra wrote:Since CEGUI is an open source project, what you say kill the principe of open source community who is to give resource to all in a free way to learn and use.


Why? You can make a pull request and we merge it in. If anyone of us developers would be willing to do it in our spare time it will also become a part of CEGUI. I was just saying if you were for example a professional developer or a part of a company and you would depend on this feature we could implement it just for you (and if you allow us to add it to the CEGUI code base we would usually ask for less payment also).

I don't see how it interferes with Open Source at all. But maybe you can explain me how the above create a conflict of any kind.

Alundra wrote:The real big time is in the distance field generation because the pixel shader is straightforward. In the link, the distance is stored in alpha of texture.

Code: Select all

float4 main(in VS_OUTPUT IN) : SV_TARGET
{
  float rawAlpha = tex2D(TextureSampler, IN.TilingCoords).a;
  clip(rawAlpha - (0.5f-delta));
  return float4(fillColour, smoothstep(0.5f-delta,0.5f+delta,rawAlpha));
}

Distance-Field generation : http://perso.telecom-paristech.fr/~bloc ... elsson.pdf
BSD-License : https://code.google.com/p/signed-distan ... generator/
Another source code : http://www.gbuffer.net/vector-textures
The result using it and without is impressive.

The results could definitley be impressive, I agree. However the way CEGUI renders font is very specific. You can check my above link to a thread that discussed exactly this. Inserting such code into your own project might be easy, but having it in a big library, such as CEGUI, and integrating it smoothly into code is difficult. Also consider that we still support the fixed-function pipeline. Also we support many different Renderers. Also we would have to ensure that the shaders compile on every possible GPU out there that could use CEGUI. These are all non-trivial tasks. Getting something like this to work in a single project, for a single renderer, in your own code, with some simple example, is relatively easy compared to that.

If you think you can add this feature we would gladly support you in your efforts. Feel free to fork CEGUI and attempt to integrate it. You can later on make a pull request and if it meets our quality standards and coding conventions we can integrate all your changes into the CEGUI code base. This would definitely be a great addition. If you need help doing this we are also available on #cegui freenode several times per day.

Re: Distance-Field Text Rendering

Posted: Mon Mar 21, 2016 10:03
by Ident
The above links are all dead, here is a good new one:
https://github.com/libgdx/libgdx/wiki/D ... ield-fonts

I think this is something we should definitely look into in the near(tm) future