[SOLVED] Turn off blending overlapped textured planes?

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
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

[SOLVED] Turn off blending overlapped textured planes?

Post by pandoragami »

I have the following image consisting of randomly oriented textured planes (images of stars) and you can notice the blending when they overlap (it's a hazy white color).

Image

These are the settings I used,

Code: Select all

smgr->getMeshManipulator()->setVertexColorAlpha( mesh, 0.0f);
        node->setMaterialTexture( 0, driver->getTexture("627360main_potw1209a.png"));
        node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        node->setMaterialFlag(irr::video::EMF_BACK_FACE_CULLING, false);
        node->setMaterialFlag(irr::video::EMF_ZWRITE_ENABLE, true);
        node->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL);
        node->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
I wanted to know if there's a material type or flag I might be missing. I did search around here in the forums and this is the best it could get but maybe someone has another suggestion; if not that's fine. I'm thinking of using a giant sphere and putting a star-field texture onto that if this doesn't work.
Last edited by pandoragami on Tue Mar 24, 2015 3:55 am, edited 1 time in total.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Turning off blending between overlapping textured planes

Post by mongoose7 »

Code: Select all

node->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL);
node->setMaterialType(irr::video::EMT_TRANSPARENT_ADD_COLOR);
I guess you know that only the last one takes effect? Read the description - I think you don't want EMT_TRANSPARENT_ADD_COLOR. But using EMT_TRANSPARENT_ALPHA_CHANNEL requires you to set the alpha in the texture.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Turning off blending between overlapping textured planes

Post by hendu »

Depth writing for alpha also requires it be enabled in the driver, in addition to the material in question.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: Turning off blending between overlapping textured planes

Post by pandoragami »

mongoose7 wrote: But using EMT_TRANSPARENT_ALPHA_CHANNEL requires you to set the alpha in the texture.
OK, turned off the one I don't need but I can't find the method or class that sets the texture alpha; I tried ITexture and the meshmanipulator, any others?

@hendu

I have an ATI 5150 card so I would guess it's not that much of a piece of crap not to be able to do that but I digress, I'm not sure if it's enabled but we'll see if the texture alpha works, then I'll cry $250 dollars for a high end card.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Turning off blending between overlapping textured planes

Post by hendu »

I mean the irr driver. IVideoDriver->enableAlphaZWrite or some such.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: Turning off blending between overlapping textured planes

Post by pandoragami »

hendu wrote:I mean the irr driver. IVideoDriver->enableAlphaZWrite or some such.
I tried driver->setAllowZWriteOnTransparent(true); which is the closest thing I could find, didn't change much though. I guess I still need the set alpha for the texture itself to test it, no luck finding the method thus far.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Turning off blending between overlapping textured planes

Post by mongoose7 »

There is no method to set alpha in a texture. You need to do this in a paint program. But I don't know why you would need to write to the depth buffer. In fact, I think you don't want that.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: Turning off blending between overlapping textured planes

Post by pandoragami »

mongoose7 wrote:There is no method to set alpha in a texture. You need to do this in a paint program. But I don't know why you would need to write to the depth buffer. In fact, I think you don't want that.
Now it works! I had to use a png test image though, I can't get gimp to properly save the star-field image here's the result.

Image

I used the test image from w3 http://www.w3.org/Graphics/PNG/inline-alpha.html

and here are the settings with driver->setAllowZWriteOnTransparent(true); removed as well

Code: Select all

smgr->getMeshManipulator()->setVertexColorAlpha( mesh, 0.0f);
        irr::video::ITexture* tex = driver->getTexture("../../media/alphatest.png");
        this->node->setMaterialTexture( 0, tex);
        this->node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
        this->node->setMaterialFlag(irr::video::EMF_BACK_FACE_CULLING, false);   
        this->node->setMaterialType(irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL);
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: [SOLVED] Turn off blending overlapped textured planes?

Post by mongoose7 »

You can remove the setVertexColorAlpha as well. With GIMP, you are saving as PNG? You can't save as JPG because the format doesn't support alpha.
pandoragami
Posts: 226
Joined: Wed Jan 26, 2011 5:37 pm
Contact:

Re: [SOLVED] Turn off blending overlapped textured planes?

Post by pandoragami »

mongoose7 wrote:You can remove the setVertexColorAlpha as well. With GIMP, you are saving as PNG? You can't save as JPG because the format doesn't support alpha.
I'll do that, thanks :D. With GIMP I used a png but the procedure was wrong, I ended up using the "set color to alpha" (using black) instead of using a transparent layer and that fixed it.
Post Reply