[osg-users] Problem setting a skydome

David Spilling david.spilling at gmail.com
Wed Jul 16 12:41:49 PDT 2008


I presume that your skydome has some sort of camera centred transform over
it (as per osghangglide's example use); your code doesn't show it.

>    osg::ClearNode* clearNode = new osg::ClearNode;
>    clearNode->setRequiresClear(false);

This is odd. If your camera is the first thing to draw (implied by
PRE_RENDER) then something needs to be clearing the colour and depth buffer.
In any case, you can use camera's setClearMask method to control this
without needing a clearNode. For example
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT) clears
everyhing, setClearMask(0) clears nothing.

   osg::TexEnv* te = new osg::TexEnv;
>    te->setMode(osg::TexEnv::REPLACE);
>    stateset->setTextureAttributeAndModes(0, te, osg::StateAttribute::ON);

Slightly surprised to see this, but if your skydome needs it, then OK.

>    stateset->setMode( GL_CULL_FACE, osg::StateAttribute::ON );
>    osg::Depth* depth = new osg::Depth;
>    depth->setFunction(osg::Depth::ALWAYS);
>    depth->setRange(1.0,1.0);
>    stateset->setAttributeAndModes(depth, osg::StateAttribute::ON );

Again, not wrong (as the depth testing is always passed) but not really
necessary, as you are ensuring that your skydome is drawn first. I would
tend to prevent depth writing with

osg::Depth* depth = new osg::Depth;
depth->setWriteMask(false); // don't bother writing the depth buffer
stateset->setAttributeAndModes(depth, osg::StateAttribute::ON );

and also disable depth testing with
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF)

I looked at my code and noticed that I also do
camera->setCullingMode(osg::CullSettings::NO_CULLING), but can't remember at
the moment whether it's relevant.

Lastly, what OSG version are you using?

Hope that helps,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080716/234ee366/attachment-0003.htm>

More information about the osg-users mailing list