Render 3d objects in layers, like sprites?

I know this may sound stupid, but is it possible?
Imagine a game like Asteroids, top down view, but with 3D objects instead of sprites.
The asteroids fly across the screen in all directions but they do not interfere with each other (they aren’t supposed to).

Now in 2d, everything is just rendered in some object order, so the “later” asteroid wins and is displayed flying above the other.

In 3d, the Z buffer decides per pixel, so two asteroids would just pass through each other which looks very weird (I tried it :wink:

So i guess the question boils down to if one can somehow draw 3d objects in layers, like, clearing the Z buffer between renders or not using it at all or something? I tried to fiddle with the layers and culling groups in the scene but to no avail. Is it possible to set it all up that way? Also this would be about hundred or more objects on screen, so there aren’t enough groups to put each object in an individual one. Is there a reasonable approach to the problem? (Putting everything at actual different distances would cause all kinds of perspective issues, so I am looking for a solution during rendering).

You could try something like this: http://stackoverflow.com/questions/3763475/how-to-disable-the-depth-buffer

In Paradox it would be done like so:

var stencilStateDesc = new DepthStencilStateDescription();
stencilStateDesc.DepthBufferEnable = true; /* Enable the depth buffer */
stencilStateDesc.DepthBufferWriteEnable = true; /* When drawing to the 
screen, write to the depth buffer */

GraphicsDevice.SetDepthStencilState(DepthStencilState.New(GraphicsDevice, stencilStateDesc));

Thanks a lot, I’ll be looking into that :slight_smile: