Transparency: Texture Alpha + Vertex alpha?

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.
Nyxojaele
Posts: 98
Joined: Mon Sep 18, 2006 4:06 am

Post by Nyxojaele »

Ah yes, my apologies- I'd been busy the last couple days, and when I sat down to write something up for you today, it appears that you have already done so yourself. Good job ^^d
kh_
Posts: 78
Joined: Fri May 19, 2006 4:29 pm

Re: Transparency: Texture Alpha + Vertex alpha?

Post by kh_ »

Nyxojaele wrote:Is it possible to combine both transparency methods?
What I'm looking at is having billboards that use the alpha channel on the texture to define their transparency, but I want to be able to fade these billboards out over time
For anyone interested, I don't know if it works with alpha-channel textures, but using EMT_TRANSPARENT_ADD_COLOR material type and a color key texture, like "portal1.bmp", you can fade out billboards with billboard->setColor(SColor&)
You need to disable lighting for the billboard : bill->setMaterialFlag(video::EMF_LIGHTING, 0);

and set all 4 colors in setColor() to your new alpha:

Code: Select all

 driver->beginScene(true, true, SColor(255,200,200,200));
 bill->setColor(SColor(alpha,alpha,alpha,alpha));
// Set the color of all vertices of the billboard
(tested in ogl only)
MartinVee
Posts: 139
Joined: Tue Aug 02, 2016 3:38 pm
Location: Québec, Canada

Re: Transparency: Texture Alpha + Vertex alpha?

Post by MartinVee »

If someone ever wanders in this thread looking for an answer, there's now a way of doing it wihout having to implement a shader :

Code: Select all

 
  setMaterialType(video::EMT_ONETEXTURE_BLEND);
  getMaterial(0).MaterialTypeParam = irr::video::pack_textureBlendFunc(irr::video::EBF_SRC_ALPHA, irr::video::EBF_ONE_MINUS_SRC_ALPHA, irr::video::EMFN_MODULATE_1X, irr::video::EAS_TEXTURE | irr::video::EAS_VERTEX_COLOR);
  getMaterial(0).setFlag(EMF_BLEND_OPERATION, true);
 
It works with one texture. For multiple materials, you'll need a shader.

This will blend the texture alpha with the vertex alpha. You can then "modulate" the color of your texture by setting the node's vertex color. Works great to fade in/out a billboard that has a transparent texture on it.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Transparency: Texture Alpha + Vertex alpha?

Post by Vectrotek »

Very usefull! Cool. Thanks! :D
Post Reply