Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / 3D Depth issues created based on the order that objects are created

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Aug 2020 04:51 Edited at: 19th Aug 2020 05:10


The red object shadow is displayed in front of the object and the green shadow behind.
The only difference between the two instances is that the red shadow is created BEFORE the red object and the green shadow is created AFTER the green object

I don't think i can use cull mode or depth write because my billboard has front and back facing polys and it is transparent.
There's a link in there setting SetObjectDepthWrite if you want to try it. (See the attached project)

Thanks for any help


UPDATE: If I clone the object is appears to affect the render order as well

Attachments

Login to view attachments
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 19th Aug 2020 07:24
cant say ive had that problem before i did not find solution. it is int he documents however that transparent object dont write to the zbuffer.

GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 19th Aug 2020 08:54 Edited at: 20th Aug 2020 01:44
It's not an AppGameKit specific thing (has been like this in basically all 3D engines), so maybe that's why they didn't mention it in the docs.
If transparent surfaces would write to the zbuffer the ones drawn first would block out everything drawn later behind themselves (behind the entire poly, even if parts of it are fully transparent). It would make rendering things like layered smoke and other common effects with layered transparent polies impossible and introduce even worse visual artefacts than what the missing sorting adds now.
Some engines do have a pre-sorter that can constantly adjust the rendering order for transparent objects or polies. That's a decent bandaid at the cost of some CPU side performance.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Aug 2020 10:52 Edited at: 19th Aug 2020 10:53
So the only way around this issue is the creation order is that right?
Also there doesn't appear to be anything i can do when the object is cloned
GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 19th Aug 2020 16:03 Edited at: 19th Aug 2020 18:23
Actually it seems you are in luck, I tested it quickly and AppGameKit auto-sorts alpha blended objects.

Here is a test project, it shows that the shadows remain behind the main objects and the objects switch being in front based on their position. (it's just the source, you have to run it in AppGameKit, no exe included)
The second object and it's shadow are both instanced from object 1 and both object and shadows use alpha blended mode.
The only trick I used is to position the pivot of the shadow planes lower, so that they are always further from the cam than their corresponding object.
Runs for me in both Studio and Classic.

Attachments

Login to view attachments
Scribble
7
Years of Service
User Offline
Joined: 2nd Apr 2017
Location:
Posted: 19th Aug 2020 18:17 Edited at: 5th Nov 2021 12:40
BlinkOk, I had this problem before, and has solved it by using SetObjectAlphaMask() instead of SetObjectTransparency().

The order of drawing is perfect when using SetObjectAlphaMask().

The only downside of SetObjectAlphaMask(), is that it cannot draw 'partial transparency' correctly. Any spot on the texture that contain even a slightest bit of transparency will be drawn as completely transparent, no partials. But otherwise, it's perfect
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Aug 2020 21:01
Excellent! Thanks guys, those approaches both work.

Login to post a reply

Server time is: 2024-04-20 06:49:39
Your offset time is: 2024-04-20 06:49:39