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] Object transparency/culling not working

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Oct 2018 08:26 Edited at: 22nd Oct 2018 08:36
NOTE: If i change the order of loading the objects it works. So if i load floor, control and then ball it works. I think it still needs fixing because sometimes that may not be possible

(Run the project and you will see the problem)

So when the ball's lowest y point is above the y point of the plane it's ok (The control plane with the white graphics)

But when the ball's lowest y point is equal to or below the plane then the culling seems to mess up.


I have tried various combinations of SetObjectCullMode() and SetObjectDepthWrite() without success

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 22nd Oct 2018 09:58
Its not a bug....its just a case of the two objects (Control and Ball) both being transparent.

If two objects are transparent in agk then, AppGameKit works out how far the object is from the camera by calculating the distance to the object positions. The object furthest away gets drawn first. IF two transparent objects both have the exact same position (as your control and ball do after the click) then the first item loaded is rendered first as the distances from the camera are the exactly the same so they are not depth sorted.

AGK does not depth sort every single triangle in the meshes for you as that would be very slow.

Do you want the controls to appear on the floor or on front of the ball?


blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Oct 2018 11:18
Controls need to be on the floor.
The distance from the camera to the center of the control is further away than the distance from the camera to the center of the ball.
How does it calculate distance?
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 22nd Oct 2018 12:41 Edited at: 22nd Oct 2018 12:42
Quote: "The distance from the camera to the center of the control is further away than the distance from the camera to the center of the ball."


After the mouse click both the control and the ball are both located at 0,-6,-50. Just print out the GetObjectX,Y,Z and you will see that.

The objects position is used to calculate distance so in this case they are both exactly the same. Clearly your Controls obj file has a negative Y offset. If you get rid of that offset you wouldnt be having this issue as it would be at something like 0,-12,-50 and would appear on the floor and the ball would appear in front of it.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Oct 2018 22:59
Ah Got it! Thank you very much. I have learned a lot

Login to post a reply

Server time is: 2024-03-28 18:16:30
Your offset time is: 2024-03-28 18:16:30