8. Summer at Xerox in 24-bit Color
After graduating from MIT with my degree in math, I returned to Toronto and another summer job at XRCC. Back to the two-hour commute. Each way. But hey, I was young and eager and it gave me time to read. And back for another take on rendering images of molecules, this time in color.
It was once again programming on VAX/VMS in FORTRAN 77, which felt like quite a step backwards from Lisp Machines. However the lab had received their new color frame buffer, a Raster Technologies Model One/25. It was a “full-color” system with 24 bit color, with a 512x512 resolution 19" monitor, and I was excited to put it through its paces.
Over the course of the summer, as I was learning how to program the new frame buffer, I discovered and purchased a new and very useful book on computer graphics: Procedural Elements for Computer Graphics by David F. Rogers. It contained the outline of a raytracing algorithm, and I was determined to implement that to render my images of molecules.
The raytracing algorithm was first describe in a 1980 paper written by Turner Whitted of Bell Labs. It rendered a 3D scene by firing rays from the camera for each pixel of the screen and finding what object in the scene the ray intersected. More rays could then be fired from the point of intersection to compute shadows, reflection, and refractions for transparent objects.
The calculations were numerically intensive, taking a lot of computer time, but results were highly photorealistic for the day. Furthermore, raytracing was particularly well-suited to rendering scenes made of spheres, and since chemists visualized molecules as interconnected spheres, it was a natural fit.
I did implement a z-buffer renderer for faster interaction, rendering molecules as polygonal spheres in minutes rather than hours for the raytracing. In fact, I would often start a full-screen raytracing when leaving work, and see the result the following morning. Today, modern GPU’s do very elaborate raytracing of complex scenes in real time.
One final note, on how we made hardcopies of the images. The monitor came with a plastic hood which could be placed over the screen. It had camera attachments for 35mm SLR’s and Polaroid cameras. So we literally took photographs of the screen.
Design & Code
I decided to implement colors as simple vectors (one-dimensional arrays), rather than classes, as I did for points.
This code is from the lessons I prepared a while back, and I wanted to show how arrays worked in Common Lisp, and how you could map over them.
The sharp-eyed among you may have noticed the rainbow-related code at the bottom of the listing. Yes, I implemented that specifically for today’s image. Figured since I mentioned color in the title, it was appropriate.