[osg-users] Problem setting a skydome

Alberto Luaces aluaces at udc.es
Wed Jul 16 02:06:36 PDT 2008


David,

thank you very much for your help so far. What you say sounds sensible, 
however I think my implementation still has bugs, because it behaves 
differently on several computers (one works, the other don't). What I have so 
far is:

// root -> camera -> clearnode -> skydome
//   |--> rest_of_scene

    osg::Camera *camera = new osg::Camera;
    osg::ClearNode* clearNode = new osg::ClearNode;
    
    clearNode->setRequiresClear(false);
    clearNode->addChild(SkydomeSubgraphNode.get());
    
    camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
    camera->addChild(clearNode);
    camera->setRenderOrder(osg::Camera::PRE_RENDER);
    
    root->addChild(camera);

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

    stateset->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
    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 );

does something look weird to you?

Thank you,

Alberto

El Martes 15 Julio 2008ES 10:32:55 David Spilling escribió:
> Alberto,
>
> > skydome->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR
> >).
> >
> > > a class osg::Camera inherits from
>
> Sorry - missed a step. Put a Camera in above your skydome.
>
> A solution that comes to my mind is to use a pair of cameras, one rendering
>
> > the skydome with the setting you said, DO_NOT_COMPUTE_NEAR_FAR, and the
> > other
> > rendering the rest of the scene.
>
> Exactly. That's what I do (although I control a bunch of other stuff in the
> camera, like projection matrix, in order to avoid the later issues).
>
> David





More information about the osg-users mailing list