Retro rendering

Posted by Martin Vilcans on 4 October 2005

I recently had a look at the latest version of POV-Ray (the open source raytracer). I first used it back in the early 90's, and years later I created some scenes and rendered them on my Pentium 166. Now, even more years have passed, and as I mentioned, I had a look at it again. Some cool new features have been added. One of them is the trace command which I used to create this picture. It may not look like much, and it isn't, but how I made it may be of interest if you're a geek like me.

POV-Ray scenes are described in a scene description language. Many modellers can export to POV format, but POV itself does not have a graphical editor and it is quite possible to create scenes by just using a text editor. The POV language has some basic scripting features, so it is possible to write code that generates the scene. For instance, you can make a loop that creates several objects and places them in the scene based on some mathematical formula. So, as I said, the trace command is a new command in the POV language. What it does is to cast a ray with a specific direction from a point in the scene. It returns the point where the ray hits an object. This makes it possible to write a simple ray-tracer in the POV-Ray scene description language itself! I just had to try that...

Now I get a bit technical...

So I implemented a nested loop that iterates in a virtual camera's x and y coordinates, and used trace to find the point where the camera ray hits an object. For an object, I used the Utah teapot, which is included with POV-Ray, and a ground plane. If the result of the trace command hits something, I use a standard lighting calculation with one light source to get the intensity of the pixel. I also add shadows by trying to trace a ray to the light source from the point where the camera ray hit the object. If that ray hits an object, the point is in shadow.

To give POV-Ray something to render, I had to add real objects to the scene. At first I just added a little box that acted as a pixel for each traced camera ray. The color of the box was based on the result of the lighting calculations. I lined up the boxes so that they would display the image.

All of this was a bit pointless, so I came to think of the old dot matrix printers of the 80's. These printed with black ink onto tractor fed paper. It was possible to print graphics, but the resolution was low, and it was only possible to write in one intensity (although there were tricks around that). So I decided to try to simulate a dot-matrix printout in POV-Ray, so the result would look like I had taken a photo of a printout of a simple raytracing of the Utah teapot! This was rather simple. Instead of rendering a little box for every camera ray, I used tiny discs (simulating a dot from the dot-matrix printer) that were added to the scene or not depending on the intensity from the lighting calculations and an ordered dither matrix. Just behind the discs, I placed a plane with a paper-like texture.

The result is not that convincing, but with more work I guess it could be made to look very good. Yeah, all of this is still rather pointless, but it was fun!

Previous: SI
Next: PlayStation Portable

Comments disabled on this post.