Page 1 of 1

Confused about EMT_TRANSPARENT_ALPHA_CHANNEL

Posted: Tue Oct 05, 2004 11:26 am
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

Posted: Tue Oct 05, 2004 12:14 pm
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)

Posted: Tue Oct 05, 2004 1:32 pm
by Mr_Ridd
Thanks. this seams promising. :D

Will this work for UV's as well?

Posted: Tue Oct 05, 2004 2:19 pm
by arras
what do you mean UV's? You mean UV coordinates of texture?

Posted: Wed Oct 06, 2004 5:13 am
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?

Posted: Wed Oct 06, 2004 10:48 am
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

Posted: Wed Oct 06, 2004 10:54 am
by arras
Here is screenshot of tree and some plants I did from Irrlicht:

Image

Posted: Wed Oct 06, 2004 11:05 am
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().

Posted: Wed Oct 06, 2004 11:53 am
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

Posted: Thu Oct 07, 2004 5:15 am
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?

Posted: Thu Apr 14, 2005 5:23 pm
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.

Posted: Sat Apr 16, 2005 1:42 pm
by Pax