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 

osgText: problem with SCREEN_COORDS mode


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
gwaldron (Glenn Waldron)
Appreciator


Joined: 25 Aug 2011
Posts: 206

PostPosted: Thu May 17, 2018 3:56 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Robert,I am getting the following problem with the tip of the OpenSceneGraph-3.6 branch. (I am building under GL CORE profile on WIn64 but suspect that is not a factor.)


This a simple osgText drawable in SCREEN_COORDS mode, tilted just a bit along the X axis:





Here is a minimal application to reproduce the problem:



https://pastebin.com/nuySbs8L



Run this and then use the mouse to slowly tilt the scene. The text becomes stretched.

Glenn Waldron

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
gwaldron (Glenn Waldron)
Appreciator


Joined: 25 Aug 2011
Posts: 206

PostPosted: Thu May 17, 2018 4:11 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Following up on my own post Smile

https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgText/TextBase.cpp#L520



I think that rotation matrices will result in an incorrect computation of the "left" and "up" vectors. So I think we need to use the translation and scale only by removing "rotate_matrix" and also removing the rotation component of "modelview". A quick test yields better results on my end. Thoughts?
Glenn Waldron







On Thu, May 17, 2018 at 11:55 AM Glenn Waldron < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Robert,I am getting the following problem with the tip of the OpenSceneGraph-3.6 branch. (I am building under GL CORE profile on WIn64 but suspect that is not a factor.)


This a simple osgText drawable in SCREEN_COORDS mode, tilted just a bit along the X axis:





Here is a minimal application to reproduce the problem:



https://pastebin.com/nuySbs8L



Run this and then use the mouse to slowly tilt the scene. The text becomes stretched.

Glenn Waldron








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Thu May 17, 2018 5:05 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Hi Glenn,


I haven't had a chance to look at your example yet, but at a guess I would suspect that the code trying to maintain the on screen aspect ratio of the text is struggling more and more as your rotate the text away from being orthogonal with the screen.  If so then we need to ask the question whether it's sensible to allow one to rotate text when in screen coords.  



Once I have a breather from my present intense bit of client work I'll have a deeper look.



Robert.



On 17 May 2018 at 17:10, Glenn Waldron < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Following up on my own post Smile

https://github.com/openscenegraph/OpenSceneGraph/blob/master/src/osgText/TextBase.cpp#L520



I think that rotation matrices will result in an incorrect computation of the "left" and "up" vectors. So I think we need to use the translation and scale only by removing "rotate_matrix" and also removing the rotation component of "modelview". A quick test yields better results on my end. Thoughts?
Glenn Waldron







On Thu, May 17, 2018 at 11:55 AM Glenn Waldron < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Robert,I am getting the following problem with the tip of the OpenSceneGraph-3.6 branch. (I am building under GL CORE profile on WIn64 but suspect that is not a factor.)


This a simple osgText drawable in SCREEN_COORDS mode, tilted just a bit along the X axis:





Here is a minimal application to reproduce the problem:



https://pastebin.com/nuySbs8L



Run this and then use the mouse to slowly tilt the scene. The text becomes stretched.

Glenn Waldron










_______________________________________________
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
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Fri May 18, 2018 10:28 am    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Hi Glenn,


I have now looked at your test program and can reproduce the stretched text.  


The example is a bit unusual in that you have text size set to SCREEN_COORDS but the orientation of the text is free to move with the scene as it gets rotated by the viewer's camera,


What I'd normally expect is that if you are using:



    text->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);


Then it would be normal to also us:


    text->setAxisAlignment(osgText::Text::SCREEN);


Adding this to your test example fixes the issue.  So I'm curious, do you have an instance where the character size should be scaled to SCREEN_COORDS but with the AxisAlignment set to SCREEN.


As a general comment, if you are scaling the text to screen coords the rotation of the text will be important to take into account as the aspect ratio of the window can be altered so required the horizontal and vertical scaling can be different, which will be affected by the rotation of the text.


At this point I don't think we are looking at a bug, rather just an odd behaviour when using text is an odd way.



Robert.

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
gwaldron (Glenn Waldron)
Appreciator


Joined: 25 Aug 2011
Posts: 206

PostPosted: Sat May 19, 2018 10:59 am    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Robert,Thank you for look into this. Indeed, my use case is an earth graticule with labels in the grid cells.


As the labels become more rotated away from the camera, things begin to break down:





Removing the rotational elements yields a better result:





I understand that just removing rotations might cause other side effects so maybe there's a better approach.


Even if this is not a bug, it is a regression relative to OSG 3.4.1. Let me know if you want me to do any further testing. 

Glenn Waldron









On Fri, May 18, 2018 at 6:27 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Glenn,


I have now looked at your test program and can reproduce the stretched text.  


The example is a bit unusual in that you have text size set to SCREEN_COORDS but the orientation of the text is free to move with the scene as it gets rotated by the viewer's camera,


What I'd normally expect is that if you are using:



    text->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);


Then it would be normal to also us:


    text->setAxisAlignment(osgText::Text::SCREEN);


Adding this to your test example fixes the issue.  So I'm curious, do you have an instance where the character size should be scaled to SCREEN_COORDS but with the AxisAlignment set to SCREEN.


As a general comment, if you are scaling the text to screen coords the rotation of the text will be important to take into account as the aspect ratio of the window can be altered so required the horizontal and vertical scaling can be different, which will be affected by the rotation of the text.


At this point I don't think we are looking at a bug, rather just an odd behaviour when using text is an odd way.



Robert.


_______________________________________________
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
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Sat May 19, 2018 11:20 am    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Hi Glenn,


While I haven't got to the bottom of the change in behaviour, I am not sure that SCREEN_COORDS scaling is wholly appropriate for you usage case, the originally behaviour might have worked OK for you but I know it wasn't working 100% correct w.r.t scaling.


If I could rewrite osgText without worrying about backwards compatibility I most like wouldn't push scaling and auto rotation functionality in the basic osgText, rather I'd leave this to AutoTransform/Billboard type nodes.  As we are trying to walk the tightrope of retaining backwards compatibility and fixing bugs we have less wriggle room.


At this point in time I don't know if the new SCREEN_COORDS should behave how you are wanting it to behave as strictly you can't have it scaling in screen coords if the text isn't aligned to the screen.  What you are probably after is uniform scaling of the text based on it's center, but not clear on how one would encode that into an actual function to get the exact behaviour you want.   This is where making it a custom behaviour would allow users to resolve this.  Subclassing from osgText is possible so perhaps this is an avenue.



Robert.



On 18 May 2018 at 18:01, Glenn Waldron < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
Robert,Thank you for look into this. Indeed, my use case is an earth graticule with labels in the grid cells.


As the labels become more rotated away from the camera, things begin to break down:





Removing the rotational elements yields a better result:





I understand that just removing rotations might cause other side effects so maybe there's a better approach.


Even if this is not a bug, it is a regression relative to OSG 3.4.1. Let me know if you want me to do any further testing. 

Glenn Waldron









On Fri, May 18, 2018 at 6:27 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:



Quote:
Hi Glenn,


I have now looked at your test program and can reproduce the stretched text.  


The example is a bit unusual in that you have text size set to SCREEN_COORDS but the orientation of the text is free to move with the scene as it gets rotated by the viewer's camera,


What I'd normally expect is that if you are using:



    text->setCharacterSizeMode(osgText::Text::SCREEN_COORDS);


Then it would be normal to also us:


    text->setAxisAlignment(osgText::Text::SCREEN);


Adding this to your test example fixes the issue.  So I'm curious, do you have an instance where the character size should be scaled to SCREEN_COORDS but with the AxisAlignment set to SCREEN.


As a general comment, if you are scaling the text to screen coords the rotation of the text will be important to take into account as the aspect ratio of the window can be altered so required the horizontal and vertical scaling can be different, which will be affected by the rotation of the text.


At this point I don't think we are looking at a bug, rather just an odd behaviour when using text is an odd way.



Robert.




_______________________________________________
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


_______________________________________________
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
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Sat May 19, 2018 3:52 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Hi Glenn,

On 19 May 2018 at 12:11, Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:
While I haven't got to the bottom of the change in behaviour, I am not sure that SCREEN_COORDS scaling is wholly appropriate for you usage case


I have been thinking so more and now wonder if we can check whether the Text::CharacterSizeMode and AxisAlignment should be both checked for in the TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const method and have different behaviour based on the different combinations.  The current implementation assumes that AxisAlignment is SCREEN when CharacterSizeMode is SCREEN_COORDS, this is what I'd would normally expect users to set up together as it there isn't an obvious mapping for when AxisAlignment isn't SCREEN when CharacterSizeMode is SCREEN_COORDS. 



I'm not sure what the most robust way to handle SCREEN_COORDS when AxisAlignemtn isn't SCREEN, perhaps one could use AxisAlignment directions so give up and side vectors that one could project onto the screen, or combine both, or perhaps use the normal vector as well when trying to infer what the scaling should be. 



Robert.



 


 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Sun May 20, 2018 12:35 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Hi Glenn,

I have tried various ways to try and make the scale of the text
consistent when using CharacterSizeMode is SCREEN_COORDS whle
AxisAlignment is not SCREEN but in the end found the only solution
that produces consistent results was to apply the same maths as was
being use for the auto rotate case, except the auto-rotation itself is
ignored when generating the final matrix.

What I have checked in is:
https://github.com/openscenegraph/OpenSceneGraph/commit/55c0afbe3ad2c6587f8c329a7dcc61284d8d18b9

This is also checked into OSG master.

To help test the various possibilities out I amend you test example to
have --xy, --xz, --screen etc. command line options for setting how to
set the axis alignment of the text. This amended version is attached.
With the above fix everything looks to be working fine, at least for
the case of this test, the tests that other users have posted and
osgtext. Fingers crossed this means that osgText is now working
solidly for 3.6.1.

Cheers,
Robert.



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
gwaldron (Glenn Waldron)
Appreciator


Joined: 25 Aug 2011
Posts: 206

PostPosted: Mon May 21, 2018 5:29 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Robert,Thanks for looking into this. Your update works well.


I have one additional request: the computing of the origin, left, and up vectors (lines 517-519) need to be done in double-precision. In my graticule example, the text jitters as you manipulate the scene; changing those lines to use osg::Vec3d resolves the issue. I have submitted a PR.
Glenn Waldron / osgEarth








On Sun, May 20, 2018 at 8:34 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Glenn,

I have tried various ways to try and make the scale of the text
consistent when using CharacterSizeMode is SCREEN_COORDS whle
AxisAlignment is not SCREEN but in the end found the only solution
that produces consistent results was to apply the same maths as was
being use for the auto rotate case, except the auto-rotation itself is
ignored when generating the final matrix.

What I have checked in is:
   https://github.com/openscenegraph/OpenSceneGraph/commit/55c0afbe3ad2c6587f8c329a7dcc61284d8d18b9

This is also checked into OSG master.

To help test the various possibilities out I amend you test example to
have --xy, --xz, --screen etc. command line options for setting how to
set the axis alignment of the text.  This amended version is attached.
With the above fix everything looks to be working fine, at least for
the case of this test, the tests that other users have posted and
osgtext.  Fingers crossed this means that osgText is now working
solidly for 3.6.1.

Cheers,
Robert.
_______________________________________________
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
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11758

PostPosted: Mon May 21, 2018 7:07 pm    Post subject:
osgText: problem with SCREEN_COORDS mode
Reply with quote

Thanks Glenn, PR merged with master and the 3.6 branch.

On 21 May 2018 at 18:28, Glenn Waldron <> wrote:
Quote:
Robert,
Thanks for looking into this. Your update works well.

I have one additional request: the computing of the origin, left, and up
vectors (lines 517-519) need to be done in double-precision. In my graticule
example, the text jitters as you manipulate the scene; changing those lines
to use osg::Vec3d resolves the issue. I have submitted a PR.

Glenn Waldron / osgEarth


On Sun, May 20, 2018 at 8:34 AM Robert Osfield <>
wrote:
Quote:

Hi Glenn,

I have tried various ways to try and make the scale of the text
consistent when using CharacterSizeMode is SCREEN_COORDS whle
AxisAlignment is not SCREEN but in the end found the only solution
that produces consistent results was to apply the same maths as was
being use for the auto rotate case, except the auto-rotation itself is
ignored when generating the final matrix.

What I have checked in is:

https://github.com/openscenegraph/OpenSceneGraph/commit/55c0afbe3ad2c6587f8c329a7dcc61284d8d18b9

This is also checked into OSG master.

To help test the various possibilities out I amend you test example to
have --xy, --xz, --screen etc. command line options for setting how to
set the axis alignment of the text. This amended version is attached.
With the above fix everything looks to be working fine, at least for
the case of this test, the tests that other users have posted and
osgtext. Fingers crossed this means that osgText is now working
solidly for 3.6.1.

Cheers,
Robert.







------------------
Post generated by Mail2Forum
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 [customizing manipulator] problem wit... mp3butcher General 1 Tue Apr 24, 2018 3:19 pm View latest post
No new posts Having issue with osgText rendering o... pixelord General 0 Mon Apr 16, 2018 4:16 am View latest post
No new posts OSG & QtQuick(QML) & setMirro... karcios General 0 Wed Apr 11, 2018 12:45 pm View latest post
No new posts Problems with osgText::Text internal ... brianh General 3 Tue Mar 20, 2018 10:45 am View latest post
No new posts set cullface mode in osg file Meldryt General 1 Fri Mar 02, 2018 10:07 am 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