Jump to content

Basic Raytracer 1.0.0

   (1 review)

8 Screenshots

About This File

Raytracer in Basic with a sphere and its shadow, and a plane with a pattern.

Originally written for C64 with Simon's Basic and published 1986 in german magazine c't (issue 1, page 104).
According to the article it took 3 to 4 hours on a c64. It's much faster on a x16, but nevertheless use warp mode.

I changed the following compared to the original code:

  • I added alternative plane pattern formulas in the lines 110 to 220 (4 patterns; just [un]comment the according lines)
  • I added lines 1205, 1206 and 1615 to read the input from data statements instead of user input
  • I changed the graphic commands (screen, line, pset)
  • from line 2000 and on I added the data for the objects 
    • line 2010: the sphere (x, y, z, radius) and the position of the lamp (x, y, z); same for all pictures
    • followed by individual data per picture (5 pictures; just [un]comment the according lines for the others)
      • coordinates of camera (x, y, z) and viewing vector (x, y, z); e.g. lines 2064 and 2065
      • aperture angles (horizontal, vertical); aspect ratio already adapted to X16; e.g. line 2066
    • line 2080: data for the view; same for all pictures; 
      • coordinates of top right corner (x, y)
      • coordinates of bottom left corner (x, y)
      • view window size (width, height)

Press "S" for a quick sketch or "D" for the real stuff ...

On demand I could share more info from the article content.
Tested with R38

Enjoy!


try_it

Yes

try_it_start_prg

sphere.prg
  • Like 3
 Share


User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

desertfish

  

Wowzers! Raytracing still is black magic for me and seeing this done by a basic program of all things. Very cool.  Does take a lot of your patience hence 4 stars instead of 5.

Link to review
×
×
  • Create New...

Important Information

Please review our Terms of Use