Thursday, December 25, 2014

Blast from the past: Turbo Pascal raytracer

Paweł’s recent post reminded me of a veeeeeery old raytracer I wrote in years 1985/89. (Yes, young ones, we had computers then!)

Header states:

1985-07-10:
  Computer: VAX-11/750
  Language: Pascal V2
  Graphics: VT100

1988-02-03:
  Computer: IBM-PC
  Language: Turbo Pascal 4.0
  Graphics: EGA 640 x 350 x 16

1989-07-03:
  Computer: IBM-PC/AT
  Language: Turbo Pascal 5.0
  Graphics: VGA 800 x 600 x 256

Quite a blast from the past – the 800 x 600 in 256 colors (out of a great palette of 262144 colors!) was more or less the greatest graphic card which you could get for PC at that time. And the first version was running on a VT100 terminal with an additional graphics board. Sadly, I don’t have that code anymore :(.

Program could draw four 3D bodies: a half space (limited with a plane), a cone, a cylinder, and a sphere. You could then use union, intersection, and difference on those bodies, then combine results in the same way (ad infinitum) and create quite a complicated picture. It was also possible to set a color for each body and to specify how much light it reflects.

Input file was stored in a “readable” text file, like this:

-10000 0 0
50 100 100
50 100 -100
50 -100 100
1 1 590 590
10
1 K 10 75 G 100  60   0 20
2 K 10 75 G 100  60 -45 20
3 K 10 75 G 100  15  45 20
4 K 10 75 G 100  15   0 20
5 K 10 75 G 100 -30  45 20
6 K 10 75 G 100 -30 -45 20
7 K 10 75 G 100 -75   0 20
-1
1 +  2  10
3 +  4  11
5 +  6  12
10 +  7  20
11 + 12  21
20 + 21   0
-1
-1
0 -100 -100 100 0

Output was generated on the screen and also stored in a file, which was not in any image format, just a binary dump (yay, old times!). I remember that the program was so slow that you could watch it paint pixel by pixel :)

I also have three GIF files stored on my old CDs. I don’t remember if they are screen shots (yes, there were programs which allowed you to do that in DOS) or conversions of binary dump files.

The dots represent the logo of a scientific research facility where I spent lots of time as a student.

IJS

IJS1

SENCE

You can download the program here. Ray.pas is the raytracer while Show.pas reads .out file and shows it on screen. There are compiled programs inside the archive but as they are 16-bit DOS versions and they write directly to graphics memory, you cannot run them on Windows.

If somebody makes them run again on Windows with Delphi, please let me know :)

2 comments:

  1. My bad, could not run it in DOSBOX. It only makes the screen reddish http://i59.tinypic.com/1qsgtx.png
    What DOSBOX params are needed to run this?
    Thank you.

    ReplyDelete
    Replies
    1. I have absolutely no idea. Last time I run it was some 20 years ago :)

      Delete