New Project – Generation 5 Engine
I’m going to put out a few details about the project I’m going to work on next now that I’m putting my ray tracer away. In writing this sort of stuff up I’m hoping that I’ll also egg myself on into making and writing about regular progress on the project.
The new project is called Generation 5 Engine, after the 5th generation video game consoles. This is the terminology that most people have adopted for the 32-bit/64-bit era of video game consoles.
The era stretches from around 1994 through 1999. The most notable consoles from the generation are the Sony PlayStation, Nintendo 64, and Sega Saturn. This was the first point where video game consoles could handle 3D graphics, texture mapping, and gouraud shading at playable framerates.
We can still play a lot of these games through emulation but something is lost when you do. As several people in the gaming community have pointed out recently, there was a certain nostalgic charm to the peculiarities of early 3D console rendering – peculiarities that are difficult to replicate in modern GPUs because they automatically introduce a level of precision well beyond what the old consoles could accomplish.
I spent a lot of the late 90s in high school computer science class trying to figure out how to write my own 3D rendering engine. I and two friends would compete to see who could churn out the best rendering code, but none of us really ever manged to get something that could be used for a game. We didn’t understand a lot of the math required to make it work – like how to create perspective-correct texture mapping, or how to use transformation matrices.
We were converting coordinates to polar, incrementing the angle, and converting back – it was completely ass-backwards but we didn’t know any better.
I’ve decided to revisit that era by writing that software renderer we just didn’t have the mathematical background to write back then.
The Generation 5 Engine is actually going to be 2 engines: P-Engine (intended to mimic the PlayStation) and N-Engine (intended to mimic the Nintendo 64). I chose the two of them because the 3DO and Jaguar were both very similar to the PlayStation (but worse) and the difficulty in creating assets for the Saturn’s affine quadrilateral-based rendering is just more trouble than it’s worth.
- 320×240 – 640×480 resolutions (Allow any, but must aim for these)
- Lower accuracy color modes (Allow 24-bit, but also support 15-bit, 18-bit, and 21-bit – more on this at a later time)
- Software-based transformation and lighting (hardware T&L wasn’t introduced until the GeForce GPU in 1999)
- Immediate mode drawing
- Fixed-point math for color blending
- Affine texture mapping
- Nearest neighbor sampling
- Painter’s algorithm (no z-buffer)
- Screen-space rasterization (triangles rasterized using vertices transformed to integer screen coordinates)
- GL-like state machine
- Three-point bilinear filtering
- Perspective correct texture mapping
- Edge anti-aliasing
- Floating point vertex manipulation
- Allow unclamped vertex colors (for lights > 1.0)
- Implement more OpenGL-like color blending (i.e. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA))
- Provide management tools for P-Engine to cache polygons and sort by Z
Progress So Far
Most of my progress is just in planning. I did manage this:
I’ve switched from SDL 1.2 to 2.0 and figured out how to make a screen buffer and blit that to the window. It’s not much but it’s a necessary start.