Page 1 of 1

transparency in textures does not work

Posted: Fri Jan 27, 2006 9:05 pm
by warden
hi there, now i'm really stuck. hope some of you guys can help me out.

i'm trying to create a 3d-user interface. however, starting with the basics I want to create round circular widgets. to keep it simple I put a circle image texture on a testscenenode (simple cube mesh) and make the corners transparent.

well, and thats the problem. i don't get it to be transparent.

plz take a look at the following code snippet:

Code: Select all

scene::ISceneNode* widget = smgr->addBillboardSceneNode(0,core::dimension2d<f32>(1.0f,1.0f),core::vector3df(0.0f,0.0f,-1.0f),-1);
//scene::ISceneNode* widget = smgr->addBillboardSceneNode(0,core::dimension2d<f32>(1.0f,1.0f),core::vector3df(0.0f,0.0f,-1.0f),-1);
//device->getVideoDriver()->setTextureCreationFlag(video::ETCF_ALWAYS_16_BIT, true);
video::ITexture* wgtex = driver->getTexture("../../media/circle.bmp");
driver->makeColorKeyTexture(wgtex, core::position2d<s32>(0,0));
widget->setMaterialTexture(0, wgtex);
widget->setMaterialFlag(video::EMF_LIGHTING, false);
widget->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
//widget->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
//widget->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
as you can see i tried many ways. theoretically, the makeColorKeyTexture should be best. it doesn't work at all, anyway! not with 16 bit textures, not with 32 bit, not if 16 bit is forced (32bit is standard in .14, right?), not if I add a material type.
the only transparent effect I get, is when the corners of the circle are dark and I choose EMT_TRANSPARENT_ALPHA_CHANNEL_REF. This is unacceptable as I need dark colours for UI design. EMT_TRANSPARENCY_ADD_COLOR works as well, but I need bright colour to be solid as well. with EMT_TRANSPARENT_ALPHA_CHANNEL the whole texture is invisible. All this is independent of the use of makeColorKeyTexture which as no effect at all.

Other options I tried: orthogonal projection vs perspective, billboardscenenode instead of testscenenode.

erm, please help me!

best regards,
warden

Posted: Fri Jan 27, 2006 9:33 pm
by dawasw
Why not trying up a .tga file with alpha channel selection ;) ?

Posted: Fri Jan 27, 2006 10:01 pm
by warden
dawasw wrote:Why not trying up a .tga file with alpha channel selection ;) ?
i didn't know how to do it. thanks to your advice I tried something with photoshop and it looks quite good. I assume I add an alpha channel and use the eraser or could you give me a short tutorial on this?

thank you, sometimes you try to open a door while standing next to it touching the wall... erm yeah! next glass of zoladkowa gorzka is devoted to you!!

Posted: Wed Dec 27, 2006 6:39 pm
by miko93
Well, although having a solution as proposed by dawasw, I tried the same way warden did. And ran into exactly the same problems (see above). Anyone got this working?

Thanks