PDA

View Full Version : Drawing 2D interface before the scene



silikone
11-15-2017, 06:59 AM
Is it at all practical to draw non-transparent 2D interface objects in the framebuffer before the 3D scene and eventually any transparent 2D object in order to reduce overdraw? Would a simple Z buffer test suffice, or does this risk creating problems?

GClements
11-15-2017, 03:17 PM
Is it at all practical to draw non-transparent 2D interface objects in the framebuffer before the 3D scene and eventually any transparent 2D object in order to reduce overdraw? Would a simple Z buffer test suffice, or does this risk creating problems?
That would work.

A depth test will suffice, but you need to take a bit of care to ensure that 3D primitives which touch the near plane don't appear in front of the 2D interface. Probably the simplest solution is to use glDepthRange() to ensure that the 2D and 3D elements don't overlap in depth.