[SOLVED] Draw order of sprites with a perspective camera

Hello!

I can reproduce this issue with a simple defold perspective camera, as well as with the rendercam library.
Just switch between the ‘/main/perspective.render’ and ‘/rendercam/rendercam.render’

Sample project: github

The red sprite can be moved with the arrow keys and as soon as it crosses the middle/green line the sprite disappears. it seems like this only occurs when looking at an angle on the objects.

Any ideas how this problem could be solved?

Thanks in advance

I haven’t tested your project but isn’t this a problem with the near and far plane and the sprite or sections of it being outside of the planes?

Both sprites are inside the configured near Z/far Z values

Without any knowledge of the system here, It looks like that the distance between the camera and the center of a sprite is used to determine a draw order.

This might be a problem with a combination of very small/large sprites (32x32 and 1024x1024 in this case) or if rotations are used a lot.

So while the red sprite should be on top of the big one, it gets rendered after (and is completely overdrawn in this case)

Well, that happens when there is no prior knowledge of OpenGL.
Found a topic that exactly desrcibes the same problem - but with a solution :slight_smile:


(and transparency also works)

Marked as solved.

Excellent!