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 

Deep cloning an active root scene node


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





PostPosted: Thu Feb 28, 2019 5:52 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Hi all, my name is Rob.


I'm currently writing a plugin for an OSG based application. I effectively want to create a snapshot of the application's scene graph state and pass it to another thread where I can render to a texture, while the main rendering thread continues with minimal interruption. 


I'd like to do this because blocking the main thread with a osgViewer::Viewer::frame() call causes the application to lock up and prevents me from displaying a progress dialog. The scene I render takes a long time because I render many camera views to a single texture. 



I'm currently trying to do this:


osg::Node* sceneCopy = dynamic_cast<osg::Node*>(sceneData_->clone(osg::CopyOp::DEEP_COPY_ALL));



Then passing this to another thread where I run:


viewer_ = new osgViewer::Viewer();
viewer_->setSceneData(sceneCopy);


However the behavior seems inconsistent. It either dies on a null reference inside osgEarth somewhere or it renders an empty scene. I don't think I fully understand the threading model of OSG, I've read a bit here and there, but I think there's a lot I'm still missing. 


Is there a safe way to copy the scene data and use it to run an isolated viewer like this in parallel? Is it even safe to run two viewers in parallel like this at all?


Cheers,

Rob























This email and any attachments are confidential and may be privileged. Any unauthorized use, disclosure, copying or distribution of the information received is prohibited. If you are not the intended recipient please contact the sender immediately by return email confirming that you have and will delete all communications related to the email and any attachments sent to you in error.

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


Joined: 18 Mar 2009
Posts: 12348

PostPosted: Thu Feb 28, 2019 6:54 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Hi Rob,

The OSG is design to allow you to rendering multiple views at once,
there is no need to clone the scene graph, you simply add another View
to a CompositeView to add the extra rendering. You can toggle
optional View's on/off as you need them.

Robert.

On Thu, 28 Feb 2019 at 17:51, Robert Lockyer
<> wrote:
Quote:

Hi all, my name is Rob.

I'm currently writing a plugin for an OSG based application. I effectively want to create a snapshot of the application's scene graph state and pass it to another thread where I can render to a texture, while the main rendering thread continues with minimal interruption.

I'd like to do this because blocking the main thread with a osgViewer::Viewer::frame() call causes the application to lock up and prevents me from displaying a progress dialog. The scene I render takes a long time because I render many camera views to a single texture.

I'm currently trying to do this:

osg::Node* sceneCopy = dynamic_cast<osg::Node*>(sceneData_->clone(osg::CopyOp::DEEP_COPY_ALL));

Then passing this to another thread where I run:

viewer_ = new osgViewer::Viewer();
viewer_->setSceneData(sceneCopy);

However the behavior seems inconsistent. It either dies on a null reference inside osgEarth somewhere or it renders an empty scene. I don't think I fully understand the threading model of OSG, I've read a bit here and there, but I think there's a lot I'm still missing.

Is there a safe way to copy the scene data and use it to run an isolated viewer like this in parallel? Is it even safe to run two viewers in parallel like this at all?

Cheers,
Rob

This email and any attachments are confidential and may be privileged. Any unauthorized use, disclosure, copying or distribution of the information received is prohibited. If you are not the intended recipient please contact the sender immediately by return email confirming that you have and will delete all communications related to the email and any attachments sent to you in error.



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





PostPosted: Fri Mar 01, 2019 11:57 am    Post subject:
Deep cloning an active root scene node
Reply with quote

Thanks Robert, that's actually what I tried initially and it renders fine, however there's a usability issue. For more background I'm rendering light fields. In order to do this I set up an array of thousands of slightly offset cameras in a rectangular grid pattern. Because I'm capturing so many views when I call osgViewer::Viewer::frame() it locks the main thread and the application becomes unresponsive for a long time. 


Ideally what I'd like is for the main application to continue rendering its single 3d view, while I render these thousands of cameras to a texture in a background thread. I'm rendering to a texture now without issue, but what's eluded me so far is how I can run this process without locking up the application.


I'd like to have a snapshot of the scene graph for this background thread so that the user can continue to use the main 3d view while the background thread renders a static copy of the scene graph. This is why I've been attempting to clone the root scene node recursively and pass it to my thread. Any concerns with that approach?


Cheers,
Rob




Message: 9Date: Thu, 28 Feb 2019 18:53:19 +0000From: Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>To: OpenSceneGraph Users < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>Subject: Re: Deep cloning an active root scene nodeMessage-ID:        <CAFN7Y+ ([email]CAFN7Y%[/email])>Content-Type: text/plain; charset="UTF-8"Hi Rob,The OSG is design to allow you to rendering multiple views at once,there is no need to clone the scene graph, you simply add another Viewto a CompositeView to add the extra rendering.  You can toggleoptional View's on/off as you need them.Robert.  



Message: 7Date: Thu, 28 Feb 2019 14:20:46 -0330From: Robert Lockyer < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>To:  (
Only registered users can see emails on this board!
Get registred or enter the forums!
)Subject: Deep cloning an active root scene nodeMessage-ID:        <CAGUte1dn64d=pcQXMrgQTShbQqDHKmdVcpd+ ([email]pcQXMrgQTShbQqDHKmdVcpd%[/email])>Content-Type: text/plain; charset="utf-8"Hi all, my name is Rob.I'm currently writing a plugin for an OSG based application. I effectivelywant to create a snapshot of the application's scene graph state and passit to another thread where I can render to a texture, while the mainrendering thread continues with minimal interruption.I'd like to do this because blocking the main thread with aosgViewer::Viewer::frame() call causes the application to lock up andprevents me from displaying a progress dialog. The scene I render takes along time because I render many camera views to a single texture.I'm currently trying to do this:osg::Node* sceneCopy =dynamic_cast<osg::Node*>(sceneData_->clone(osg::CopyOp::DEEP_COPY_ALL));Then passing this to another thread where I run:viewer_ = new osgViewer::Viewer();viewer_->setSceneData(sceneCopy);However the behavior seems inconsistent. It either dies on a null referenceinside osgEarth somewhere or it renders an empty scene. I don't think Ifully understand the threading model of OSG, I've read a bit here andthere, but I think there's a lot I'm still missing.Is there a safe way to copy the scene data and use it to run an isolatedviewer like this in parallel? Is it even safe to run two viewers inparallel like this at all?Cheers,Rob  



Robert LockyerSoftware Developer

Office: 1-709-701-0281Email:  (
Only registered users can see emails on this board!
Get registred or enter the forums!
)




















This email and any attachments are confidential and may be privileged. Any unauthorized use, disclosure, copying or distribution of the information received is prohibited. If you are not the intended recipient please contact the sender immediately by return email confirming that you have and will delete all communications related to the email and any attachments sent to you in error.

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


Joined: 18 Mar 2009
Posts: 12348

PostPosted: Fri Mar 01, 2019 12:06 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Hi Rob,



There is a limit to how well you'll be able to get things to scale given the hardware limits you have to work around.  If you don't want the main rendering loop to wait for the rendering of all these extra views then you'll need to use a separate viewer(or compositeviewer) with it's own threading.  You'll need to manage your own frame loops in the secondary viewer.



The only reason to copy data is if it the data is being modified by the different threads, I wouldn't recommend avoiding any modifications of the scene graph so you can simply share it all without copying.  If there are modifications you currently need I would suggest looking at ways to move this work elsewhere - often you can move to the GPU and just pass a Uniform per View to select the settings that are approriate so the shaders can do the right thing.


Cheers,

Robert.

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





PostPosted: Fri Mar 01, 2019 12:56 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Thanks Robert, that's good advise for a more efficient approach in the long term. I just figure it might be a simple proof of concept to just blindly clone the whole graph. Sounds like there's no fundamental reason I can't do that, so probably just some silly thing I'm getting wrong.


Robert LockyerSoftware Developer

Office: 1-709-701-0281Email:  (
Only registered users can see emails on this board!
Get registred or enter the forums!
)





















On Fri, Mar 1, 2019 at 8:36 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
Hi Rob,



There is a limit to how well you'll be able to get things to scale given the hardware limits you have to work around.  If you don't want the main rendering loop to wait for the rendering of all these extra views then you'll need to use a separate viewer(or compositeviewer) with it's own threading.  You'll need to manage your own frame loops in the secondary viewer.



The only reason to copy data is if it the data is being modified by the different threads, I wouldn't recommend avoiding any modifications of the scene graph so you can simply share it all without copying.  If there are modifications you currently need I would suggest looking at ways to move this work elsewhere - often you can move to the GPU and just pass a Uniform per View to select the settings that are approriate so the shaders can do the right thing.


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


This email and any attachments are confidential and may be privileged. Any unauthorized use, disclosure, copying or distribution of the information received is prohibited. If you are not the intended recipient please contact the sender immediately by return email confirming that you have and will delete all communications related to the email and any attachments sent to you in error.

------------------
Post generated by Mail2Forum
Back to top
Daniel Emminizer, Code...
Guest





PostPosted: Fri Mar 01, 2019 1:07 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Hi Rob,

Be sure that if you’re using cloning that everything in the scene supports cloning. If you have custom (non-OSG) nodekit elements in the scene, cloning may only be partially supported. That can certainly cause issues with that approach. Though OSG nodes supports cloning, not all custom nodekits necessarily implement the copy constructors properly.

- Dan



From: osg-users [mailto:] On Behalf Of Robert Lockyer
Sent: Friday, March 1, 2019 7:56 AM
To: OpenSceneGraph Users <>
Subject: Re: Deep cloning an active root scene node

Thanks Robert, that's good advise for a more efficient approach in the long term. I just figure it might be a simple proof of concept to just blindly clone the whole graph. Sounds like there's no fundamental reason I can't do that, so probably just some silly thing I'm getting wrong.



Robert Lockyer
Software Developer

Office: 1-709-701-0281
Email: (
Only registered users can see emails on this board!
Get registred or enter the forums!
)





















On Fri, Mar 1, 2019 at 8:36 AM Robert Osfield < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Hi Rob,



There is a limit to how well you'll be able to get things to scale given the hardware limits you have to work around. If you don't want the main rendering loop to wait for the rendering of all these extra views then you'll need to use a separate viewer(or compositeviewer) with it's own threading. You'll need to manage your own frame loops in the secondary viewer.



The only reason to copy data is if it the data is being modified by the different threads, I wouldn't recommend avoiding any modifications of the scene graph so you can simply share it all without copying. If there are modifications you currently need I would suggest looking at ways to move this work elsewhere - often you can move to the GPU and just pass a Uniform per View to select the settings that are approriate so the shaders can do the right thing.



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



This email and any attachments are confidential and may be privileged. Any unauthorized use, disclosure, copying or distribution of the information received is prohibited. If you are not the intended recipient please contact the sender immediately by return email confirming that you have and will delete all communications related to the email and any attachments sent to you in error.

------------------
Post generated by Mail2Forum
Back to top
Chris Hanson
Guest





PostPosted: Fri Mar 01, 2019 2:41 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Hey Rob (Lockyear). You know, Mike Weiblen has already done this stuff you're doing in OSG. Last year, I put him in touch with Matthew Hamilton and Russ Baker an email suggesting you guys all mind-meld to see if his wisdom could save you all some effort. Perhaps they didn't know he was working with OSG, but it seems like based on the questions you're asking, you're following paths he's already navigated.


I'd be happy to put you in touch again.

------------------
Post generated by Mail2Forum
Back to top
Robert Lockyer
Guest





PostPosted: Fri Mar 01, 2019 4:42 pm    Post subject:
Deep cloning an active root scene node
Reply with quote

Hey Chris, Just had a chat with Matt and he reminded me of the Raspberry Pi light field rig Mike was working on a while back. Very cool stuff. I don't think we were aware that he was working with OSG.


If you can put me in touch, sounds like we would have lots to talk about.


Thanks,
Rob



















On Fri, Mar 1, 2019 at 11:10 AM Chris Hanson < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:

Hey Rob (Lockyear). You know, Mike Weiblen has already done this stuff you're doing in OSG. Last year, I put him in touch with Matthew Hamilton and Russ Baker an email suggesting you guys all mind-meld to see if his wisdom could save you all some effort. Perhaps they didn't know he was working with OSG, but it seems like based on the questions you're asking, you're following paths he's already navigated.


I'd be happy to put you in touch again.




_______________________________________________
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


This email and any attachments are confidential and may be privileged. Any unauthorized use, disclosure, copying or distribution of the information received is prohibited. If you are not the intended recipient please contact the sender immediately by return email confirming that you have and will delete all communications related to the email and any attachments sent to you in error.

------------------
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 Updating a PositionAttitudeTransform ... johansson_gbg General 3 Wed Oct 09, 2019 8:26 am View latest post
No new posts Orient a node to face another pleopard General 2 Wed Oct 02, 2019 2:47 pm View latest post
No new posts DEEP_COPY_USERDATA isn't that deep AnyOldName3 General 9 Fri Sep 20, 2019 6:19 pm View latest post
No new posts Questions on optimizing my scene graph Werner Modenbach General 1 Mon Sep 02, 2019 10:08 am View latest post
No new posts Different colors for a node shared sc... icf80 General 1 Thu Jun 13, 2019 12:49 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