draw2dImage Alpha

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kevinsbro
Posts: 51
Joined: Fri Nov 05, 2010 8:18 pm

draw2dImage Alpha

Post by kevinsbro »

Is it possible to use the texture's alpha values when drawing 2D images?
I know you can get it so that either all or none of certain pixels are transparent, but what if I want a value in between for each pixel?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: draw2dImage Alpha

Post by Nadro »

draw2DImage allow enable alpha blending, so all values between 0-255 are available for pixels related to alpha.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
kevinsbro
Posts: 51
Joined: Fri Nov 05, 2010 8:18 pm

Re: draw2dImage Alpha

Post by kevinsbro »

I know that you can use alpha on the vertex level, but I want to be able to load a texture with an alpha channel and have it use that for alpha blending.

Currently, if you try and do this now, it clamps the value to all invisible or all visible.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: draw2dImage Alpha

Post by Nadro »

Which Irrlicht version do you use?
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
kevinsbro
Posts: 51
Joined: Fri Nov 05, 2010 8:18 pm

Re: draw2dImage Alpha

Post by kevinsbro »

I'm currently using Irrlicht 1.8.

I've taken a look at the source code on the direct x side of things and can tweak the code in CD3D9Driver::setRenderStates2DMode to change the alpha blending between the vertex alpha and texture alpha, but there seems to be something going on at the actual texture alpha. Somewhere else in the code the texture alpha must be getting clamped to either all (255) or none (0).

Can someone help me find where in the source this is happening?
The main method to look at is CD3D9Driver::draw2DImage
vroad
Posts: 18
Joined: Sun Jan 03, 2010 1:30 pm

Re: draw2dImage Alpha

Post by vroad »

Have you look at the documentation?
Just pass true to 'useAlphaChannelOfTexture' parameter.
http://irrlicht.sourceforge.net/docu/cl ... e526bbcdb3
Post Reply