Blend mode

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
flip21
Posts: 2
Joined: Tue Feb 02, 2021 2:28 pm

Blend mode

Post by flip21 »

Hello! I'm trying to draw textures with transparency.

I already tried to set BlendOperation to BlendOperation.Add for the material. The problem is that black borders appear.

So I would like to use textures with premultiplied alpha, drawing them using the following blend mode:

blend(source, dest) = (source.rgb * source.a) + (dest.rgb * (1 – source.a))

The problem is that I don't know how to configure this blend mode in Irrlicht. Please help! :(

Note: I'm currently using the Irrlicht Lime .NET wrapper.

Thank in advance!
CuteAlien
Admin
Posts: 9647
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Blend mode

Post by CuteAlien »

Premultiplied - so your texture are not having alpha anymore but using black for clipped out areas already?
That would need EMT_TRANSPARENT_ADD_COLOR as materialType, but that doesn't fit with your formula.
Your formula looks more like what you get for EMT_TRANSPARENT_ALPHA_CHANNEL which directly uses the alpha-channel of the texture.

It's also possible to set custom formulas with EMT_ONETEXTURE_BLEND, but that one changed a bit between version 1.8 and svn trunk and I also have to figure it out myself each time (bit tricky stuff...).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply