transparent texture

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.
ghiboz
Posts: 37
Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:

transparent texture

Post by ghiboz »

Hi all!
I have this problem:
I have some trees bult with 2 planes and the texture use the alpha channel to determine the transparent zone...
first impression seems to work:
Image
but if i move on the right, and the trees are between the camera and the building i see this effect:
Image
the problem seems that if there's something behind the object with the transparent alpha channel, happens that is not rendered, otherwise (look for example the top of the trees, that have nothing except the skybox behind, are rendered correctly

i tried to set the EMT_TRANSPARENT_ALPHA_CHANNEL or EMT_TRANSPARENT_ALPHA_CHANNEL_REF but doesn't change nothing.

thanks in advance!

ghiboz
ghiboz
Posts: 37
Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:

Post by ghiboz »

if i set the lighting material to false, works correctly with the buliding (that have lighting =true)but gives same error with the other trees object...
thanks! :wink:

i tried to change all the textures from tga with alpha channel to png with transparent zones, now the problem is only an object with a transparent texture that have behind another object with transparent texture.... :(
PuG
Posts: 13
Joined: Wed Mar 05, 2008 12:11 pm

Post by PuG »

Im new to Irrlicht! but to me that looks like a sort order problem, or zbuffer?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah it's a sorting order problem, but i thought irrlicht took care of that so there must be something else going on to cause the problem...

It's strange that changing the texture format fixed part of the problem though...
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This is once more a problem with the hard-coded zbuffer disabling, that was reintroduced in 1.4. Please remove the lines with ZWriteEnable=false in the MaterialRenderer files. You'll have to take care for proper setting of that flag for billboards etc.
ghiboz
Posts: 37
Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:

Post by ghiboz »

hybrid wrote:This is once more a problem with the hard-coded zbuffer disabling, that was reintroduced in 1.4. Please remove the lines with ZWriteEnable=false in the MaterialRenderer files. You'll have to take care for proper setting of that flag for billboards etc.
thanks mate... you're helping me very much!!!!
i commented this in the "CD3D9MaterialRenderer.h"

Code: Select all

((SMaterial&)material).ZWriteEnable = false;
and works fine now!!!
:wink:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, this is an open issue, we'll keep it in mind. It was reverted because many people complained about problems with transparent billboards etc. But I guess we just need to add some more SMaterial getters and setters to set the zbuffer once, and let the user change it after that. Silently forcing the value to something fixed is quite...fixed.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

hello!
i want to put two textures in one model. a skin and a tatoo for example.
if i have 10 skins and 10 tatoos, then it's a little hard to make them to one texture.
so i thought the best way to do is, put a texture to the model(skin), and put another texture(tatoo) in top of it with alpha channel.
but when i searched how to do it, i just found how to use two textures in one model, and how to use alpha channel... but how can i do both? xD
or there is another way to do it?
maybe i don't want to use just 2 layers, maybe more.. but i necessary need 2 layers.
do you have any idea how to do it? maybe i should do it without alpha, but i don't know how.

thank you for help
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

the solid 2 layer material could make this possible, does require proper vertex alpha values. Otherwise you need an additional material which would do similar things with the alpha channel instead.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

sorry, but how can i give the proper vertex alpha values to irrlicht?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You simply set them in the vertices.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

you mean in the 3d modeller? can i do it in milkshape?
doqkhanh
Posts: 158
Joined: Sat Mar 01, 2008 3:14 am
Location: Tokyo, Japan
Contact:

Post by doqkhanh »

I had the same problem to you.
Hope this be helpful.

Code: Select all

video::E_MATERIAL_TYPE leafMaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;

tree->getLeafNode()->setMaterialType( leafMaterialType );
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thank you, but it's only just for one layer right?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you set the vertex alpha values in the modeller you have to be sure that your mesh format supports vertex colors. Otherwise you do it in Irrlicht, by directly accessing the vertices.
EMT_TRANSPARENT_ALPHA only supports one texture, whereas you'd need two.
Post Reply