Re: [osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
Thanks Farshid, that explains it all. Farshid Lashkari wrote: Hi Fred, OSG does compute the correct near/far values for pre-render cameras, assuming it is enabled for it. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54463#54463 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
Robert, Sorry to further fill in this thread with a question - but couldn't it be that the OSG indeed correctly calculates the near/far values for my pre_render camera, and that I simply just do not know (yet) a proper way to correctly retrieve the projection matrix? I see the CullVisitor calculates the near/far values, maybe I should hook into this and grab the values from there? Any hint is appreciated really, and again sorry for the verbose thread. Cheers, Fred -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54407#54407 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
Hi Fred, OSG does compute the correct near/far values for pre-render cameras, assuming it is enabled for it. As you can tell, the main problem is getting access to the computed projection matrix. What I have done to get the computed near/far values from camera nodes is to attach a cull callback to the camera that retrieves the computed projection matrix from the cull visitor after the camera has been traversed. The cull callback function looks something like this: void MyCullCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) { if (nv-getVisitorType() == osg::NodeVisitor::CULL_VISITOR) { osgUtil::CullVisitor* cv = dynamic_castosgUtil::CullVisitor*(nv); if(cv) { traverse(node,nv); cv-computeNearPlane(); if (cv-getComputeNearFarMode() cv-getCalculatedFarPlane() = cv-getCalculatedNearPlane()) { osgUtil::CullVisitor::value_type znear = cv-getCalculatedNearPlane(); osgUtil::CullVisitor::value_type zfar = cv-getCalculatedFarPlane(); //Do something with znear/zfar values } return; } } traverse(node,nv); } This works really well for my application. I think every time I've encountered some tricky problem like this, cull callbacks were the solution. I don't know what I would do without them :) Cheers, Farshid On Mon, Jun 3, 2013 at 9:00 AM, Fred Smith osgfo...@tevs.eu wrote: Robert, Sorry to further fill in this thread with a question - but couldn't it be that the OSG indeed correctly calculates the near/far values for my pre_render camera, and that I simply just do not know (yet) a proper way to correctly retrieve the projection matrix? I see the CullVisitor calculates the near/far values, maybe I should hook into this and grab the values from there? Any hint is appreciated really, and again sorry for the verbose thread. Cheers, Fred -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54407#54407 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
Hi, I can render my scene graph fine when declared under the master camera in my viewer. What I am focused on is the Z far and near values, I must ensure they're good - I can inspect the view and projection matrix, render the viewing frustrum (as lines for instance), and observe that the Z far and near values are correctly set to enclose all objects in my scene. All good. I then create a PRE_RENDER, RELATIVE_RF, FBO-bound slave camera, and move over my whole scene graph to a child of this slave camera. The master camera just has the slave camera as a child now, which itself references my original scene graph. Finally I render the whole scene (viewer-frame()) and capture the contents of my framebuffer to an image file (using shaders) : it works fine. However, I can't get to display the viewing frustrum as I did before. The slave's camera view/proj matrices have been set to identity in my setup, so my expectation is that the slave camera retains the same view and projection as the master camera, right? Here, the projection part is okay, but not the depth range. The Z far and near values are way outplaced, very far away from the viewpoint (crazy values like 1.0 to 1.0 in my situation). How can I get the frustrum's properties correctly? Thank you! Cheers, Fred -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54358#54358 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
Hi Fred, The OSG by default automatically computes the near/far values during the cull traversal so you don't normally need to worry about the specific settings of near/far. The 1.0 and 1.0 are simply default values and are of no particular note. The osg::Camera inherits from osg::CullSettings so have a look at CullSettings if you want to look at the various settings that you can control, in particular the near/far computation. Robert. On 31 May 2013 21:54, Fred Smith osgfo...@tevs.eu wrote: Hi, I can render my scene graph fine when declared under the master camera in my viewer. What I am focused on is the Z far and near values, I must ensure they're good - I can inspect the view and projection matrix, render the viewing frustrum (as lines for instance), and observe that the Z far and near values are correctly set to enclose all objects in my scene. All good. I then create a PRE_RENDER, RELATIVE_RF, FBO-bound slave camera, and move over my whole scene graph to a child of this slave camera. The master camera just has the slave camera as a child now, which itself references my original scene graph. Finally I render the whole scene (viewer-frame()) and capture the contents of my framebuffer to an image file (using shaders) : it works fine. However, I can't get to display the viewing frustrum as I did before. The slave's camera view/proj matrices have been set to identity in my setup, so my expectation is that the slave camera retains the same view and projection as the master camera, right? Here, the projection part is okay, but not the depth range. The Z far and near values are way outplaced, very far away from the viewpoint (crazy values like 1.0 to 1.0 in my situation). How can I get the frustrum's properties correctly? Thank you! Cheers, Fred -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54358#54358 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
Hi Robert, Both my master and slave cameras have matching cull settings, set to COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES. Somehow though, this doesn't work when my scene is under the slave camera. My bounding box is defined as a callback on the unique leaf drawable node I have in my graph. Z near/far calculations work fine when used with the master camera. I can't understand why I cannot retrieve a correct frustrum. Is there anything else I need to do? Cheers, Fred robertosfield wrote: Hi Fred, The OSG by default automatically computes the near/far values during the cull traversal so you don't normally need to worry about the specific settings of near/far. The 1.0 and 1.0 are simply default values and are of no particular note. The osg::Camera inherits from osg::CullSettings so have a look at CullSettings if you want to look at the various settings that you can control, in particular the near/far computation. Robert. On 31 May 2013 21:54, Fred Smith wrote: Hi, I can render my scene graph fine when declared under the master camera in my viewer. What I am focused on is the Z far and near values, I must ensure they're good - I can inspect the view and projection matrix, render the viewing frustrum (as lines for instance), and observe that the Z far and near values are correctly set to enclose all objects in my scene. All good. I then create a PRE_RENDER, RELATIVE_RF, FBO-bound slave camera, and move over my whole scene graph to a child of this slave camera. The master camera just has the slave camera as a child now, which itself references my original scene graph. Finally I render the whole scene (viewer-frame()) and capture the contents of my framebuffer to an image file (using shaders) : it works fine. However, I can't get to display the viewing frustrum as I did before. The slave's camera view/proj matrices have been set to identity in my setup, so my expectation is that the slave camera retains the same view and projection as the master camera, right? Here, the projection part is okay, but not the depth range. The Z far and near values are way outplaced, very far away from the viewpoint (crazy values like 1.0 to 1.0 in my situation). How can I get the frustrum's properties correctly? Thank you! Cheers, Fred -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54358#54358 ___ osg-users mailing list http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54360#54360 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Incorrect zfar/znear when scene rendered under a PRE_RENDER camera
There might be one wrong thing. When creating the slave camera, I set it up as a child of my master camera. Should I used osg::View::addSlave(Camera) instead, and leave my master camera's scene graph empty? Sorry if this question has been answered before I am all mixed up with regards to the registration of slave cameras. Fred -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54361#54361 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org