Pix's Demo Coding Page

Jonny looks around, confused, his train of thought disrupted. He collects himself, and stares at the teacher with a steady eye. "I want to code demos," he says, his words becoming stronger and more confidant as he speaks. "I want to write something that will change peoples perception of reality. I want them to walk away from the computer dazed, unsure of their footing and eyesight. I want to write something that will reach out of the screen and grab them, making heartbeats and breathing slow to almost a halt. I want to write something that, when it is finished, they are reluctant to leave, knowing that nothing they experience that day will be quite as real, as insightful, as good. I want to write demos." Silence. The class and the teacher stare at Jonny, stunned. It is the teachers turn to be confused. Jonny blushes, feeling that something more is required. "Either that or I want to be a fireman."

Denthor of Asphyxia

This page is devoted to the art and lore of demo coding! Greetz and dedication to  Future Crew, whose demo 2nd Reality so inspired me that it started me on my journey to learning demo coding.

Over time I will place various stuff about the demo scene and cronicle a few of my code snipplets featuring effects that I’ve coded over the years since I began my journey of discovering the craft of demo coding. It’s been 10 good years since last started on this very fruitful journey! [=

Looking back at these codes and effects now… they doesn’t seem that much of a big deal, considering how CG has progressed over the years to the state of the art we have right now. Besides, coding skills have also progressed and these stuff seem like they are not as tough as it looks. But perhaps, if we take ourselves back in time to late nineties… and view these effects keeping in mind the hardware and platform limitations back then, maybe we can be in better position to appreciate these works… and I must say that for a 17-18 yr old chap that I was back then, learning it was fun, challenging (at times VERY frustrating) and immensely rewarding an experience!

Note: All the effects below date back to the days of ’97 and DO NOT in any way rely on modern graphics APIs such as OpenGL, SDL etc. All the effects run on a 3D rendering engine and custom built API from the ground up using low level hardware access. Effects are coded in pure assembler or C (with inline assembly) on the djgpp platform. All effects are rendered on VGA mode 13h with resolution 320x200 and 256 indexed color mode. For some nostalgia.... we can still run the binaries below on DosBox with CWSDPMI  :)

Just place CWSDPMI.EXE in the same folder as the executable.

Effects

  • 3D Particle Morphing and Motion Blur (bmorph.exe)

This effect features particle morphing with “motion blur” achieved by smooth filtering of the frame buffer.

  • Delaydot Vectors - 3D Lissajous Figure Morph (MOPHDLY7.exe)

This code is optimized to comprise of only 1 erase and 1 plot of the full object per frame and there is no slow full frame blurring as in the previous example. In between the visible points in the particle trail there are actually invisible points. The trailing dots are merely a sparser sampling of the actual point trail.  How the “delaydot” effect is actually achieved is thru clever rotation of the color palette in 256 color mode.

 

  • 3D software z-buffered rendering engine.

 
Wireframe with “burn” effect.


Phong Normal Interpolated Shading


Lambertian Shading

 

 

This effect is a very good lesson on how doing things the straightforward way and applying the 2D transformations will not work. I was baffled quite a bit by it back then but it was really one fascinating thing I learnt from demo coding. To get it right the transformations have to be done the inverse way. And the solution is actually pretty neat since it exploits the fact that rotation matrices are orthonormal and their inverses are their transpose. So it turns out that there is no additional computational cost required for computing the inverse matrices.

  • 2D Image Warping

    This one sort of simulates a radial sinus surface floating on top of the image and just traces the rays from the eye back to the image as the ray passes thru the surface. Its based on the ‘refraction’ principle and the hack is just to use the surface normals and partial derivatives to compute to point where rays hits the image.