Z-order Question

Blitz3D Forums/Blitz3D Programming/Z-order Question

Trek(Posted 2015) [#1]
Well, I believe it’s a z-order problem (like when two mesh planes are close together, but far away from the camera so they start to flicker). I have a procedural generated adventure game where the world is divided into areas. Each area is 400x400 blitz units. I take the X and Y position of the player, divide by 400 to determine which area to generate, then delete all previously generated areas.
I am finding out that the farther away the player gets from blitz center (global entity coordinates of 0, 0), he starts to flicker. He can be wearing a helmet (parented to the “head bone”), and it will flicker between being able to see the helmet on top of the character like intended, to seeing the player’s head drawn on top of the helmet. He also jitters, but this may be part of the same problem. Is this a problem with my computer/code, or does this happen to blitz when you get that far away from center (such as coordinates 36000, 18000)?
PS I have a picture if needed, but I don't know how to post it.


RemiD(Posted 2015) [#2]
From my past experiments, it can be because of a surface with alpha (pixels/material/brush) over another surface but with a too near distance, or because of a camerarange with a too great difference between the min value and the max value, or because of duplicated tris which have the exact same size and normal and position (by mistake) in the mesh.

About the camerarange, see : http://www.blitzbasic.com/Community/posts.php?topic=98868

About surfaces with alpha (pixels/material/brush) maybe try to search : https://www.google.fr/?gws_rd=ssl#q=alpha+z+ordering+site:blitzbasic.com


Zethrax(Posted 2015) [#3]
If you get tens of thousands of world units away from the world center then floating point precision issues start to come into play and may cause z-fighting and other problems. It's best to try to stay within a few thousand world units of world center. If you have a large world then you might need to center the world occasionally (how you do that is going to depend on the nature of your project).


RemiD(Posted 2015) [#4]
Indeed there can also be weird problems when an entity is too far from the origin (0,0,0)


Rroff(Posted 2015) [#5]
I've noticed anything over 32768 units from the world origin (0,0,0) will progressively have more issues with jitter and ordering, etc. and ocer 65536 much more severe issues due to as mentioned above rounding precision issues.

Never tested it extensively for performance impact or other issues but I was offsetting the world so the player position was 0,0,0 for rendering and some movement updates and then moving it back rather than the more traditional work around of locking the player at 0,0,0 and moving everything around them which I dislike.


RemiD(Posted 2015) [#6]
I have done some tests about this in the past, my approach was to have a world coordinate (between 0 and 1000 world units) and a zone coordinate (between 0 and 100 blitz3d units).
The player was able to turn move freely in the zone (between 0,0,0 and 100,0,100) and when he reached a border of the zone, the world coordinate was updated and all zones where moved so that the active zone (where the player is) had its origin at 0,0,0
The challenge was to load then build, and save then destroy, the properties and entities inside each zone without slowdown...


Trek(Posted 2015) [#7]
Ugh, I was afraid of it simply being too far away from center...Off to recode my world generator. Thanks for the quick info guys!