So, that System Shock code that was open-sourced by Nightdive Studios a few months back? Despite being done for “historical/preservation purposes” with an “updated version” slated for later, it hasn’t stopped programmer Chad Cuddigan from not only tinkering with the code, but transforming it into a fork called Shockolate that is both playable and cross-platform.
At the moment, Shockolate only works on Linux and Mac and even though it has a long way to go, it already has limited support for modding.
But you don’t have to play it to enjoy the work that Cuddigan’s doing — his Twitter is a treasure trove of interesting discoveries.
It’s easy to forget that System Shock, which features a first-person, 3D environment, came out a year before hardware acceleration was widely available, so all the graphics relied on software rendering techniques.
With the exception of transparency in deferred shading scenarios, modern developers don’t have to worry too much about the order in which pixels are rendered to screen, thanks to something called a “Z buffer”.
Basically, either before or during the main rendering pass, the depth of each pixel (its distance from the camera) is written to the Z buffer.
This buffer can then be used to determine which pixels are actually visible, so the GPU doesn’t have to waste time on more costly operations, such as lighting, for the ones we can’t see. The buffer can also be reused — say, for post-processing effects like ambient occlusion.
Anyway, I digress. Back in the pre-3D hardware days, it was way too expensive to render things twice to generate a depth buffer. Instead, you relied on some sort of sorting algorithm, as this animation Cuddigan derived from System Shock demonstrates.
And here’s the explanation of what’s happening:
The rendering here does two sorts: one to find the visible tiles in the view cone and sort them back to front, left to right, and then in each tile sorts objects inside them the same way. Drawing loop then can iterate over tiles, drawing the surfaces and then objects.
When you realise all the crazy stuff the Looking Glass folks had to do to make System Shock work, it’s hard not to be impressed.