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 

Cloning text


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Andreas Ekstrand
Guest





PostPosted: Fri Aug 18, 2017 8:16 am    Post subject:
Cloning text
Reply with quote

Hi,

With OSG 3.2.1 I have been able to do fast shallow cloning of osgText::Text in my own subclass, copying the _textureGlyphQuadMap instead of calling computeGlyphRepresentation, since the latter is a slow operation for my thousands of texts.

In OSG 3.5.6 this isn't possible, I guess due to a private GlyphQuads::operator=. So I'm looping through _textureGlyphQuadMap in my copy constructor and copy its glyphs and primitives separately instead. But I can't see my copied text at all! If I save it out to an .osg or .osgt file it's visible in osgviewer.

I guess setting GlyphQuads::operator= private was deliberate, so can someone explain how I can accomplish fast text cloning in OSG 3.5.6 or optimize it somehow?

Regards,
Andreas

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11238

PostPosted: Fri Aug 18, 2017 9:39 am    Post subject:
Cloning text
Reply with quote

Hi Andreas,


In my rewrite of osgText my approach was that the internal implementation details aren't meant to be something that users need to meddle with.


The fact that you are needing to meddle with the internal details to workaorund performance issues in your usage case suggest an issue with basic performance/flexibility,  The new implementation might change this performance/flexibility side so perhaps your local changes might not be needed.


If the new osgText doesn't provide the performance you need for your usage case perhaps it could be optimized to handle them.  Creating an example that illustrates the usage case which highlights the issues would be a good first step if you feel this approach has promise.


Finally, I'm open to small tweaks to the API allow easier subclassing. However, this isn't my preferred approach as any changes to the internals later would then break end user code that relies upon it - exactly the problem you are facing now...


Robert.



On 18 August 2017 at 09:14, Andreas Ekstrand < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

With OSG 3.2.1 I have been able to do fast shallow cloning of osgText::Text in my own subclass, copying the _textureGlyphQuadMap instead of calling computeGlyphRepresentation, since the latter is a slow operation for my thousands of texts.

In OSG 3.5.6 this isn't possible, I guess due to a private GlyphQuads::operator=. So I'm looping through _textureGlyphQuadMap in my copy constructor and copy its glyphs and primitives separately instead. But I can't see my copied text at all! If I save it out to an .osg or .osgt file it's visible in osgviewer.

I guess setting GlyphQuads::operator= private was deliberate, so can someone explain how I can accomplish fast text cloning in OSG 3.5.6 or optimize it somehow?

Regards,
Andreas



_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Andreas Ekstrand
Guest





PostPosted: Fri Sep 08, 2017 1:19 pm    Post subject:
Cloning text
Reply with quote

Hi,

I revisited my osgText performance issue by measuring the time for copying text.

With some 150,000 copies of my VertexNumber class inheriting from osgText::Text, I ended up with roughly the following figures using OSG 3.5.6, compared to my previous solution using OSG 3.2.1, calling the osgText::TextBase copy constructor from my copy constructor (skipping over osgText::Text copy constructor) and copying the _textureGlyphQuadMap instead of calling the slower computeGlyphRepresentation.

3.2.1 without the "trick" above:
40 - 70% slower compared to 3.2.1 with trick

3.5.6 (obviously without the trick):
50 - 90% slower compared to 3.2.1 with trick
10 - 30% slower compared to plain 3.2.1 without trick

Furthermore, in 3.5.6 my application requires about 37% more RAM with this number of texts, compared to 3.2.1 (both with and without the trick), but only about 4% more without the texts created.

I'm creating and caching new text instances per vertex number in the model. Since there are mostly triangles, I'm getting 0,1,2 but also occasional other numbers up to 7 for special polygons. For a situation like this, with a large number of texts from a small number of cached originals, what would be the recommended approach? Maybe osgText isn't suitable at all?

Regards,
Andreas



On 2017-08-18 11:38, Robert Osfield wrote:

Quote:
Hi Andreas,


In my rewrite of osgText my approach was that the internal implementation details aren't meant to be something that users need to meddle with.


The fact that you are needing to meddle with the internal details to workaorund performance issues in your usage case suggest an issue with basic performance/flexibility,  The new implementation might change this performance/flexibility side so perhaps your local changes might not be needed.


If the new osgText doesn't provide the performance you need for your usage case perhaps it could be optimized to handle them.  Creating an example that illustrates the usage case which highlights the issues would be a good first step if you feel this approach has promise.


Finally, I'm open to small tweaks to the API allow easier subclassing. However, this isn't my preferred approach as any changes to the internals later would then break end user code that relies upon it - exactly the problem you are facing now...


Robert.



On 18 August 2017 at 09:14, Andreas Ekstrand < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Hi,

With OSG 3.2.1 I have been able to do fast shallow cloning of osgText::Text in my own subclass, copying the _textureGlyphQuadMap instead of calling computeGlyphRepresentation, since the latter is a slow operation for my thousands of texts.

In OSG 3.5.6 this isn't possible, I guess due to a private GlyphQuads::operator=. So I'm looping through _textureGlyphQuadMap in my copy constructor and copy its glyphs and primitives separately instead. But I can't see my copied text at all! If I save it out to an .osg or .osgt file it's visible in osgviewer.

I guess setting GlyphQuads::operator= private was deliberate, so can someone explain how I can accomplish fast text cloning in OSG 3.5.6 or optimize it somehow?

Regards,
Andreas



_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org






Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11238

PostPosted: Fri Sep 08, 2017 3:11 pm    Post subject:
Cloning text
Reply with quote

Hi Andreas,


I am bit surprised by the extra memory footprint, as I'm currently working on osgText::Text I don't want to start diving into code that may well disappear once my work is complete.  The new osgText::Text implementation relies upon shaders to do outline and shadows rather than multipass and should simplify the internals a bit.  Given this the balance of memory overhead is likely to change.


As a general comment, creating a 150,000 copies of an object is something that raise a red flag - suggesting that you are working around an issue that may well be better solved with a different approach, perhaps not using osgText::Text at all.



Could you explain from a higher level what you are wanting to do with all these text labels?



Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Andreas Ekstrand
Guest





PostPosted: Fri Sep 22, 2017 8:40 am    Post subject:
Cloning text
Reply with quote

Hi,

I'm using osgText to show vertex numbers. Often enough it's only 0,1,2 for triangles but it can be several hundred thousands of them.

It's never been optimal, I know - and I guess this is the time to do something about it, I will look into an alternative way without osgText. Any suggestions are welcome!

Regards,
Andreas



On 2017-09-08 17:09, Robert Osfield wrote:

Quote:
Hi Andreas,


I am bit surprised by the extra memory footprint, as I'm currently working on osgText::Text I don't want to start diving into code that may well disappear once my work is complete.  The new osgText::Text implementation relies upon shaders to do outline and shadows rather than multipass and should simplify the internals a bit.  Given this the balance of memory overhead is likely to change.


As a general comment, creating a 150,000 copies of an object is something that raise a red flag - suggesting that you are working around an issue that may well be better solved with a different approach, perhaps not using osgText::Text at all.



Could you explain from a higher level what you are wanting to do with all these text labels?



Robert.



Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11238

PostPosted: Fri Sep 22, 2017 10:13 am    Post subject:
Cloning text
Reply with quote

Hi Andreas.

On 22 September 2017 at 09:40, Andreas Ekstrand < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
I'm using osgText to show vertex numbers. Often enough it's only 0,1,2 for triangles but it can be several hundred thousands of them.

It's never been optimal, I know - and I guess this is the time to do something about it, I will look into an alternative way without osgText. Any suggestions are welcome!



On the OSG side I steadily shifting osgText to using shaders for effects and simplifying the CPU side.  Not all the way there yet but that's the direction I'm going with it.  Simplifying the CPU side will mean less custom data manipulation that is different frrom osg::Geometry that just pushes arrays and primitives to GL.  With these evolution of osgText the overhead for creating new text should be lower.


However, osgText it will always be a general purpose text implementation rather than a highly tuned for a specific purpose.  In your case it might be simpler to do some specifically your task.  If you have just 0..9 characters and a limited number of characters you start thinking about doing far more on the GPU. 



For instance you could use a single textured quad for each label, passing in the characters to render via a uniform array or packed uniforms and have a shader work out what texture coordinates into the glyph texture atlas to use to render each character, then in the fragment shader get the appropriate samples for each character.  I have used this approach on client project to make a very lightweight system for rendering labels, it was a closed source project so not something I can share the implementation, but it does at least show it works.


Another approach you could take is just create your own osg::Geometry and reuse the osgText::Font/osgText::GlyhTexture. In the end basic rendering of text is just texture quads, osgText can be used to provide the texture atlas you need so most of the awkward work is done for you already.



Robert.









 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Andreas Ekstrand
Guest





PostPosted: Fri Sep 22, 2017 10:43 am    Post subject:
Cloning text
Reply with quote

Thanks for the suggestions, Robert! I was just investigating such possibilities, shows I'm on the right track...
/Andreas


On 2017-09-22 12:13, Robert Osfield wrote:

Quote:
Hi Andreas.

On 22 September 2017 at 09:40, Andreas Ekstrand < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
I'm using osgText to show vertex numbers. Often enough it's only 0,1,2 for triangles but it can be several hundred thousands of them.

It's never been optimal, I know - and I guess this is the time to do something about it, I will look into an alternative way without osgText. Any suggestions are welcome!



On the OSG side I steadily shifting osgText to using shaders for effects and simplifying the CPU side.  Not all the way there yet but that's the direction I'm going with it.  Simplifying the CPU side will mean less custom data manipulation that is different frrom osg::Geometry that just pushes arrays and primitives to GL.  With these evolution of osgText the overhead for creating new text should be lower.


However, osgText it will always be a general purpose text implementation rather than a highly tuned for a specific purpose.  In your case it might be simpler to do some specifically your task.  If you have just 0..9 characters and a limited number of characters you start thinking about doing far more on the GPU. 



For instance you could use a single textured quad for each label, passing in the characters to render via a uniform array or packed uniforms and have a shader work out what texture coordinates into the glyph texture atlas to use to render each character, then in the fragment shader get the appropriate samples for each character.  I have used this approach on client project to make a very lightweight system for rendering labels, it was a closed source project so not something I can share the implementation, but it does at least show it works.


Another approach you could take is just create your own osg::Geometry and reuse the osgText::Font/osgText::GlyhTexture. In the end basic rendering of text is just texture quads, osgText can be used to provide the texture atlas you need so most of the awkward work is done for you already.



Robert.









 





Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
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 Major changes to osgText merged into ... robertosfield General 0 Thu Oct 26, 2017 5:30 pm View latest post
No new posts osg::Text::setBackdropType crash with... Carlo Lanzotti - DynaD... General 7 Wed Sep 20, 2017 2:40 pm View latest post
No new posts osgText::Text problem robertosfield General 5 Thu Aug 17, 2017 12:23 pm View latest post
No new posts A problem of depth on osgText::Text i... gyw General 4 Mon Jul 10, 2017 7:29 am View latest post
No new posts How to color each character of an osg... lq37 General 0 Thu Jun 22, 2017 1:31 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