Confused about EMT_TRANSPARENT_ALPHA_CHANNEL

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
Mr_Ridd
Posts: 63
Joined: Tue Sep 28, 2004 5:16 am

Confused about EMT_TRANSPARENT_ALPHA_CHANNEL

Post by Mr_Ridd »

Hey

If I want to put an alpha mask on a model, say a tree, for the leaves. Do I use EMT_TRANSPARENT_ALPHA_CHANNEL? I have tried this but it didn't work.

If not then what should I use?

Just another question, what is the difference between EMT_TRANSPARENT_ALPHA_CHANNEL and EMT_TRANSPARENT_VERTEX_ALPHA?

Thanks
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Code: Select all

video::ITexture* treeTexture = driver->getTexture(filename);

driver->makeColorKeyTexture(treeTexture, core::position2d<irr::s32>(0,0)); //change texture coordinates to choose diferent pixel

node->getMaterial(0).Texture1 = treeTexture;

node->getMaterial(0).BackfaceCulling = false; //will make all polygoons to be doublesided

node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
This code will make all pixels of texture with the same color as pixel 0,0 to be transparent (invisible)
Mr_Ridd
Posts: 63
Joined: Tue Sep 28, 2004 5:16 am

Post by Mr_Ridd »

Thanks. this seams promising. :D

Will this work for UV's as well?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

what do you mean UV's? You mean UV coordinates of texture?
Mr_Ridd
Posts: 63
Joined: Tue Sep 28, 2004 5:16 am

Post by Mr_Ridd »

Yeah. I tried it and it didn't work. It seems as though it didn't even take the pixel thing into account. If I use the TRANSPARENT_ALPHA flag it takes the extra bits away but it also makes the whole model transparent/ which I don't want. It did the same thing regardless of whether I applied the pixel co-ordinate method or not.

Is there anything else I could try?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

that's strange, it works perfectly for me...

try this bug fixes (I think its for Irrlicht v.0.6):
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2977

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=3130
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Here is screenshot of tree and some plants I did from Irrlicht:

Image
Mr_Ridd
Posts: 63
Joined: Tue Sep 28, 2004 5:16 am

Post by Mr_Ridd »

Thats exactly what I want. Did you have to do the fixes to get yours to work.
See the problem is, as I said, that it is taking away the unwanted areas but it's also making the whole model transparent. Isn't there some way I can change the transparency of a single object, setTranspency().
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I dont remember anymore if I was applying that bug fixes. But it doesn't have nothing to do with object transparency.

look also here for some ideas:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2679
Mr_Ridd
Posts: 63
Joined: Tue Sep 28, 2004 5:16 am

Post by Mr_Ridd »

Well I eventually got it to work. It was because I was using OpenGL. I'm got a bit of a saga now because DX9 or DX8 looks bad but the Alphs works. Anyway..

There is still a bit of an issue with it though. It's making the (0,0) pixel co-oord which is black, transparent, but if I look at another model through the transparent parts it's like it's taken those pixels away but hasn't drawn whats behind it. It's quite odd because when I first load it in, I have a sky box, and it seems to be taking the color of the skybox for it's transparency.

Is there any way to fix this?
Il_pax_temp

Post by Il_pax_temp »

Hi guys, i also have a problem with my transparency:

Image

I know my .tga file is ok, (it laods fine in giles[s], with alpha channel). The code is:

IAnimatedMesh* follaje1 = smgr->getMesh("mediaf/afolla.obj");
IAnimatedMeshSceneNode* node4 = smgr->addAnimatedMeshSceneNode(follaje1);
node4 -> setMaterialFlag(EMF_LIGHTING, false);
node4 -> setMaterialTexture(0, driver->getTexture("mediaf/u34.tga"));
node4 -> setMaterialType (EMT_TRANSPARENT_ALPHA_CHANNEL);

I've read:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6116
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6104
http://irrlicht.sourceforge.net/phpBB2/ ... ik&start=0
but haven't yet found a fix.

I'm using dev-cpp with irrlicht .9, OpenGL (so no possibility to try with Direct X, as i haven't yet been able to compile a new .dll)

Please let me know if there is a fix.
Pax
Posts: 12
Joined: Sat Apr 16, 2005 1:29 pm

Post by Pax »

Post Reply