There will be opportunities can have depth-order ?

Previous topic - Next topic

equinox

There will be opportunities can have X, Y, Z, for a just ordering of depth of objects (depth-order) in GLBasic-2D function ?

Tags: zorder, z-order, z order

Ian Price

Here is one simple method of z-ordering sprites - basically it relies on you drawing the sprites in order based on their Y position and their height.

The graphics come from Jack The Nipper

Attachment contains .EX and source.

[attachment deleted by admin]
I came. I saw. I played.

equinox

Tnk1000.

This code was what I was looking.

Hemlos

My message here is not directly related to the Q&A, however it is similiar.

Ian, i have a 3d particle engine which is in dire need of z ordering.

MY question is, do you have any simple solution for handling the Z depth using 3d decimal coordinate system which might have thousands of sprite objects?
Bing ChatGpt is pretty smart :O

Ian Price

Hemlos: Short and simple answer - no. I'm strictly 2D only. The code above will happily deal with hundreds of sprites, but probably not thousands - but I've not tried TBH.

I don't know if it could be incorporated into 3D (I see no reason why not), but isn't the point of 3D that you don't need to depth sort? Doesn't the graphics card do this for you?
I came. I saw. I played.

Moru

Billboards don't sort sadly, you need to place them in z-order yourself. (From the camera viewpoint no less...)

Kitty Hello

I used the SORTARRAY function, which makes the drawing a lot faster and also would work for floating point z values. See attached file.

[attachment deleted by admin]

Hemlos

Quote from: Kitty Hello on 2010-Mar-01
I used the SORTARRAY function, which makes the drawing a lot faster and also would work for floating point z values. See attached file.

Its not the speed which is an issue, its the ordering itself making ugly graphics overlapping.
Ive tried adding a sortarray to reorder all the particles each frame.....this drops this speed(FPS) by roughly 25-50% because of an additional sorting loop.
The result is roughly 500 stablized particles.
This is not good because the main stream c++ particle libs i was testing, run 5k-15k # of particles, at the same FPS speeds without any asthetic z ordering issues.


Bing ChatGpt is pretty smart :O

Kitty Hello

try using sortarray on the existing array. If it was sorted once, the SORTARRAY function returns very fast.