www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: gamenewer on January 03, 2015, 02:58:29 am

Title: Question about transparency
Post by: gamenewer on January 03, 2015, 02:58:29 am
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 !
Title: Re: Question about transparency
Post by: EgonOlsen on January 03, 2015, 10:58:47 am
Try a larger value for the transparency like 255.
Title: Re: Question about transparency
Post by: gamenewer on January 03, 2015, 11:34:50 am
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. :-\
Title: Re: Question about transparency
Post by: EgonOlsen on January 03, 2015, 02:09:10 pm
Have you adjusted the transparency settings in Config and/or are you a custom shader?
Title: Re: Question about transparency
Post by: gamenewer on January 04, 2015, 01:38:35 am
I have't chang the transparency settings, and I don't use a custon shder,  everything is default.
Title: Re: Question about transparency
Post by: Lobby on January 04, 2015, 09:58:41 am
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.
Title: Re: Question about transparency
Post by: EgonOlsen on January 04, 2015, 12:14:04 pm
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?
Title: Re: Question about transparency
Post by: gamenewer on January 05, 2015, 10:58:08 am
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 :-[
Title: Re: Question about transparency
Post by: Lobby on January 05, 2015, 11:21:44 am
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.

Yes, that sounds like the z-ordering problem on transparent objects. See this topic (http://www.jpct.net/forum2/index.php/topic,4232.0.html) 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).
Title: Re: Question about transparency
Post by: gamenewer on January 05, 2015, 01:31:54 pm
Thank you Lobby !   :)