There are lots of ways you could tackle it, include multi-texturing,
multi-pass (i.e. two spheres) though to use of shaders.

On 3/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hello -

I'm thinking that Robert can probably answer this one, but it's up for
grabs if anyone wants to chime in.  :)

I'm trying to render a globe (blue-marble/google-earth) like stuff but not
zoomable.  I got the globe with texturemap, but would like to also render
a haze atmosphere and a cloud layer.

I tried many different approaches with the cloud map.  I was using
a BLEND State Attribute on my texture and got something kind of inverse to
what I was expecting, but with no transparency.

This is pretty straight forward and I'm wondering what I'm doing wrong.
Any help?

Some code that I'm playing with now:

osg:: Node* createEarth(void) {
         float radius = 20.0f;
         char *map_filename="map.jpg";
         char *cloud_filename="clouds.jpg";

         osg::Geode* geode = new osg::Geode();
         osg::StateSet* stateset = new osg::StateSet();
         osg::StateSet* stateset2 = new osg::StateSet();

         osg::TessellationHints* hints = new osg::TessellationHints;
         hints->setDetailRatio(1.0f);

         osg::ShapeDrawable *earth = new osg::ShapeDrawable(new 
osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),radius),hints);

         earth->setStateSet( stateset );
         osg::Image* image = osgDB::readImageFile( map_filename );
         if (image) {
                 osg::Texture2D* texture = new osg::Texture2D;
                 texture->setImage(image);
                 
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
         }

         osg::ShapeDrawable *clouds = new osg::ShapeDrawable(new 
osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),radius + 1.0),hints);
         osg::Image* image2 = osgDB::readImageFile( cloud_filename );

         osg::TexGen* texgen = new osg::TexGen;
         texgen->setMode(osg::TexGen::SPHERE_MAP);

         osg::TexEnv* texenv = new osg::TexEnv;
//        texenv->setMode(osg::TexEnv::BLEND);
         texenv->setColor(osg::Vec4(1.0f,1.0f,0.8f,0.2f));

         if (image2) {
//              osg::Texture2D* texture2 = new osg::Texture2D;
//              texture2->setImage(image2);
//              
stateset2->setTextureAttributeAndModes(1,texture2,osg::StateAttribute::ON);
//              
stateset2->setTextureAttributeAndModes(1,texgen,osg::StateAttribute::ON);
                 stateset2->setTextureAttribute(1,texenv);
                 stateset2->setMode(GL_BLEND,osg::StateAttribute::ON);
                 stateset2->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
                 clouds->setStateSet( stateset2 );
         }

         osg::MatrixTransform* xform = new osg::MatrixTransform;
         xform->setUpdateCallback(new 
osg::AnimationPathCallback(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(1.0f)));

         geode->addDrawable(earth);
         geode->addDrawable(clouds);
         osg::MatrixTransform* positioner = new osg::MatrixTransform;

         positioner->setMatrix(
                                         osg::Matrix::translate(0.0,0.0,0.0) *
                                         
osg::Matrix::rotate(osg::inDegrees(90.0f),0.0f,0.0f,0.0f)
                                 );
         positioner->addChild(geode);

         xform->addChild(positioner);
         osg::CameraNode* camera = new osg::CameraNode;

         camera->addChild(xform);
         return camera;
}

The above doesn't work currently.  I'm guessing that I'm just doing
something wrong somewhere, but I can't seem to find out where.  None of
the above is doing the haze effect, just the cloud map.

I've seen the haze effect done several different ways.  Anyone have any
interesting solutions to making a nice haze that trails off?  I'd like to
avoid the billboard method that's used in the osgplanets example, but
that's the same kind of effect that I'd eventually like to get with the
haze effect (as opposed to have a 'hard' border that fades as it goes
'into' the planet.

- Steve

--
EMAIL: (h) [EMAIL PROTECTED]  WEB: http://badcheese.com/~steve

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to