Time Warp - Voyage into 3D

Here is the second part of my Time Warp series of posts, detailing past projects of mine that I feel are worth sharing or at least archiving for my own sake. In this entry, I've compiled a list of significant 3D engine prototypes that I'd once created, most of which were developed circa 2005 onwards. Titles such as Wolfenstein 3D, Rise of the Triad and Blake Stone 3D were all childhood favourites of mine, and as such inspired many of my early builds.

While we're back in the era of Mode 13h, I'd like to mention a book that I recommend for anyone interested in nineties development techniques: Tricks of the Game-Programming Gurus, by Andre Lamothe, John Ratcliff and Denise Tyler. Although outdated, many of its low level concepts are still applicable today as are its timeless mathematics. If only we all wrote code that could run in real-time on a 486 nowadays...




Below are screenshots from my very first legitimate attempt at writing a rasterised 3D engine using Game Maker. This was long before I understood perspective projection and when support for texture mapping didn't actually exist as part of my code. What you see are regular polygons rendered using an affine mapping function built-in to Game Maker. Interestingly enough, it appears that I had part of the math working, at least along the horizontal axis. The flaw lies in the calculation of vertical wall height, having been based on scale and distance just like the sprites.




The Blake Stone style screenshot below depicts a later albeit still early version, I believe I was playing around with rotational sprites! At this point I had conquered 3D projection and had implemented my own texturing routines. The Quake style screenshot is an even later build with support for walls of varying height, vertical camera movement and roll. I should mention that all of my engines use a Z-up coordinate system to this day. Probably from writing these psudo-3D engines around what were actually flat 2D levels, giving the illusion of a 3rd dimension as height.




I continued to experiment, eventually creating a version that allowed for six degrees of freedom. Although the perspective math seems so natural now, back then it took quite a while for me to wrap my head around the projection of 3D space onto a 2D plane. Arbitrary polygons, sprites or billboards and mouse look were all fully supported and as I remember, achieving what I had in this build was a rite of passage for me as a programmer. Clearly the engine was extremely primitive, there was no backface culling or hidden surface removal and any form of lighting model was left in the dark...




Rasterisation aside, I had also written a few ray casters (not to be confused with ray tracing). Having also witnessed the limited number of 3D titles available on mobile devices back then, I wanted to challenge myself with the task of writing a ray caster that would run in real-time on the limited hardware. The renderer was written in Java for the J2ME platform, below shows the first level of Wolfenstein 3-D running in the Sun Wireless Toolkit Emulator. I was getting around 30fps on my phone at the time, a Sony Ericsson z750i.




Eventually I did end up writing a hybrid J2ME engine, that worked more like a rasteriser internally. It supported higher quality texturing at double the frame rate and walls of any angle provided that they were perpendicular to the floor. My original intention was to produce a game from it, however lack of knowledge and time halted progress. Below shows my most recent 3D engine, using WebGL and written entirely in JavaScript. This particular build has its own complete math library, a scene graph, spatial partitioning, frustum culling and a custom shader and material system.



Comments

Popular Posts