[osg-users] Text following lines shaders with osgText

Robert Osfield robert.osfield at gmail.com
Thu Jan 5 02:36:07 PST 2017


Hi Valerian,

osgText doesn't support placing the glyphs on anything others that a
straight line, trying to adapt it to do this is not straight forward
so would not recommend this route.

A better approach would be create an osg::Geometry that contains one
or of your text labels with the glyph quads placed exactly where you
want them.  You could leverage osgText for details of the glyph
texture coordinates and the texture objects etc.

A basic implementation of this approach wouldn't need shaders, but can
be extended to use shaders.

Robert.


On 2 January 2017 at 13:25, Valerian Merkling <niarkoleptik at gmail.com> wrote:
> Hi,
>
> I'm currently working on osg 3.4.0 on windows 7, my shaders are #version 120, and I'm using #extension GL_ARB_texture_rectangle.
>
> I almost made a shader able to draw a text all along the selected line.
>
> My main goal can be seen here : http://docs.geoserver.org/stable/en/user/_images/label_underlines.png
> where labels like "primary a road" and "non primary A road" are following the lines.
>
> Maps can be viewed with an ortho2D camera, and the text size needs to be constant while playing with zoom.
>
> Right now, I apply the shader to the osgText object, and use as uniform the current zoom scale and the line coords.
>
> After a few days of work, It is almost OK but I have a maybe unsolvable problem in my vertex fragment :
> - broken line is a set of segments
> - Each letter is 4 vertices, but each of these vertices are processed - individually.
> - I can tell, for each vertices, which segments to use
> - I cannot be sure that all 4 vertices of one letter are tied to the same segment
>
> As far as I understand shaders, the vertex fragment is called for each vertices, and there is no way to pass any information from a call to another, so when I'm compution the position of the upper right corner of a letter, the position of the upper left corner can't be reached, and that why I am stuck.
>
> I'm not really familliar with shaders (this one is the first I ever created) so I may be forgetting the obvious, and that's why I need your help !
>
> The only solution I can see is to generate an osgText object for each letter, but I don't know if it is a good idea...
>
> I may also be able to upgrade to a better shader level if needed, but I don't even know if it could help me.
>
> Thank you!
>
> Cheers,
> Valerian
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=69823#69823
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list