In my code I have an OSG tree with the following global state
attributes defined:
osgUtil::CullVisitor *pCullVisitor = m_sceneView-
>getCullVisitor();
osgUtil::RenderBin *pRenderBin = pCullVisitor->getCurrentRenderBin();
pRenderBin->setSortMode(osgUtil::RenderBin::SORT_BACK_TO_FRONT);
osg::StateSet *pStateSet = m_sceneView-
>getGlobalStateSet();
pStateSet->setMode(GL_ALPHA_TEST,
osg::StateAttribute::OFF);
osg::CullFace *pCullFace = new osg::CullFace;
pCullFace->setMode(osg::CullFace::BACK);
pStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
pStateSet->setAttribute(pCullFace, osg::StateAttribute::ON);
osg::ShadeModel *pShadeMdl = new osg::ShadeModel;
pShadeMdl->setMode(osg::ShadeModel::FLAT);
pStateSet->setAttribute(pShadeMdl, osg::StateAttribute::ON);
osg::Depth *pDepth = new osg::Depth;
pDepth->setFunction(osg::Depth::LEQUAL);
pStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
pStateSet->setAttribute(pDepth, osg::StateAttribute::ON);
The only other time I change the state is when I enable and disable
the color buffer writes.
Here is what I am seeing:
If I render the scene with the color buffer always on, then objects
that should be occluded by other objects behave correctly and are
occluded.
When I render the scene with the color buffer off for some of the
nodes in the beginning of the tree, with it enabled again for ones
later on, I expect that because I DID NOT disable writes to the depth
buffer, that the objects which are occluded by other objects (even
though they were not drawn to the color buffer) should behave
correctly. However, they do not. Some do and some don't and if I
rotate then even ones that behave correctly, begin to misbehave.
Now I have made the following change because I don't need to worry
about transparency anymore:
pRenderBin->setSortMode(osgUtil::RenderBin::SORT_FRONT_TO_BACK);
And this almost fixes the issue except if I rotate to some degree, I
still get parts of objects drawn that should be occluded. I know
because I can toggle the objects visible and invisible.
Is there something internally that can be culling parts of objects
because I have the color buffer masked for them?
Thanks,
Judie
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org