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 Classic Chat / [bug] 3d object appear behind transparent 3d plane.

Author
Message
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 5th May 2015 11:21 Edited at: 5th May 2015 11:23
3d object (tree) sometimes appear behind transparent 3d plane ( water ). but only on transparent planes, if i set it (water) to non transparent it works fine.





Must be something with distance , if you get closer it works.





if a non transparent object (jeep) get in the middle it works.





best regards Preben Eriksen,
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 12th May 2015 21:12 Edited at: 14th May 2015 00:52
I've seen something like this before. I didn't mention it at the time as it was at the height of everyone moaning about the progress of AppGameKit V2 and I figured it would all only get sorted out when Paul started work on the 3D commands.

I can't quite remember the combination of things I did to stop if from happening. It wasn't a solution, just a compromise on the design.

I'll have a look into it and see if I can recreate it.

[edit]
This is what I've seen before:



The image on the left is what I want, in this case it's a section of race track going through a ring.

The image in the middle is achieved simply by turning on both objects transparencies using the "SetObjectTransparency" command.



The image on the right was when I simply loaded the objects in a different order:



Note, the actual alpha of both objects is 255 which is why they don't appear transparent but this doesn't actually effect what's going on. The last object to be created is drawn on top of the previous one. It also doesn't matter if you set the transparency modes to 2.

In my game (Hover Car Race Challenge Accepted) I wanted the scenery objects, such as the ring, to fade in, as the camera got closer. I also wanted the track to fade in but couldn't do this because of this graphical issue. So track sections "pop in" which isn't ideal but I lived with it.

Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB

Attachments

Login to view attachments
Facias
12
Years of Service
User Offline
Joined: 20th Apr 2012
Location:
Posted: 17th May 2015 06:19
This is not a bug. Transparent objects do not utilize the depth buffer so you can effectively see content behind them. What this means is there is some approximation as to where the object is relative to other objects on the field. By default, agk uses a sorting algorithm based on the object's distance from the camera to draw each transparent object in order from furthest to nearest. While this works in some cases as far as making things look accurate, you're bound to run into situations like this where the draw order seems messed up.

One thing you can do is enable depth writing on the tree. This will make sure the water doesn't get drawn over it. However, this can have ugly results if you don't enable alpha testing as well.

You can also use the Draw Object function to specifically draw the tree after the water has been drawn to make sure there is no confusion. Ultimately, dealing with semi-transparent objects will pretty much always require a special level of care, even if you're working in a perfect engine.
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 27th May 2015 16:06
Thanks for your help.

SetObjectDepthWrite(trees[a].treeid ,1)

Did the trick for me.

29 games: I dont think that will solve your problem , i think it would only be solved by setting both objects as non transparent. perhaps a new smart command is coming with the new 3d commands

best regards Preben Eriksen,

Login to post a reply

Server time is: 2024-04-20 05:49:48
Your offset time is: 2024-04-20 05:49:48