Issue with multi-texturing

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
aglagla
Posts: 1
Joined: Fri May 22, 2015 4:52 pm

Issue with multi-texturing

Post by aglagla »

Hi there,

I have a strange problem using Irrlicht (OpenGL) on Windows with multitexturing.

I am trying to display a simple cube with 2 textures. At first it worked ok, but later I added a second cube without any texture... and a strange thing occured: when the second cube is displayed, the first cube does not use the second texture anymore!

See the following example:

Code: Select all

 
//load 2 texture (image is a standard image with no alpha channel, image2 is a semi transparent image with alpha)
video::ITexture* image = _driver->getTexture("image.jpg");
video::ITexture* image2 = _driver->getTexture("alpha-image.png");
 
//create a cube and assign 2 textures
IMeshSceneNode* myNode = _smgr->addCubeSceneNode(500);
myNode->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL);
myNode->setMaterialTexture(0, image);
myNode->setMaterialTexture(1, image2);
    
//create a dummy cube   
IMeshSceneNode* myNode2 = _smgr -> addCubeSceneNode(10); //IF I COMMENT THIS LINE THE FIRST CUBE IS OK
    
// STANDARD RUN LOOP    
while(_device->run())
{
    if(_input.IsExit())
    {
        _device->closeDevice();
    }
    _driver->beginScene(true, true, SColor(255,0,0,0));     
    _smgr->drawAll();
    _driver->endScene();
}
 
If I comment the line:
IMeshSceneNode* myNode2 = _smgr -> addCubeSceneNode(10);

The display is as expected (picture on top) and with the line the alpha image is not used anymore (bottom image)

Image

Any idea? Is there something wrong in my code? Is it expected?

Thanks for any help!
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Issue with multi-texturing

Post by hendu »

The EMT_TRANSPARENT_ALPHA_CHANNEL material only supports one texture. So the bug is having the second texture visible at all.

You should write a shader to use multiple textures in any way you wish.
Post Reply