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 

AutoTransform, ROTATE_TO_SCREEN and small feature culling


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
hartwigw
Appreciator


Joined: 20 Mar 2009
Posts: 128

PostPosted: Mon Mar 26, 2018 9:28 pm    Post subject:
AutoTransform, ROTATE_TO_SCREEN and small feature culling
Reply with quote

Hi,

I found a very old article covering this issue: https://www.mail-archive.com//msg15948.html. In the meantime it seems to be that proposal (2) has been implemented and the AutoTransform's computeBound() method returns an invalid bounding sphere during the first cull traversal. Nevertheless, when checking in the example osgautotransform.cpp the bounding spheres (of the text messages) remain invalid. To check this I have added an update callback to the AutoTransforms that only checks the validity of the bounding sphere.

Now, if the bounding sphere remains invalid culling of the AutoTransform's children will not be correctly performed because the AutoTransform's isCullingActive method will always return false (bounding sphere is invalid).

To solve this issue I was thinking to add a ComputeBoundingSphere callback or an update callback to the AutoTransform. But this is not a good solution because in this case I have to calculate always a new bounding sphere as I do not have access to the node's "_boundingSphereComputed" flag.

Another solution is to patch the node's getBound() method that will set the flag "_boundingSphereComputed" only to true if a valid "_boundingSphere" exists. This sounds reasonable in any case:
Code:
        inline const BoundingSphere& getBound() const
        {
            if(!_boundingSphereComputed)
            {
                _boundingSphere = _initialBound;
                if (_computeBoundCallback.valid())
                    _boundingSphere.expandBy(_computeBoundCallback->computeBound(*this));
                else
                    _boundingSphere.expandBy(computeBound());

                _boundingSphereComputed = _boundingSphere.valid();
            }
            return _boundingSphere;
        }

But I do not know if this breaks anything.

Is there any other method to get a valid bounding sphere for the AutoTransform without sacrificing performance?

Thank you!

Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Tue Mar 27, 2018 7:35 am    Post subject:
AutoTransform, ROTATE_TO_SCREEN and small feature culling
Reply with quote

Hi Hartwig,

CullingActive flag is only effective for the Node that you set it for
and all it's parents, it doesn't disable culling for the children of
the node with CullingActive set.

Robert.

On 26 March 2018 at 22:28, Hartwig Wiesmann <> wrote:
Quote:
Hi,

I found a very old article covering this issue: https://www.mail-archive.com//msg15948.html. In the meantime it seems to be that proposal (2) has been implemented and the AutoTransform's computeBound() method returns an invalid bounding sphere during the first cull traversal. Nevertheless, when checking in the example osgautotransform.cpp the bounding spheres (of the text messages) remain invalid. To check this I have added an update callback to the AutoTransforms that only checks the validity of the bounding sphere.

Now, if the bounding sphere remains invalid culling of the AutoTransform's children will not be correctly performed because the AutoTransform's isCullingActive method will always return false (bounding sphere is invalid).

To solve this issue I was thinking to add a ComputeBoundingSphere callback or an update callback to the AutoTransform. But this is not a good solution because in this case I have to calculate always a new bounding sphere as I do not have access to the node's "_boundingSphereComputed" flag.

Another solution is to patch the node's getBound() method that will set the flag "_boundingSphereComputed" only to true if a valid "_boundingSphere" exists. This sounds reasonable in any case:

Code:
inline const BoundingSphere& getBound() const
{
if(!_boundingSphereComputed)
{
_boundingSphere = _initialBound;
if (_computeBoundCallback.valid())
_boundingSphere.expandBy(_computeBoundCallback->computeBound(*this));
else
_boundingSphere.expandBy(computeBound());

_boundingSphereComputed = _boundingSphere.valid();
}
return _boundingSphere;
}



But I do not know if this breaks anything.

Is there any other method to get a valid bounding sphere for the AutoTransform without sacrificing performance?

Thank you!

Cheers,
Hartwig

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73174#73174








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hartwigw
Appreciator


Joined: 20 Mar 2009
Posts: 128

PostPosted: Tue Mar 27, 2018 4:44 pm    Post subject:
Reply with quote

Hi Robert,

I was not talking about the cullingActive flag but the method isCullingActive! isCullingActive checks besides the cullingActive flag if the boundary sphere is valid. As long as the boundary sphere is invalid isCullingActive() returns false. This is the problem I reported.

Code:
inline bool isCullingActive() const { return _numChildrenWithCullingDisabled==0 && _cullingActive && getBound().valid(); }



Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Wed Mar 28, 2018 9:03 am    Post subject:
AutoTransform, ROTATE_TO_SCREEN and small feature culling
Reply with quote

Hi Hartwig,

On 27 March 2018 at 17:44, Hartwig Wiesmann <> wrote:
Quote:
I was not talking about the cullingActive flag but the method isCullingActive! isCullingActive checks besides the cullingActive flag if the boundary sphere is valid. As long as the boundary sphere is invalid isCullingActive() returns false. This is the problem I reported.

This is by design, you can't cull something that doesn't have a valid
bounding volume as culling tests are based on the bounding volume.

For AutoTransform the bounding volume change per frame, especially so
if it's being scaled to screen space as it's size can grow and shrink,
so in this case leaving it undefined is the one safe thing to do.

As for children of an AutoTransform not being culled, this is
incorrect, the children's culling will be done in their own right,
what happens to the parents will no affect this.

As a general note, AutoTransform is not something I would recommend
using for large numbers of objects in your scene as it not only
presents issues with cullng itself but also forces the cull traversal
to transform the view frustum into the children coordinate frame, this
involves pushing/popping view frustum state on and off a stack as
well.

I don't know the specifics of your scene graph or the particular
performance issues you are trying to address, but it may well be that
pushing the task of rotating/scaling to a vertex or geometry shader
might be the best way to refactor your scene graph for best
performance.

Robert.


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


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Thu Mar 29, 2018 7:34 am    Post subject:
AutoTransform, ROTATE_TO_SCREEN and small feature culling
Reply with quote

HI Hatwig,

The code is correct, you can't cull something that you don't have a
valid bounding volume for. Distabling culling for a particular node
only affect that node and all it's parents, it does affect culling of
the children which can still have their own culling be effective.

If you don't like the default behaviour of AutoTransform w.r.t
bounding volume calculation you can always write your own or subclass
from AutoTransform to specialise it to be compatible with a fixed
bounding volume,

Robert.



On 27 March 2018 at 17:44, Hartwig Wiesmann <> wrote:
Quote:
Hi Robert,

I was not talking about the cullingActive flag but the method isCullingActive! isCullingActive checks besides the cullingActive flag if the boundary sphere is valid. As long as the boundary sphere is invalid isCullingActive() returns false. This is the problem I reported.


Code:
inline bool isCullingActive() const { return _numChildrenWithCullingDisabled==0 && _cullingActive && getBound().valid(); }




Cheers,
Hartwig

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73183#73183








------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hartwigw
Appreciator


Joined: 20 Mar 2009
Posts: 128

PostPosted: Thu Mar 29, 2018 9:51 pm    Post subject:
Reply with quote

Hi Robert,

what I would like to produce is an object that is always oriented towards the user (screen) and has the same size independent of the zoom level. Though the zoom level is limited in a certain range by an additional LOD.
Therefore, I think that AutoTranslate is the only viable option, or?

Thank you!

Cheers,
Hartwig
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12094

PostPosted: Fri Mar 30, 2018 6:53 am    Post subject:
AutoTransform, ROTATE_TO_SCREEN and small feature culling
Reply with quote

Hi Hartwig,

On 29 March 2018 at 22:51, Hartwig Wiesmann <> wrote:
Quote:
what I would like to produce is an object that is always oriented towards the user (screen) and has the same size independent of the zoom level. Though the zoom level is limited in a certain range by an additional LOD.
Therefore, I think that AutoTranslate is the only viable option, or?

You can also implement your own subclasses from
osg::Node/osg::Transform or even osg::AutoTransform.

You can also implement billboard with vertex shaders.

So there are plenty of viable options.

Robert.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
hartwigw
Appreciator


Joined: 20 Mar 2009
Posts: 128

PostPosted: Fri Mar 30, 2018 9:52 pm    Post subject:
Reply with quote

Hi Robert,

I want to come back to my original remark that culling does not work correctly with AutoTransforms and ROTATE_TO_SCREEN.

I have modified the example osgautotransform.cpp by adding a new class that contains an AutoTransform and a drawable (showing a simple box). An object of this class is added to the scene whose auto-scale to screen flag is set to true. The root cause for the bug is that a wrong bounding sphere might be cached that leads to culling of the AutoTransform-node when it is not appropriate.

To verify the bug the following steps have to be performed:

1) zoom into the scene
2) press 'd' (this marks the bounds of all objects of the scene as dirty)
3) zoom out of the scene
4) the box disappears while zooming out

The reason of the disappearance of the box is that a bounding sphere has been cached after all objects have been marked as dirty. When zooming out this bounding box is not modified anymore. After a while the size of the bounding box reaches the pixel size for small features and the AutoTransform object and its children are culled. Though the children should not be culled because they are auto-scaled to screen coordinates.

Cheers,
Hartwig
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 Culling and instanced drawing wernerM General 7 Fri Jul 13, 2018 4:45 pm View latest post
No new posts AutoTransform for scale 3.6.0 bcolbert General 1 Mon Jun 18, 2018 5:07 pm View latest post
No new posts Camera serializer and culling mp3butcher General 1 Sat Apr 21, 2018 12:16 pm View latest post
No new posts Small fix in osgdb_osgjs Andreas Ekstrand Submission 1 Sat Mar 31, 2018 6:01 pm View latest post
No new posts Prevention of near plane culling whil... hartwigw General 3 Sat Mar 10, 2018 7:57 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