Page 1 of 1

Transparency on textures with direct 3d 9

Posted: Tue Aug 18, 2009 3:03 am
by Rei
Hmm so I experienced a weird behaviour when using direct 3d 9 and transparent textures. The transparent part of the texture doesn't seem to draw other parts of the same node through the transparency.

This is probably a bad example, but oh well. Here is a screenshot showing what I mean. (models/textures arent mine, took them from some game)

First without transparency (see the white part at the top of the weapon - this is the part on each screenshot which I am referring to)
http://www.anime-fansubs.com/~reiko/tra ... _trans.jpg

Now with transparency on and using direct 3d 9. A little hard to see but the part that should show through on the same node isnt being drawn, instead whats behind (in this case the floor) is being drawn.
http://www.anime-fansubs.com/~reiko/tra ... _trans.jpg

Now with transparency on and using openGL, its drawn exactly as it should be.
http://www.anime-fansubs.com/~reiko/tra ... _trans.jpg

In this particular case it hardly seems like a big deal, but for other cases it can look kinda bad.

Here's a bit clearer example of what I mean:
http://www.anime-fansubs.com/~reiko/kel ... _front.jpg
http://www.anime-fansubs.com/~reiko/kellel_set_back.jpg

The skirt, arms and legs are part of the one mesh. At the bottom of the skirt at the frill part there is some transparency in the texture, but the legs/knees dont show through at that part, instead the background does.


So.. my question is, since I would prefer to use direct 3d 9, how can I get the same behaviour as the way it appears with opengl? Is there some flag I need to set somewhere?

Thanks.

Posted: Tue Aug 18, 2009 8:32 am
by hybrid
Sounds like an ordering problem, or maybe depth buffer related. Which version of Irrlicht do you use?

Posted: Tue Aug 18, 2009 9:13 am
by Rei
Using version 1.5.

Posted: Wed Aug 19, 2009 2:43 pm
by Reiko
I dont know if it matters but I forgot to say that burnings video also has the same behaviour as direct 3d 9 does in this case.

Posted: Wed Aug 19, 2009 9:24 pm
by Lonesome Ducky
I remember having a problem almost exactly like this. Hold on while I look for the thread.

EDIT: Here's a link to that thread: http://irrlicht.sourceforge.net/phpBB2/ ... ht=#172372
If you don't get an answer from there I'll try to solve your problem.

Posted: Thu Aug 20, 2009 8:50 am
by Eigen
I have the problem as well. I have to use EMT_TRANSPARENT_ALPHA_CHANNEL_REF instead which works correctly but doesn't look as good.

Posted: Thu Aug 20, 2009 9:46 am
by hybrid
If ALPHA_CHANNEL_REF works, it'S a problem with the z-ordering. Since transparent materials need to be ordered by depth, and rendered back-to-front, failure to do this inside meshes can lead to erroneous behavior. It's strange, though, to see nothing being rendered at that position. I'd have expected a wrong material maybe, but not nothing (besides background).

Posted: Thu Aug 20, 2009 3:13 pm
by Reiko
Im using EMT_TRANSPARENT_ALPHA_CHANNEL, but with _REF it does the same thing at my end.


edit: oops, my bad. I'm wrong, maybe I don't know what I'm doing because with _REF the transparent part is all black and not transparent at all.

Posted: Thu Aug 20, 2009 4:22 pm
by Lonesome Ducky
When you use REF, you need to set the parameters for the alpha. So

Code: Select all

node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
for (int x = 0; x < node->getMaterialCount(); x++) {
	node->getMaterial(x).MaterialTypeParam = 127;
}
Also try turning off lighting if it's still black.