Author Topic: Question about transparency  (Read 3799 times)

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Question about transparency
« 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 !

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Question about transparency
« Reply #1 on: January 03, 2015, 10:58:47 am »
Try a larger value for the transparency like 255.

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Question about transparency
« Reply #2 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. :-\

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Question about transparency
« Reply #3 on: January 03, 2015, 02:09:10 pm »
Have you adjusted the transparency settings in Config and/or are you a custom shader?

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Question about transparency
« Reply #4 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.

Offline Lobby

  • int
  • **
  • Posts: 66
    • View Profile
    • flowersoft
Re: Question about transparency
« Reply #5 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Question about transparency
« Reply #6 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?

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Question about transparency
« Reply #7 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 :-[

Offline Lobby

  • int
  • **
  • Posts: 66
    • View Profile
    • flowersoft
Re: Question about transparency
« Reply #8 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 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).

Offline gamenewer

  • long
  • ***
  • Posts: 171
    • View Profile
Re: Question about transparency
« Reply #9 on: January 05, 2015, 01:31:54 pm »
Thank you Lobby !   :)