A 1997 DOS software-rendering demo by Ben Houston. It renders a rotating 3D mask with texture mapping, Phong-style lighting, bump mapping, and reflective shading in VGA Mode 13h on pre-GPU hardware.
For modern context, read Rendering Real-Time 3D Before GPUs. The post explains how the renderer works, including the fixed-point math, palette quantization, triangle rasterization, lighting maps, reflection mapping, and bump mapping techniques used in this demo.
Install DOSBox-X:
brew install dosbox-xRun the demo:
dosbox-x -fastlaunch -nopromptfolder -defaultconf \
-c "mount c /Users/username/3DMaskDemo1997/bin" \
-c "c:" \
-c "PTB_DEMO.EXE"If you cloned this repository somewhere else, replace the path in the mount c command with the path to this repository's bin directory.
- Ben Houston [ plash / AZuRe ]
- Friday, March 14, 1997
- e-mail:
ben@ben3d.ca
Here are the results of my first attempt at Phong texture bump mapping. I'm moving from BC4/TASM to Watcom, and my next engine won't be so limited as this thing. Although this engine is fairly limited, it is fairly fast because of the fixed-point math, fast polygon tracer, and dirty rectangle animation. You will find a lot of weird things in this source because I started to run out of space in the data segment, and I had to reuse portions of it. Let me tell you that Phong texture bump mapping is not meant to be done under 540 KB using a small memory model in 16-bit real mode.
To learn about some of the techniques used in this source, it would be best to read other people's work that is more suited to learning from. The texture mappers used are all based on a doc called FATMAP.TXT written by MRI. The fixed-point rotation is based on Rex Deathstar's EMPHONG4 archive. Rex also has an example of how to environment map, and it is the technique on which my source is based. The bump mapping method is my own, as well as the Phong map calculations. The Phong palette calculations are not totally correct but fairly close. The technique used to bump map causes bumps to appear larger when the bump is perpendicular to the viewer than when the bump is facing the viewer head-on. The distortion has to do with the non-uniform Phong map. Most of the code was written when I had way too much coffee, so please ignore that the libraries are called "nothing comes close" (NCC) ;).
Enjoy the code. If you do use it, give credit or you are plagiarizing (taking credit for work that's not your own). I'm always happy to get mail discussing techniques or whatever. By the way, I am looking for one talented musician to help with a major big demo.
PS. I've added reflective metal shading and plastic Phong shading just for the fun of it. The inner loops of almost all the triangle drawers are totally shit! I'm moving to Watcom, so there is no point optimizing real-mode code. Real mode sucks shit, and I'm done with it!!!
PPS. I want greets too!
+-- readme.txt this file
+-- bin archive containing working demo
| +-- ptb_demo.exe the DOS16 x86 demo executable (small eh?)
| +-- azure.raw background (320x200)
| +-- bumpmap.raw star heightmap (256x256)
| +-- texture.raw star texture (256x256 32clr)
| +-- texture.pal texture palette (32 clrs used)
| +-- refmap.raw metal reflection map (grayscale)
| +-- mask.vtx vertices for object
| +-- mask.nrm vertex normals for object
| +-- mask.fct facet indices for object
| +-- mask.txr vertex texture coords for object
+-- src archive containing all source code :)
+-- ptb_demo.cpp main C++ source for demo
+-- ncctypes.h types header for NCC library
+-- nccgraph.* graphics functions
+-- ncctri.* a lot of triangle drawers
+-- ncccolor.* palette quantization
+-- nccmisc.* just simple crap
+-- azr_ptb.ide project file for Borland C++ 4.0
- Mundane - in no particular order.
- Asch - that girl has driven me insane.
- Olivier - am I bothering you?
- xyz - try to use some sentence structure :).
- TimJ/Vertigo - a guy who knows his Phong.
- Phantasm - how goes the engine?
- Cyclone - object orientation overload.