Author Topic: transparent objects depth?  (Read 2259 times)

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
transparent objects depth?
« on: August 29, 2012, 09:18:10 am »
Hello is there any way to fix this? Depending on the camera angle certain polys of transparent objects seem to appear in front of things that they should be behind.



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #1 on: August 29, 2012, 09:48:51 pm »
No, there's no way to fix this except for splitting the objects into several smaller ones. Transparent objects will be sorted by depth and rendered back to front. But they can only be sorted by object, not by polygon which results in this kind of artifacts when seen from specific angles.

Offline Disastorm

  • long
  • ***
  • Posts: 161
    • View Profile
Re: transparent objects depth?
« Reply #2 on: August 30, 2012, 01:34:37 am »
That sounds like it would explain part of the grass showing up inside itself, but the grass, the bush, and the fog are 3 different objects though (they are all clones of other grass, fog, and bushes though, not sure if thats related)
« Last Edit: August 30, 2012, 01:36:20 am by Disastorm »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #3 on: August 30, 2012, 07:06:11 am »
That's another, albeit related issue. The sorting has to use some point of the object to determine its depth. So it takes the center of the object transformed into camera space. As you can easily imagine, this sorting can never be perfect in all cases (if it where, nobody would need a depth buffer at all), which leads to these results. For special cases, you can tweak the sorting with Object3D.setSortOffset(), but that's most likely not suitable here.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #4 on: August 30, 2012, 07:06:49 am »

Offline tomoroho

  • byte
  • *
  • Posts: 16
    • View Profile
Re: transparent objects depth?
« Reply #5 on: September 11, 2012, 02:28:37 pm »
That's another, albeit related issue. The sorting has to use some point of the object to determine its depth. So it takes the center of the object transformed into camera space. As you can easily imagine, this sorting can never be perfect in all cases (if it where, nobody would need a depth buffer at all), which leads to these results. For special cases, you can tweak the sorting with Object3D.setSortOffset(), but that's most likely not suitable here.
I also encounter this problem. I need to set the object transparency to make "every pixel with a color of #000000 will be completely transparent ". And the problem occurs. When rotating the whole scene in certain angle,the object which should be in front is rendered to back.  How to make object A in front of object B from whatever camera angle. I think in my scene , object A is in front of object B for ever when it is visible. can the method setSortOffset works. I set the offset of object A always bigger or smaller than object B,it doesn't work.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #6 on: September 11, 2012, 09:06:38 pm »
If A should always be in front of B, give A a very low negative offset like -100000. If these objects are the only ones that are transparent in the scene, you can give B a very offset instead too.

Offline tomoroho

  • byte
  • *
  • Posts: 16
    • View Profile
Re: transparent objects depth?
« Reply #7 on: September 13, 2012, 06:27:18 pm »
If A should always be in front of B, give A a very low negative offset like -100000. If these objects are the only ones that are transparent in the scene, you can give B a very offset instead too.
yep.it works. Finally I make the showing of different lays of transparent object stably through this method,though it's a little
trivial because there is tens of objects.
But there is a weird problem during this,Object A is invisible though its sortoffset is smaller than (>10000)Object B. I set the both
objects with the method setCullingenable(false). Then A is visible but it's not what it supposed to be , It looks like being seen through from object B. How the culling happens, object A is not outside the camera space and the sortoffset makes it in front of object B.
Thank you very much.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #8 on: September 14, 2012, 09:33:13 am »
Culling happens based on the actual position. It's not affected by the sort offset. Anyway, i don't really understand your description...do you have a screen shot?
« Last Edit: September 14, 2012, 11:14:44 am by EgonOlsen »

Offline tomoroho

  • byte
  • *
  • Posts: 16
    • View Profile
Re: transparent objects depth?
« Reply #9 on: September 14, 2012, 10:18:01 am »
Calling happens based on the actual position. It's not affected by the sort offset. Anyway, i don't really understand your description...do you have a screen shot?
as the image below showing:

when all object set culling disable,it displays like what the image showing.
And when not set,the number "08 00 " is invisible.And they're just in front of the panel with a much lower sortoffset.
« Last Edit: September 14, 2012, 10:33:01 am by tomoroho »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #10 on: September 14, 2012, 11:22:08 am »
With setCulling, you are setting the backface calling. It has nothing to do with camera calling. Maybe the vertex order of the number meshes is just wrong. That would explain the darker look without backface culling too, because the normals used for the lighting calculations would be pointing away from the camera. Try to leave calling enabled but call invert() on the numbers before calling build() to see if that helps.

Offline tomoroho

  • byte
  • *
  • Posts: 16
    • View Profile
Re: transparent objects depth?
« Reply #11 on: September 14, 2012, 11:46:40 am »
With setCulling, you are setting the backface calling. It has nothing to do with camera calling. Maybe the vertex order of the number meshes is just wrong. That would explain the darker look without backface culling too, because the normals used for the lighting calculations would be pointing away from the camera. Try to leave calling enabled but call invert() on the numbers before calling build() to see if that helps.
works well,and I know why it occurs.It's very awesome.
thank you very much.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: transparent objects depth?
« Reply #12 on: September 15, 2012, 09:30:35 am »
I'm glad it worked. And please ignore that i've written calling instead of culling multiple times...it's caused by the auto-complete of the phone.... ::)