Original Post
I'm currently working on a 3D "engine" (Just a demo, really) that imitates the feel of old 16 bit-era graphics. Though all the graphics are 3D models the camera is locked into pointing straight down the "Z" axis at all times, Collision detection only takes place on a 2d plane, and the graphics themselves are broken up into several "layers" (For Parallax Scrolling and other similar effects) The layers effect is what I'm working on now. My current solution is as such: -Start with the back-most layer -Preform culling/scrolling/etc -Render all visible entities on this layer -Clear the depth buffer (not the color) -Repeat with the next layer up till all layers are drawn. (This is all OpenGL, BTW. Not that it really matters.) This should work very nicely in theory (haven't finished implementing it yet) and elegantly prevents any element from one layer interfering with any others. (If you drew them all into the same depth buffer large objects in the background may intersect with objects in the foreground) There is one big problem, though. OVERDRAW! If you have a scene made up of, say, 10 layers, and each ends up drawing in the same section of the screen, you've just overwritten a pixle 9 times to get what should have been done in 1. This becomes even more of an issue when you introduce fragment shaders. Early z-out can help significantly reduce the number of fragment operations you go through. So I'm curious to see if anyone has any suggestions as to how to elegantly be able to render front to back and still keep each layer to it's own "plane." My idea thus far is to try and implement some sort of stencil buffer that masks the areas that have already been drawn as you go back, but I feel like there may be a better way. Thanks for any ideas!