[osg-users] osgShadow question

Jean-Sébastien Guay jean-sebastien.guay at cm-labs.com
Mon Nov 9 13:41:10 PST 2009


Hi Wyatt,

> Is this what you are referring to?
> 
>         if (withBaseTexture)
>         {
>             scene->getOrCreateStateSet()->setTextureAttributeAndModes( 0,
> new osg::Texture2D(osgDB::readImageFile("Images/lz.rgb")),
> osg::StateAttribute::ON);
>         }

Nope, this:

         {
             // fake texture for baseTexture, add a fake texture
             // we support by default at least one texture layer
             // without this fake texture we can not support
             // textured and not textured scene

             // TODO: at the moment the PSSM supports just one texture 
layer in the GLSL shader, multitexture are
             //       not yet supported !

             osg::Image* image = new osg::Image;
             // allocate the image data, noPixels x 1 x 1 with 4 rgba 
floats - equivilant to a Vec4!
             int noPixels = 1;
             image->allocateImage(noPixels,1,1,GL_RGBA,GL_FLOAT);
             image->setInternalTextureFormat(GL_RGBA);
             // fill in the image data.
             osg::Vec4* dataPtr = (osg::Vec4*)image->data();
             osg::Vec4 color(1,1,1,1);
             *dataPtr = color;
             // make fake texture
             osg::Texture2D* fakeTex = new osg::Texture2D;
 
fakeTex->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_EDGE);
 
fakeTex->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_EDGE);
 
fakeTex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
 
fakeTex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
             fakeTex->setImage(image);
             // add fake texture
 
_stateset->setTextureAttribute(_baseTextureUnit,fakeTex,osg::StateAttribute::ON);
 
_stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_2D,osg::StateAttribute::ON);
 
_stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_3D,osg::StateAttribute::OFF);
             #if !defined(OSG_GLES1_AVAILABLE) && 
!defined(OSG_GLES2_AVAILABLE)
 
_stateset->setTextureMode(_baseTextureUnit,GL_TEXTURE_1D,osg::StateAttribute::OFF);
             #endif
         }

(sorry for the formatting, search for "fakeTex" in your sources and you 
should see it)

J-S
-- 
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.guay at cm-labs.com
                                http://www.cm-labs.com/
                         http://whitestar02.webhop.org/


More information about the osg-users mailing list