transparent objects depth?

Started by Disastorm, August 29, 2012, 09:18:10 AM

Previous topic - Next topic

Disastorm

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.



EgonOlsen

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.

Disastorm

#2
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)

EgonOlsen

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.


tomoroho

Quote from: EgonOlsen 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.
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.

EgonOlsen

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.

tomoroho

Quote from: EgonOlsen 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.
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.

EgonOlsen

#8
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?

tomoroho

#9
Quote from: EgonOlsen on September 14, 2012, 09:33:13 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.

EgonOlsen

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.

tomoroho

Quote from: EgonOlsen 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.
works well,and I know why it occurs.It's very awesome.
thank you very much.

EgonOlsen

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.... ::)