[osg-users] Show part of geometry which intersects a specific area

Robert Osfield robert.osfield at gmail.com
Fri Mar 30 08:20:46 PDT 2018

Hi Ali,

I had some time for looking into bugs this afternoon so I have
modified the osgclip example to allow one to pass in a osgText::Text
as the subgraph for clipping and this confirmed that clipping isn't
working for osgText::Text in the 3.4 branch.

  osgclip --text MY_TEST

Is sufficient to run the new test.  You'll need update to 3.4 banch,
3.6 branch or master to get this example.  The commit that provides
the new test code is:


I have done a review of the osgText::Text implementation in the 3.4
branch and can't see any where when clipping is explicitly disabled so
I'm surprised it's not functioning OK.  Unfortunately I couldn't spot
any good lead to investigate, I can only guess that there is some
interaction with the way the the old osgText 3.4 code renders text
using a multi-pass approach where is toggles on/off the color mask and
depth writes.  Without an obvious reason for failure I can't see a way
of resolving the problem for the 3.4 branch.

The test also failed with OSG master and the new OpenScenGraph-3.6
branch, but this was easy to fix as osgText implementation has been
almost completely rewritten since 3.4, and now uses shaders.  The fix
was simply the add setting of the gl_ClipVertex into the shader and
then the everything works fine.  The new osgText implementation
doesn't implement using lots of toggling of state or is saddled with
multi-pass approach so is cleaner, as well as provides better visual
quality and some new approaches such as using Signed Distance Function
(you need to enable this on osgText::Font to use it.)

The fix to the OpenSceneGraph-3.6 branch is:


I also updated the OpenSceneGraph-Data as this contains the
shaders/text.vert this is embedded in the source of the osgText
library - which the above commit modifies.

As the OpenSceneGrpah-3.6.0 stable release is imminent, I would
suggest just moving to the 3.6 branch or the release candidate 3
branch I'll be making this afternoon, as this should resolve the
problem you are seeing.


More information about the osg-users mailing list