OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Major changes to osgText merged into master, provide high quality text including SDF support


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12127

PostPosted: Thu Oct 26, 2017 5:30 pm    Post subject:
Major changes to osgText merged into master, provide high quality text including SDF support
Reply with quote

Hi All,



Over the last couple of months I've been working on changes to osgText that change the way text is rendered with the aim of improving visual quality, in particular when using outline and shadows or zooming and zooming out.


The new implementation uses shaders to implement outline and shadows, the old multi-pass approach has been removed completely.  If your hardware doesn't support shaders then I'm afraid you'll no longer see outlines/shadows by as it's been well over a decade that GLSL has become mainstream I don't think this should be an issue.  Removing the old codes paths help simplify the internals of osgText.


The use of shaders also opens the door to implement new techniques the most significant one is that osgText now support generation of and use of Signed Distance Field (SDF) based glyph textures. The SDF texture data is automatically created from the original grey scale image data that freetype and other font reading plugins provide.  SDF strength is when you zoom in close to the text you get smoother endges without the pixelation that is present with traditional textured glyphs.  Previous to get readable results with large characters on screen we'd need to push up the font resolution really high, using SDF's this is no longer required.


The new shaders also allows us to do multi-sampling in more creative ways that can help address rendering artefacts associated with outline and shadows when zoomed far out from the text - previously text would saturate to the backdrop colour (typically black) and do so with aliasing artefacts.  The new text implementation will provide more smooth transitions from near to far and fade out into the distance in a natural way.


The different techniques from rendering the text are now controlled using the following methods:


1) Setting the text directly:


    text->setShaderTechniqure(osgText::GREYSALE); // the default


    text->setShaderTechniqure(osgText::SIGNED_DISTANCE_FIELD);


    text->setShaderTechniqure(osgText::ALL_FEATURES); // create GlyphTexture with both GREYSCALE and SIGNED_DISTANCE_FIELD, shader defaulting to  SDF


    text->setShaderTechniqure(osgText::NO_TEXT_SHADER); // disable use of shaders



2) Setting the global default value of Text::ShaderTechnique using osg::DisplaySettings::setTextShaderTechnique(..)  :




    osg::DisplaySettings::instance()->setTextShaderTechnque("GREYSCALE");
    osg::DisplaySettings::instance()->setTextShaderTechnque("SIGNED_DISTANCE_FUNCTION");
    osg::DisplaySettings::instance()->setTextShaderTechnque("SDF"); // short for above
    osg::DisplaySettings::instance()->setTextShaderTechnque("ALL_FEATURES");
    osg::DisplaySettings::instance()->setTextShaderTechnque("NO_TEXT_SHADER");
    osg::DisplaySettings::instance()->setTextShaderTechnque("NONE); // short for above












3) Setting the above DisplaySettings::setTextShaderTechnique(..) string using env var:


   export OSG_TEXT_SHADER_TECHNIQUE="SDF"




--


As part of this work I added the ability to assign osg::DisplaySetting assigned user values to shaders using DisplaySettings::setValue(name, value).  You can use this to pass in globals your shaders, which you can leverage for setting things like #version and precision hint, which in turn means you can pass in these settings for different platfrom targets, making it much easier to share shaders between GL2, GL3 and GLES.


To help with this DisplaySetting automatically sets up the follow values:


OSG_GLSL_VERSION
OSG_PRECISION_FLOAT
OSG_VARYING_IN
OSG_VARYING_OUT


When you build the OSG specifically against a GL2, GL3/GLCORE, GLES2 or GLES3 target the appropriate defaults will set, then in your sharer you can use the following syntax:


$OSG_GLSL_VERSION


$OSG_PRECISION_FLOAT


$OSG_VARYING_OUT vec2 texCoord;

$OSG_VARYING_IN vec2 texCoord;



You can have a look at the new OpenSceneGraph-Data/shaders/text.vert and text.frag to see these in action.  Just update to master of OpenSceneGraph-Data to see these shaders.


--


Now while the internals of osgText have changed significantly the API is largely identical so hopefully you'll just need to pull down OSG master and build the OSG and your application and text will just work (using the GREYSCALE default code path.)  Visually it should be pretty similar when using this default - you should start to see improvements when doing things like outlines/shadows or when enabling SDF.



If there are any issues let me know,



Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
makulis
User


Joined: 19 Jan 2015
Posts: 23

PostPosted: Fri Dec 29, 2017 1:54 pm    Post subject:
Text Shader Technque
Reply with quote

Hi Guys,

Can anyone please point me to the branch with the Text Shader Technque? Does anyone know if it has been merged with the master or when maybe that might happen? Sorry if I missed the discussion somewhere with that information. I’ve been looking for it in the master branch and development tags. I can’t find anything.

Thanks in advance.

...

Thank you!

Cheers,
Lincoln
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12127

PostPosted: Sat Dec 30, 2017 3:29 pm    Post subject:
Major changes to osgText merged into master, provide high quality text including SDF support
Reply with quote

Hi Lincoln,

The new osgText function has been checked into master back in October.
It's also part of the latest dev release.

Robert.

On 29 December 2017 at 13:54, Lincoln Nxumalo <> wrote:
Quote:
Hi Guys,

Can anyone please point me to the branch with the Text Shader Technque? Does anyone know if it has been merged with the master or when maybe that might happen? Sorry if I missed the discussion somewhere with that information. I’ve been looking for it in the master branch and development tags. I can’t find anything.

Thanks in advance.

...

Thank you!

Cheers,
Lincoln

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72651#72651








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
makulis
User


Joined: 19 Jan 2015
Posts: 23

PostPosted: Mon Jan 01, 2018 11:44 am    Post subject:
Reply with quote

Hi Robert,

Thank you for the quick reply. I have noticed a major improvement in osgText that's why I was so sure that the merge has been done. However, I am struggling to locate the setTextShaderTechnque() functions in the current master and development releases.

Maybe I'm missing something like a CMake option or do I need to build for a specific GL version?

...

Thank you!

Cheers,
Lincoln
Back to top
View user's profile Send private message
makulis
User


Joined: 19 Jan 2015
Posts: 23

PostPosted: Mon Jan 01, 2018 11:58 am    Post subject:
Reply with quote

Hi Robert,

I managed to find it after all. Sorry about that. I don't know what I was happening. It must be the time of the year. Thanks.

...

Thank you!

Cheers,
Lincoln
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts OpenSceneGraph 3.0 for beginners book... NoeMurr General 5 Fri Oct 12, 2018 3:55 pm View latest post
No new posts About Interleaved Array Support mp3butcher General 4 Tue Oct 09, 2018 11:13 pm View latest post
No new posts osgText 3.6.3 crash Trajce Nikolov NICK General 2 Wed Sep 12, 2018 12:25 pm View latest post
No new posts osgText: two thread-safety issues gwaldron General 1 Tue Jul 31, 2018 2:54 pm View latest post
No new posts Extra draw calls in osgText? gwaldron General 1 Thu Jul 19, 2018 8:48 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP