Re: [osg-users] Depth/Cull question
Hmm just some doubts after a look on OpenGl specifications : Why turning OFF the culling ? it will just eliminate or not the backface... so it is not very useful for this problem, isn't it ? Next, if I use a depth test to (ALWAYS,0,1), renderbindetails is not necessary...isn't it ? Last, still have no results... Just a question now (or two) : If I set the depth test on a node (PAT) or if I set it on a drawable/geode/... is there some difference ? Have you any idea of why I have no visible results ? Thanks, Vincent. 2008/12/3 Vincent Bourdier [EMAIL PROTECTED] 2008/12/3 Tomlinson, Gordon [EMAIL PROTECTED] To NOT render a node and all its children simply set is Node mask to 0x0 to stop it being drawn, and set it 0xFFF and any value that results in true when locial AND'ed cameras mask As to alsway being drawn 1) Turn OSG culling of on the node 2) Place the node and its children in a render bin with a high number like 100 or higher than any other you may be using. This will make sure it is rendered last node-setRenderBinDetails( 100,LastRenderBin); 3) If you want all of the geometry to be drawn then turn OFF the depth test of for node and its children as shown below Hmm, I use this code : *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet(); node-setCullingActive(false); state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); state-setRenderBinDetails(1000, RenderBin);* and nothing happen... It is not my lucky day today... Thanks. Regards, Vincent. Gordon __ Gordon Tomlinson Product Manager 3D Email : gtomlinson @ overwatch.textron.com __ (C): (+1) 571-265-2612 (W): (+1) 703-437-7651 Self defence is not a function of learning tricks but is a function of how quickly and intensely one can arouse one's instinct for survival - Master Tambo Tetsura -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ulrich Hertlein Sent: Wednesday, December 03, 2008 12:53 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Depth/Cull question Hi Vincent, Quoting Vincent Bourdier [EMAIL PROTECTED]: I just need to set a node to be always rendered (or not). It needs to not depend on the Zbuffer/culling. ... *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet();* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *osg::ref_ptrosg::Depth depth;* *if(set){* *depth = new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::OFF);* *node-setCullingActive(false);* *}else{* *depth = new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *node-setCullingActive(true);* *}* ** *state-setAttributeAndModes(depth.get(), osg::StateAttribute::ON);* Seems to me you're actually throwing different concepts into one bag: - Zbuffer/depth test - GL face culling - OSG node culling If I understand you correctly then you want to make sure a node is always drawn irrespective of any objects that might be in front of it. Simply turn of the depth test: state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF) That might expose issues with the order in which objects are drawn - the solution to that is RenderBins. When you say always rendered *(or not)* (my emphasis) do you want to turn it off completely? Hope this helps, Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or ghttp://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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
Jean-Sébastien Guay schrieb: Hi Vincent, Or perhaps your ground is a very very large sphere where no part of the sphere can be culled away, so the far plane is actually behind the Earth (which is very far away relatively to the distance between the airplane and the ground)... J-S I second that. Your background sphere (which is the radius of the earth) takes away all of the Z-Buffer resolution. What you would really need is a two pass rendering: Rendering of the earth sphere as a background with it's own depth range and then the air plane as the front scene. So I'd propose a variant of the HUD approach, but with 3 dimensional geometry for background and front part. regards Ralph ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
Hi Jean-Sébastien, Using a HUD-like system seems to be a extrem solution for me... I am just looking at a way to set a node always rendered... For the moment, using the .osg format file to see my stateset, I see that the culling test still stay ON. I correct it ; my code is now : *node-setCullingActive(false); osg::ref_ptrosg::Depth depth = new osg::Depth(osg::Depth::NEVER, 0.0, 1.0); node-getOrCreateStateSet()-setAttributeAndModes(depth.get(), osg::StateAttribute::ON); node-getOrCreateStateSet()-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); node-getOrCreateStateSet()-setRenderBinDetails(1000, RenderBin);* my node is now : *PositionAttitudeTransform { UniqueID PositionAttitudeTransform_0 name F-GHOP nodeMask 0x cullingActive FALSE StateSet { UniqueID StateSet_1 rendering_hint DEFAULT_BIN renderBinMode USE binNumber 1000 binName RenderBin GL_DEPTH_TEST OFF GL_NORMALIZE ON Depth { UniqueID Depth_2 function NEVER writeMask TRUE range 0 1 } } UpdateCallbacks { NodeCallback { name planeOverTheFloorCallback NodeCallback { name triggerScaleCallback } } } ... //with LOD children after.* And the result... still the same : culling make nothing different. Am I missing something important ? thanks, Regards, Vincent. 2008/12/4 Ralph Kern [EMAIL PROTECTED] Jean-Sébastien Guay schrieb: Hi Vincent, Or perhaps your ground is a very very large sphere where no part of the sphere can be culled away, so the far plane is actually behind the Earth (which is very far away relatively to the distance between the airplane and the ground)... J-S I second that. Your background sphere (which is the radius of the earth) takes away all of the Z-Buffer resolution. What you would really need is a two pass rendering: Rendering of the earth sphere as a background with it's own depth range and then the air plane as the front scene. So I'd propose a variant of the HUD approach, but with 3 dimensional geometry for background and front part. regards Ralph ___ 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] Depth/Cull question
Sorry : made a mistake *Depth { UniqueID Depth_2 function NEVER writeMask TRUE range 0 1 } *is really* Depth { UniqueID Depth_2 function ALWAYS writeMask TRUE range 0 1 } * 2008/12/4 Vincent Bourdier [EMAIL PROTECTED] Hi Jean-Sébastien, Using a HUD-like system seems to be a extrem solution for me... I am just looking at a way to set a node always rendered... For the moment, using the .osg format file to see my stateset, I see that the culling test still stay ON. I correct it ; my code is now : *node-setCullingActive(false); osg::ref_ptrosg::Depth depth = new osg::Depth(osg::Depth::NEVER, 0.0, 1.0); node-getOrCreateStateSet()-setAttributeAndModes(depth.get(), osg::StateAttribute::ON); node-getOrCreateStateSet()-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); node-getOrCreateStateSet()-setRenderBinDetails(1000, RenderBin);* my node is now : *PositionAttitudeTransform { UniqueID PositionAttitudeTransform_0 name F-GHOP nodeMask 0x cullingActive FALSE StateSet { UniqueID StateSet_1 rendering_hint DEFAULT_BIN renderBinMode USE binNumber 1000 binName RenderBin GL_DEPTH_TEST OFF GL_NORMALIZE ON Depth { UniqueID Depth_2 function NEVER writeMask TRUE range 0 1 } } UpdateCallbacks { NodeCallback { name planeOverTheFloorCallback NodeCallback { name triggerScaleCallback } } } ... //with LOD children after.* And the result... still the same : culling make nothing different. Am I missing something important ? thanks, Regards, Vincent. 2008/12/4 Ralph Kern [EMAIL PROTECTED] Jean-Sébastien Guay schrieb: Hi Vincent, Or perhaps your ground is a very very large sphere where no part of the sphere can be culled away, so the far plane is actually behind the Earth (which is very far away relatively to the distance between the airplane and the ground)... J-S I second that. Your background sphere (which is the radius of the earth) takes away all of the Z-Buffer resolution. What you would really need is a two pass rendering: Rendering of the earth sphere as a background with it's own depth range and then the air plane as the front scene. So I'd propose a variant of the HUD approach, but with 3 dimensional geometry for background and front part. regards Ralph ___ 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] Depth/Cull question
Hi Vincent, Using a HUD-like system seems to be a extrem solution for me... I am just looking at a way to set a node always rendered... I did not suggest a HUD approach, Ralph did. It's one possible solution, but see below for what I'd suggest. For the moment, using the .osg format file to see my stateset, I see that the culling test still stay ON. Argh... How many times do I need to say that culling is not your problem? It's a z-buffer precision issue. Fix this the right way or you'll always have problems. I'll spell it out for you: Culling will only remove entire nodes / drawables. This is not happening with your airplane, since you can see part of it, but some of it is behind your terrain. This means that part of the object is failing the depth test, which is because your near and far planes are too far apart and thus your z-buffer precision is too small to resolve the airplane correctly over the terrain. The AUTO_COMPUTE_NEAR_FAR mode will automatically push back the near plane to be closest to your airplane, and pull in the far plane to be just behind your terrain, which will make sure that the distance between the near and far planes is minimal, and thus that you have enough precision between them to resolve the airplane above the terrain. Then again, as I mentioned before, if you're using a whole Earth model for your terrain, then the far plane will be behind the Earth and the near plane will be in front of your airplane, which will result in there being more than the diameter of the Earth between the two, which if you use meters as your unit will be too much and you will get low z-buffer precision even with AUTO_COMPUTE_NEAR_FAR enabled. One solution here is to use depth partitioning to render the Earth with one depth partition and the rest (the airplane and anything on the surface) with another. See the osgdepthpartition example. Another solution would be to break up your Earth model into multiple Geodes/Drawables, and use occlusion culling, which would remove the back part of the Earth. Anyways, breaking up the Earth will bring better performance in general because OSG will be able to cull parts of it that are outside of the view frustum. So it's a good idea if you haven't done it already. osg::ref_ptrosg::Depth depth = new osg::Depth(osg::Depth::NEVER, 0.0, 1.0); NEVER means it will NEVER pass the depth test. This is not what you want, you want ALWAYS. http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/depthfunc.html J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
2008/12/4 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Vincent, Using a HUD-like system seems to be a extrem solution for me... I am just looking at a way to set a node always rendered... I did not suggest a HUD approach, Ralph did. It's one possible solution, but see below for what I'd suggest. For the moment, using the .osg format file to see my stateset, I see that the culling test still stay ON. Argh... How many times do I need to say that culling is not your problem? It's a z-buffer precision issue. Fix this the right way or you'll always have problems. I'll spell it out for you: Culling will only remove entire nodes / drawables. This is not happening with your airplane, since you can see part of it, but some of it is behind your terrain. This means that part of the object is failing the depth test, which is because your near and far planes are too far apart and thus your z-buffer precision is too small to resolve the airplane correctly over the terrain. The AUTO_COMPUTE_NEAR_FAR mode will automatically push back the near plane to be closest to your airplane, and pull in the far plane to be just behind your terrain, which will make sure that the distance between the near and far planes is minimal, and thus that you have enough precision between them to resolve the airplane above the terrain. Then again, as I mentioned before, if you're using a whole Earth model for your terrain, then the far plane will be behind the Earth and the near plane will be in front of your airplane, which will result in there being more than the diameter of the Earth between the two, which if you use meters as your unit will be too much and you will get low z-buffer precision even with AUTO_COMPUTE_NEAR_FAR enabled. One solution here is to use depth partitioning to render the Earth with one depth partition and the rest (the airplane and anything on the surface) with another. See the osgdepthpartition example. Another solution would be to break up your Earth model into multiple Geodes/Drawables, and use occlusion culling, which would remove the back part of the Earth. Anyways, breaking up the Earth will bring better performance in general because OSG will be able to cull parts of it that are outside of the view frustum. So it's a good idea if you haven't done it already. osg::ref_ptrosg::Depth depth = new osg::Depth(osg::Depth::NEVER, 0.0, 1.0); NEVER means it will NEVER pass the depth test. This is not what you want, you want ALWAYS. http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/depthfunc.html Yes, it is just a mistake when I paste the code... I am in ALWAYS. Okay for the culling, but when nothing seems to work... I tried everything that can modify anything... My Earth model is already divided into lots of groups/drawables... So when I put the normal COMPUTE_NEAR_FAR_MODE, the plane and the Earth are well renderd... But, the frustum near plane is too far... because, even if I can move in spatial mode... I need to go into the plane too, and for now, the frustum near plan do not allow that... PS : AUTO_COMPUTE_NEAR_FAR do not exist... or I didn't find it. That's why I would prefer to not change the frustum parameters... and to set the plane always rendered, and a callback will adjust this parameter, depending on camera's position. I did it last week, it works well. But after some modifications in my code, nothing seems to work about culling... I use CompositeViewers, each one get one View... this kind of thing can be responsible of this problem ? Sorry to insist... I hear you about frustum and culling, but I know what I expect and what is possible or not with my application structure... and just setting my plane always rendered will be sufficient, and useful. So the problem still stay the same : whatever is my Depth setting, the plane render always the same... Thanks for you precisions. Regards, Vincent. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ 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] Depth/Cull question
Hi Vincent, My Earth model is already divided into lots of groups/drawables... So when I put the normal COMPUTE_NEAR_FAR_MODE, the plane and the Earth are well renderd... But, the frustum near plane is too far... because, even if I can move in spatial mode... I need to go into the plane too, and for now, the frustum near plan do not allow that... Seriously, try depth partitioning, it's easy to integrate into an engine. Or try to change the nearFarRatio so that your near plane is pushed less far when you're inside the airplane. You may just need different strategies for the two cases, since they're very different situations as far as tyhe z-buffer is concerned. If it works well when outside the plane with the normal ComputeNearFarMode, and it works well outside the plane when you set the near and far distances explicitly and disable ComputeNarFarMode, then just set them that way when you switch from inside your plane to outside! PS : AUTO_COMPUTE_NEAR_FAR do not exist... or I didn't find it. I was going from memory, seeing as the disable case is DO_NOT_COMPUTE_NEAR_FAR. The other options are COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES and COMPUTE_NEAR_FAR_USING_PRIMITIVES. Sorry to insist... I hear you about frustum and culling, but I know what I expect and what is possible or not with my application structure... Everything is possible with any application structure. It's just the willingness to fix the problem that's missing. I think you've already wasted lots of time trying to get your workaround to work that in the end you won't have saved any time at all. and just setting my plane always rendered will be sufficient, and useful. So the problem still stay the same : whatever is my Depth setting, the plane render always the same... There's nothing more we can say about this. It should work, it does work in other applications, so if it doesn't work in yours then you need to find the problem, we can't really help that much since we don't have the app. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
2008/12/4 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Vincent, My Earth model is already divided into lots of groups/drawables... So when I put the normal COMPUTE_NEAR_FAR_MODE, the plane and the Earth are well renderd... But, the frustum near plane is too far... because, even if I can move in spatial mode... I need to go into the plane too, and for now, the frustum near plan do not allow that... Seriously, try depth partitioning, it's easy to integrate into an engine. Or try to change the nearFarRatio so that your near plane is pushed less far when you're inside the airplane. You may just need different strategies for the two cases, since they're very different situations as far as tyhe z-buffer is concerned. If it works well when outside the plane with the normal ComputeNearFarMode, and it works well outside the plane when you set the near and far distances explicitly and disable ComputeNarFarMode, then just set them that way when you switch from inside your plane to outside! Yes, this is already implemented, but just to ajust the frustum a little. Why ? because when we are in the plane, we can see the sky or Earth far away... so I always need a FAR plane around 5000 ... and a near around 0.5 !! With the plane rendered in Always mode, everything will be good... It is the only thing that causes Z-buffer fighting ... PS : AUTO_COMPUTE_NEAR_FAR do not exist... or I didn't find it. I was going from memory, seeing as the disable case is DO_NOT_COMPUTE_NEAR_FAR. The other options are COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES and COMPUTE_NEAR_FAR_USING_PRIMITIVES. Sorry to insist... I hear you about frustum and culling, but I know what I expect and what is possible or not with my application structure... Everything is possible with any application structure. It's just the willingness to fix the problem that's missing. I think you've already wasted lots of time trying to get your workaround to work that in the end you won't have saved any time at all. Of course... But, this was working well weeks ago. So repair the bug is more simple than to rebuilt half the code to adapt it... and just setting my plane always rendered will be sufficient, and useful. So the problem still stay the same : whatever is my Depth setting, the plane render always the same... There's nothing more we can say about this. It should work, it does work in other applications, so if it doesn't work in yours then you need to find the problem, we can't really help that much since we don't have the app. :'( I will get it ! one day Thanks a lot Sorry to take so much of your time... Regards, Vincent. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ 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] Depth/Cull question
Hi Vincent, But, this was working well weeks ago. So repair the bug is more simple than to rebuilt half the code to adapt it... Do you use source control? If so you can just compare your code from a few weeks ago when it worked to the code now, and see what changed. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
Hi Jean-Sébastien, Of course I compared my current version and the last one... If I keep the last one... nothing changes compared to new... The big changed I did is to switch for osgViewer to composite Viewer... I'll have a look on that... because I will become mad looking my code still not working whatever I do... Thanks Vincent. 2008/12/4 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Vincent, But, this was working well weeks ago. So repair the bug is more simple than to rebuilt half the code to adapt it... Do you use source control? If so you can just compare your code from a few weeks ago when it worked to the code now, and see what changed. J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ 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] Depth/Cull question
Hi Vincent, My goal is to set this state in a callback, to allow changes when camera is near the plane : the culling is good without cheating... when camera is far from it, the culling/zbuffer makes stranges things, so I would make the necessary things to set the plane always visible... Setting the node to always render without the z-buffer is not a fix, it's a workaround. It will introduce other problems when something else (a cloud perhaps) is on top of the airplane. The result you're seeing is z-fighting, and is a result of poor z-buffer precision (you have too much distance between your near and far planes to have enough precision to represent the distance between two objects, so the z-buffer thinks object A is in front of object B when it's the opposite). The fix is to fix your z-buffer precision problem. Do you disable automatic near/far calculation? You probably should not, since this would make sure that your near plane is at the top of your airplane, and your far plane is below your ground. Or perhaps your ground is a very very large sphere where no part of the sphere can be culled away, so the far plane is actually behind the Earth (which is very far away relatively to the distance between the airplane and the ground)... Look into these problems, and you'll be able to fix the real problem. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
To NOT render a node and all its children simply set is Node mask to 0x0 to stop it being drawn, and set it 0xFFF and any value that results in true when locial AND'ed cameras mask As to alsway being drawn 1) Turn OSG culling of on the node 2) Place the node and its children in a render bin with a high number like 100 or higher than any other you may be using. This will make sure it is rendered last node-setRenderBinDetails( 100,LastRenderBin); 3) If you want all of the geometry to be drawn then turn OFF the depth test of for node and its children as shown below Gordon __ Gordon Tomlinson Product Manager 3D Email : gtomlinson @ overwatch.textron.com __ (C): (+1) 571-265-2612 (W): (+1) 703-437-7651 Self defence is not a function of learning tricks but is a function of how quickly and intensely one can arouse one's instinct for survival - Master Tambo Tetsura -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ulrich Hertlein Sent: Wednesday, December 03, 2008 12:53 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Depth/Cull question Hi Vincent, Quoting Vincent Bourdier [EMAIL PROTECTED]: I just need to set a node to be always rendered (or not). It needs to not depend on the Zbuffer/culling. ... *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet();* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *osg::ref_ptrosg::Depth depth;* *if(set){* *depth = new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::OFF);* *node-setCullingActive(false);* *}else{* *depth = new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *node-setCullingActive(true);* *}* ** *state-setAttributeAndModes(depth.get(), osg::StateAttribute::ON);* Seems to me you're actually throwing different concepts into one bag: - Zbuffer/depth test - GL face culling - OSG node culling If I understand you correctly then you want to make sure a node is always drawn irrespective of any objects that might be in front of it. Simply turn of the depth test: state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF) That might expose issues with the order in which objects are drawn - the solution to that is RenderBins. When you say always rendered *(or not)* (my emphasis) do you want to turn it off completely? Hope this helps, Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
Hi, I know that I want to render some nodes without Z-buffer. It is a choice, implemented as a solution enabled ans disabled in real-time execution, when necessary. Sure there will be no nodes (clouds) over it. I know exactly what can be the associated problems. Near/Far calculation is already disabled , but the scene is big, so this is not a surprised that the culling have difficulties. So, to make a real No Z-buffer on some node, do you have any idea ? Thanks, Regards, Vincent. 2008/12/3 Jean-Sébastien Guay [EMAIL PROTECTED] Hi Vincent, My goal is to set this state in a callback, to allow changes when camera is near the plane : the culling is good without cheating... when camera is far from it, the culling/zbuffer makes stranges things, so I would make the necessary things to set the plane always visible... Setting the node to always render without the z-buffer is not a fix, it's a workaround. It will introduce other problems when something else (a cloud perhaps) is on top of the airplane. The result you're seeing is z-fighting, and is a result of poor z-buffer precision (you have too much distance between your near and far planes to have enough precision to represent the distance between two objects, so the z-buffer thinks object A is in front of object B when it's the opposite). The fix is to fix your z-buffer precision problem. Do you disable automatic near/far calculation? You probably should not, since this would make sure that your near plane is at the top of your airplane, and your far plane is below your ground. Or perhaps your ground is a very very large sphere where no part of the sphere can be culled away, so the far plane is actually behind the Earth (which is very far away relatively to the distance between the airplane and the ground)... Look into these problems, and you'll be able to fix the real problem. Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ 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] Depth/Cull question
2008/12/3 Tomlinson, Gordon [EMAIL PROTECTED] To NOT render a node and all its children simply set is Node mask to 0x0 to stop it being drawn, and set it 0xFFF and any value that results in true when locial AND'ed cameras mask As to alsway being drawn 1) Turn OSG culling of on the node 2) Place the node and its children in a render bin with a high number like 100 or higher than any other you may be using. This will make sure it is rendered last node-setRenderBinDetails( 100,LastRenderBin); 3) If you want all of the geometry to be drawn then turn OFF the depth test of for node and its children as shown below Hmm, I use this code : *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet(); node-setCullingActive(false); state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); state-setRenderBinDetails(1000, RenderBin);* and nothing happen... It is not my lucky day today... Thanks. Regards, Vincent. Gordon __ Gordon Tomlinson Product Manager 3D Email : gtomlinson @ overwatch.textron.com __ (C): (+1) 571-265-2612 (W): (+1) 703-437-7651 Self defence is not a function of learning tricks but is a function of how quickly and intensely one can arouse one's instinct for survival - Master Tambo Tetsura -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ulrich Hertlein Sent: Wednesday, December 03, 2008 12:53 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Depth/Cull question Hi Vincent, Quoting Vincent Bourdier [EMAIL PROTECTED]: I just need to set a node to be always rendered (or not). It needs to not depend on the Zbuffer/culling. ... *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet();* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *osg::ref_ptrosg::Depth depth;* *if(set){* *depth = new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::OFF);* *node-setCullingActive(false);* *}else{* *depth = new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *node-setCullingActive(true);* *}* ** *state-setAttributeAndModes(depth.get(), osg::StateAttribute::ON);* Seems to me you're actually throwing different concepts into one bag: - Zbuffer/depth test - GL face culling - OSG node culling If I understand you correctly then you want to make sure a node is always drawn irrespective of any objects that might be in front of it. Simply turn of the depth test: state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF) That might expose issues with the order in which objects are drawn - the solution to that is RenderBins. When you say always rendered *(or not)* (my emphasis) do you want to turn it off completely? Hope this helps, Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or ghttp://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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Depth/Cull question
Hi, Still me and my rendering problems : I just need to set a node to be always rendered (or not). It needs to not depend on the Zbuffer/culling. Maybe I am confuse, but I have tried this : *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet();* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *osg::ref_ptrosg::Depth depth;* *if(set){* *depth = new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::OFF);* *node-setCullingActive(false);* *}else{* *depth = new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *node-setCullingActive(true);* *}* ** *state-setAttributeAndModes(depth.get(), osg::StateAttribute::ON);* Nothing changes at the screen... If I put a node always rendered, is there some limits to that ? (node will be culled if frustum far plane cut it... or anything similar ) if not, there is a real mistake is my code... and if it is right... that will complicate my work :-( Thanks. Regards, Vincent. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Depth/Cull question
Hi Vincent, Quoting Vincent Bourdier [EMAIL PROTECTED]: I just need to set a node to be always rendered (or not). It needs to not depend on the Zbuffer/culling. ... *osg::ref_ptrosg::StateSet state = node-getOrCreateStateSet();* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *osg::ref_ptrosg::Depth depth;* *if(set){* *depth = new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::OFF);* *node-setCullingActive(false);* *}else{* *depth = new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0);* *state-setMode(GL_CULL_FACE, osg::StateAttribute::ON);* *node-setCullingActive(true);* *}* ** *state-setAttributeAndModes(depth.get(), osg::StateAttribute::ON);* Seems to me you're actually throwing different concepts into one bag: - Zbuffer/depth test - GL face culling - OSG node culling If I understand you correctly then you want to make sure a node is always drawn irrespective of any objects that might be in front of it. Simply turn of the depth test: state-setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF) That might expose issues with the order in which objects are drawn - the solution to that is RenderBins. When you say always rendered *(or not)* (my emphasis) do you want to turn it off completely? Hope this helps, Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org