Page 1 of 2

2D image transparency?

Posted: Tue Feb 24, 2004 1:07 pm
by Dark_Exodus
Hi

I'm trying to draw a 2D image over my quake 3 map (like a HUD) but I can’t get transparency to work. The complete image is drawn to the screen.
:(

Here is the code I’m using:
driver->makeColorKeyTexture(lives,core::position2d<s32>(0,0));

driver->draw2DImage(lives,core::position2d<s32>(500,0));

Posted: Wed Feb 25, 2004 11:30 am
by Dark_Exodus
no one able to help? :(

Posted: Fri Feb 27, 2004 1:26 am
by Masdus
i had a problem like this in a earlier version of irrlicht. I'm not sure if the alpha setting affects 2d images, or i may be a problem with the format your image is stored in.

Posted: Fri Feb 27, 2004 2:03 am
by thesmileman
You might try rt's png load, since png's support transparency. (I know thats not really what you want but maybe it will work for you until you can get the other figured out)

Posted: Fri Feb 27, 2004 2:28 am
by rt
thesmileman wrote:You might try rt's png load, since png's support transparency. (I know thats not really what you want but maybe it will work for you until you can get the other figured out)
if you don't want to bulid in .png supprt, you can use 32bit .tga which also supports an alpha channel. you have to tweak some of the render settings in the engine since they don't seems to be set correctly for image alpha blending .. check out my PNG thread to learn more

Posted: Fri Feb 27, 2004 6:30 pm
by Dark_Exodus
Ok thanks guys I'll try using a different picture format.

Posted: Sun Feb 29, 2004 12:11 pm
by Masdus
let us know if you find a solution

Posted: Sun Feb 29, 2004 1:56 pm
by Dark_Exodus
sure thing :D

Posted: Sun Feb 29, 2004 10:56 pm
by shurijo
I'm having a similiar problem. The transparency (makeColorKeyTexture) almost works... my ugly purple (target color) becomes black instead of transparent, so it covers the stuff underneath it.

Posted: Wed Mar 03, 2004 12:30 am
by Masdus
transparency for one color works, look at the 2D tutorial. I have previously used the command without a problem but i haven't tried it with 0.5 yet. Have your declared makeColoeKeyTexture the same as in the 2D graphic tutorial?.

Posted: Fri Mar 05, 2004 12:35 pm
by Dark_Exodus
I think I did. :roll: I'll go back and have a look at that.

Posted: Fri Mar 05, 2004 3:45 pm
by Xception
There are 2 "draw2DImage" methods.
You have to use the other one with more parameters that supports transparency like in the 2DGraphics example:

Code: Select all

// draw flying imp 
driver->draw2DImage(images, core::position2d<s32>(164,125),(time/500 % 2) ? imp1 : imp2, 0, video::SColor(255,255,255,255), true);

Posted: Mon Mar 08, 2004 12:45 pm
by Masdus
I have just thought of a cheap hack that might be useful. This used to be used on website with DHTML to create transparent images. Take you image and load into a editor like photoshop. Then make evey second pixel of the image the same color as your are using for makeColorKeyTexture. Now when the image i drawn every 2nd pixel is tranparent, which give te impression of a transparent image. However if your are using small images, or images with a lot of detail this would probably not be the best method. You can also change which pixels you change to try for slight different level o transparency, like using interlacing (evey 2nd or so line use the ugly purple color)

Posted: Mon Mar 08, 2004 3:46 pm
by Luke923
I know that this might be a stupid question, but is the first pixel in your image the transparent color? Otherwise, try using "dirver->makeColorKeyTexture(lives, video::SColor(255,255,255,255));"

Posted: Mon Mar 08, 2004 5:38 pm
by NecromanX
listen to what Xception says.
The function you use simply draws an image as stated in the API,
the second function will also apply the alpha channel when setting the last parameter to true. try this instead:

driver->makeColorKeyTexture(lives,core::position2d<s32>(0,0));

driver->draw2DImage(lives,core::position2d<s32>(500,0),core::rect<s32>(0,0,x,x), 0,video::SColor(255,255,255,255), true);

change the 2 x values with the size of your picture minus 1 then it will apply the alpha channel and your image will be transparent