www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Disastorm on August 29, 2012, 09:18:10 am

Title: transparent objects depth?
Post by: Disastorm 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.

(http://i8.photobucket.com/albums/a23/Disastorm/device-2012-08-29-001220.png)
(http://i8.photobucket.com/albums/a23/Disastorm/device-2012-08-29-001236.png)
Title: Re: transparent objects depth?
Post by: EgonOlsen 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.
Title: Re: transparent objects depth?
Post by: Disastorm 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)
Title: Re: transparent objects depth?
Post by: 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.
Title: Re: transparent objects depth?
Post by: EgonOlsen on August 30, 2012, 07:06:49 am
More information: http://en.wikipedia.org/wiki/Painter's_algorithm (http://en.wikipedia.org/wiki/Painter's_algorithm)
Title: Re: transparent objects depth?
Post by: tomoroho 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.
Title: Re: transparent objects depth?
Post by: 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.
Title: Re: transparent objects depth?
Post by: tomoroho 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.
Title: Re: transparent objects depth?
Post by: EgonOlsen 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?
Title: Re: transparent objects depth?
Post by: tomoroho 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:
(http://img4.ph.126.net/IhQU9rjMqbHAg7A0_1Fxzw==/2752262322294518024.jpg)
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.
Title: Re: transparent objects depth?
Post by: 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.
Title: Re: transparent objects depth?
Post by: tomoroho 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.
Title: Re: transparent objects depth?
Post by: EgonOlsen 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.... ::)