Question about transparency

Started by gamenewer, January 03, 2015, 02:58:29 AM

Previous topic - Next topic

gamenewer

Hello , I  have a texture like attached picture, I only want the black part transparency, but  when I use Object3D.setTransparency,  the whole object become transparency,  How to resolve this problem ? thanks !

EgonOlsen

Try a larger value for the transparency like 255.

gamenewer

I used 300 for the transparency value, but it still looks  transparency. and I try to use a  transparency texture, the same result I got. :-\

EgonOlsen

Have you adjusted the transparency settings in Config and/or are you a custom shader?

gamenewer

I have't chang the transparency settings, and I don't use a custon shder,  everything is default.

Lobby

In order to load a texture with alpha channel you have to use a Texture constructor where you specify the useAlpha parameter with true. Otherwise the transparency won't be loaded. A setTransparency(15) should then be enough to see the changes. Be aware that you may get problems with the drawing order when using transparency like this.

Here I would recommend instead a own shader which just doesn't draw one specific color (like black). This also would solve the Z-Order problem.

EgonOlsen

I've still no idea why the non-black parts should appear transparent when using a high transparency value. Maybe we are talking about different things here...do you have a screen shot?

gamenewer

I'm sorry,  there are  three ojbect  A , B , C  use the same texture,     B behind the A  and C behind the B,   but it seems   b and c  can see  through A .  It maybe the Z-Order problem. If there is a good,simple way to resolve this ?

To Lobby:  Could you give a   custom shader to resolve this problem?  I'm a newner  about shader.   Thank you very much :-[

Lobby

Quote from: gamenewer on January 05, 2015, 10:58:08 AMB behind the A  and C behind the B,   but it seems   b and c  can see  through A .  It maybe the Z-Order problem.

Yes, that sounds like the z-ordering problem on transparent objects. See this topic for more information. I also provide there a sample with a costum shader to solve the problem using alpha testing (which just means that fully transparent texels won't be drawn).

gamenewer