[osg-users] Text following lines shaders with osgText

Valerian Merkling niarkoleptik at gmail.com
Mon Jan 2 05:25:33 PST 2017


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



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vertex_fragment.glsl.txt
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20170102/5e3a50c1/attachment-0002.txt>


More information about the osg-users mailing list