Transparency on textures with direct 3d 9

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Rei
Posts: 4
Joined: Mon Aug 17, 2009 1:51 pm

Transparency on textures with direct 3d 9

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Sounds like an ordering problem, or maybe depth buffer related. Which version of Irrlicht do you use?
Rei
Posts: 4
Joined: Mon Aug 17, 2009 1:51 pm

Post by Rei »

Using version 1.5.
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post 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.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post 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.
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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).
Reiko
Posts: 105
Joined: Sun Aug 16, 2009 7:06 am
Location: Australia

Post 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.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post 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.
Post Reply