Hello, I'm trying to write a multitexture rendering
with 2 textures: one diffuse and one alpha (grayscale
bmp). I'm using the following code:

osg::Image* osg_image= new osg::Image;          
osg_image->setFileName("diffuse.tga");
osg::Texture2D* osg_texture = new osg::Texture2D;
osg_texture->setImage(osg_image);
// Use the diffuse texture on the first texture unit.
state->setTextureAttributeAndModes(0, osg_texture,
osg::StateAttribute::ON);

osg::Image* osg_image2= new osg::Image;
osg_image2->setFileName("mask.bmp");
osg::Texture2D* osg_texture2 = new osg::Texture2D;
// Use the mask texture as alpha channel only.
osg_texture2->setInternalFormat(GL_ALPHA);
osg_texture2->setImage(osg_image2);
// Use the mask texture on the second texture unit.
state->setTextureAttributeAndModes(1, osg_texture2,
osg::StateAttribute::ON);

// First texture stage
osg::TexEnvCombine *te = new osg::TexEnvCombine;    
// Modulate diffuse texture with vertex color.
te->setCombine_RGB(osg::TexEnvCombine::MODULATE);
te->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
te->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
te->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
te->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
// Alpha doesn't matter.
te->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
te->setSource0_Alpha(osg::TexEnvCombine::PREVIOUS);
te->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
state->setTextureAttribute(0, te);

// Second texture stage.
osg::TexEnvCombine *te2 = new osg::TexEnvCombine;
te2->setCombine_RGB(osg::TexEnvCombine::MODULATE);
te2->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
te2->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
te2->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
te2->setOperand1_RGB(osg::TexEnvCombine::SRC_ALPHA);
te2->setCombine_Alpha(osg::TexEnvCombine::REPLACE);
te2->setSource0_Alpha(osg::TexEnvCombine::TEXTURE);
te2->setOperand0_Alpha(osg::TexEnvCombine::SRC_ALPHA);
state->setTextureAttribute(1, te2);

Now, alpha texture is always white. I've tried to use
it as luminance and it shows correctly but when I use
it as alpha it is always white? Are there another
states that needs to be set or is there an opened
issue with alpha textures on OSG?



 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to