Software 3D Engine

Final year project at university was a pure software 3D engine written in Modula 2 and then ported to C++.

PDF version of the dissertation can be downloaded by clicking this link

Its features included:

Brief history

The basic engine started out in Modula 2 which was the #1 language at the University at the time. It ran at a decenent 60 FPS framerate in DOS talking direct to the graphics hardware using Mode 13h (320 x 200 + colour palette).
It then got ported to C++, so it could run at a higer resolution with 24 bit colour on Windows using DirectShow.

With more colours and more resolution all the shading / environment mapping started to be added. The results were good, but still suffered from lots of aliasing ( jaggies ). To fix this the engine rendered everything 3 x larger than the display, then sampled it down ( Super Sampling). The results looked good, but involved huge amounts of RAM for time! Also the frame rate dropped from 60 Frames per second to 2 Frames per minute :-)

Screenshots

Animation competition

In effort to kill two birds with one stone, the engine was also used to create an animation for the Reading University Computer Graphics competition ( part of a graphics module).

The competition is based on trying to create a short Pixar style animation, but instead of using an off the shelf package like Maya or 3D-Studio Max you have to write your own graphics engine to generate the animation. The generated frames were saved as .ras (Sun Raster) files on to multiple cd-roms that were then copied on to an SGI Indigio for playing out in realtime.

The team consisted of Nigel Drew, Mike Roberts, Joe Rutledge and myself.

We tried to go for a car driving through a futuristic landscape. Unfortunately I didn't have time to add a camera to the engine, so everything was done by moving objects around. Also at the time it didn't have the ability to manipulte child 3d objects in relation to their parent. So the wheels on the car had to be 'detached' as a separate model and moved / rotated separately to the body of the car :-) There were some incredible magic numbers to tie it all together.

Depsite tough competetion the animation won first place, which was the first time a non-ray tracer based engine had won. I remember at the time a few people couldn't understand how you could generate a 3D model that looks smooth and shiny, but is only made of triangles.

low resolution mpeg of the entire video with audio

With graphics programming you never have bugs, just effects

One scene in the animation featured the car driving through video. The Video Wall was an attempt to replicate a video wall from blade runner. Unfornately I messed up with the bilinear filtering so it was sampling 3 pixels from the video texture and 1 from a skyscaper texture. However it made the video wall look like it was made of blocks of LEDs. Note for some reason the color of these stills is wrong (bug in PaintShopPro's ras file loader).

Drawing in Mode 13h with Modula 2

Who needs to DirectX and OpenGL, when you can talk direct to the hardware, perfectly in sync with the display

PROCEDURE WaitRetrace();
VAR data:BYTE;
VAR h,m,s:CARDINAL;
VAR i:LONGCARD;
BEGIN
   REPEAT
      data:=In(986);
    UNTIL  (3 IN BITSET(data));
     REPEAT
      data:=In(986);
  UNTIL NOT (3 IN BITSET(data));

END WaitRetrace;

PROCEDURE DrawMph();
VAR x,y:CARDINAL;
BEGIN

      FastMove(ADR(mph),ADR(Screen^),64000);

END DrawMph;

PROCEDURE SpanLine(X,Y,N:CARDINAL;Col:BYTE);
VAR i,ypos:CARDINAL;
BEGIN
     ypos:=YLookUp[Y];
     FOR i:=X TO N DO
       Screen^[i+ypos]:=Col;
     END;

END SpanLine;

PROCEDURE PutPixel (X,Y:CARDINAL;Col:BYTE);
BEGIN

      Screen^[X+YLookUp[Y]]:=Col;

END PutPixel;

Modula 2 recording from dosbox -> gif ( a lot smoother on an original 486)