The Z-Fighting Problem

Z-fighting is a graphical issue which occurs when a game tries to draw two layers at the same depth.

The results vary — sometimes one layer can appear to poke through another or they will flicker back and forth as they “fight” over which one should be drawn in front and which one in back.

Z-fighting demonstration from https://en.wikipedia.org/wiki/Z-fighting

Z-fighting demonstration from Wikipedia article

From the Teapot to the Milky Way

If you’re a gamer, you’ve probably seen z-fighting before. But this issue mostly affects games which are working with very large camera distances. For example, open-world games may try to draw mountains and clouds in the distance, but because they both are designated as “very far away,” they fight over which is drawn in front.

Universe Sandbox ² handles camera distances on a scale even larger than this. The camera may be a few meters away from a teapot, and lightyears away from a galaxy. And somewhere in between there may be a whole bunch of planets. The issue here would be distinguishing which planet should be drawn in front when, relatively, they’re much closer to each other than they are to either the teapot or the galaxy.

Log-Z

This is where logarithmic z-buffering comes in. In non-technical terms, log-z is a programming technique which opens up more “options” at which layers can be drawn. For example, instead of all planets being grouped together at depth 5, they can be drawn at 5 as well as 5.1 and 5.2 and so on. And with their own personal space, they no longer fight!

Here’s a great interactive example of logarithmic versus standard z-buffering: http://threejs.org/examples/webgl_camera_logarithmicdepthbuffer.html

Using this technique in Universe Sandbox ² has been a long time coming — its implementation had been held up by a bug in Unity (the engine we use for development), which has now been fixed.

It won’t be an obvious change for users, but now that Georg has added it in, we’re ready to move forward with a whole bunch of other visual improvements as well, not to mention the small performance increase we expect.

Thanks, Georg! Now there’ll be no more of this:

Pluto-Z-Fighting

You can buy Universe Sandbox ² now for instant access to the alpha via our website: universesandbox.com/2 

Universe Sandbox ² will be on Steam Early Access later this summer.