Alpha Channel help

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
ShadowOfintent
Posts: 5
Joined: Wed Feb 11, 2009 10:56 am

Alpha Channel help

Post by ShadowOfintent »

So i've just started using the irrlicht engine i have managed to get get alpha channels working BUT i have run into a problem.

its not on the plane that i want it to be instead it creates a whole new sprite at the camera node start point

Image

i am using the alpha code:
// Alpha Channels

node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
node->setMaterialFlag(video::EMF_LIGHTING, true);
node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
node->setMaterialTexture(0, driver->getTexture("textures/factory/crane_pipe.tga"));
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I haven't the first clue at what you're even trying to achieve :lol:

Tell us what the picture should look like...
Image Image Image
ShadowOfintent
Posts: 5
Joined: Wed Feb 11, 2009 10:56 am

Post by ShadowOfintent »

haha fair enough WELL

the grate you see right. it should be alpha but instead its created a spirte in the background that is alpha of the same texture and i got no idea why.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Reeeeally not following you here. Any chance you could post some code, and explain (ideally with inline comments) what you expect it to do?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I think maybe you're not understanding how the engine works or something... The code you showed i would expect to create something similar to the alpha'd grate in the distance...

How is the non-alpha's grate created? is it part of the map geometry? Or is it a seperate model you've loaded? It's clearly not a billboard so it seems you've misunderstood something!
Image Image Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Re: Alpha Channel help

Post by bitplane »

Code: Select all

        node = smgr->addBillboardSceneNode(node, core::dimension2d<f32>(50, 50));
That's why it adds another sprite, because you're adding a billboard sprite to the scene.

You need to find the mesh buffer with this texture and set its material type.

Code: Select all

ITexture *tex = driver->getTexture("textures/factory/crane_pipe.tga");

// loop through materials in this node
for (u32 i=0; i < levelNode->getMaterialCount(); ++i)
{
    // get the material
    SMaterial &mat = levelNode->getMaterial(i);

    // if the diffuse texture is the grate then make it transparent
    if (mat.TextureLayer[0].Texture == tex)
       mat.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
}
Not guaranteed to work because I didn't compile it, but in future you should read and understand each line of code instead of just copying and pasting it and guessing at what it does. Go through the examples, they're not that hard!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
ShadowOfintent
Posts: 5
Joined: Wed Feb 11, 2009 10:56 am

Post by ShadowOfintent »

i made the model with GTKRadiant

and want the grate to be transparent i have tried the code posted by bitplane
and it still dosnt work =\
scooters rule =D
ShadowOfintent
Posts: 5
Joined: Wed Feb 11, 2009 10:56 am

Post by ShadowOfintent »

K. So i got it but now the box is to small i dont need the plane in GTK anymore but this is what i get

Image
scooters rule =D
Post Reply