Oh, my cloud map texture is just a greyscale image. Would it help and
make things a ton easier if I converted the black in the image to
transparent and just mapped that to a new sphere instead of doing the
GL_BLENDING stuff?
- Steve
On Tue, 13 Mar 2007, [EMAIL PROTECTED] wrote:
Date: Tue, 13 Mar 2007 17:07:05 -0600 (MDT)
From: [EMAIL PROTECTED]
Reply-To: osg users <[email protected]>
To: [email protected]
Subject: [osg-users] Cloud layer (transparency)?
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/
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/