
A JavaScript Port of the 1986 Amiga Juggler Raytracer - guru_meditation
http://home.comcast.net/~erniew/cghist/juggler_rt.html
======
guru_meditation
For some context, this was the first raytracer that ran on any personal
computer.

Some more context here:
[http://home.comcast.net/~erniew/juggler.html](http://home.comcast.net/~erniew/juggler.html)

and a bit more here:
[http://www.pouet.net/prod.php?which=10776](http://www.pouet.net/prod.php?which=10776)

The source code is refreshingly simple and easy to read: both the original C
code and the ported JS code.

~~~
azakai
I trust you are accurate because of your username.

~~~
vardump
You do? I think I see blinking red bars around his username...

------
orionblastar
The Juggler showed off the Amiga graphic abilities. It is what helped sell
some of the 1986 and 1987 Amiga computers.

Before that it was a bouncing checkered beach ball. Other computers did their
own bouncing ball, but the Amiga could multitask and had multiple bouncing
beach balls, each program running on its own. I think you could have multiple
jugglers as well.

~~~
vardump
A few years later 1992 "State of the Art", Spaceballs demo shows off Amiga 500
pretty well. That whole thing fits on 880 kB floppy and it's rendered
realtime.

[https://www.youtube.com/watch?v=89wq5EoXy-0](https://www.youtube.com/watch?v=89wq5EoXy-0)

A year later same group released "9 Fingers", also running on Amiga 500.

[https://www.youtube.com/watch?v=PPoYzwib7JQ](https://www.youtube.com/watch?v=PPoYzwib7JQ)

~~~
aidenn0
Did those run on a stock Amiga 500?

~~~
guru_meditation
Yes, this ran on an 1987 Amiga 500 with the Commodore A501[1] 512K RAM
expansion. This means:

    
    
      * 1MB RAM
      * 256K ROM
      * 7.16 MHz (yes, that's 0.007 GHz :)) Motorola 68000
    

plus a whole lot of custom chips [2]

There were different ways of expanding the Amiga RAM and the demo became so
popular it was reverse engineered by a popular cracking group Skid Row[3,4].,
patched and re-distributed

[1] [http://amiga.resource.cx/exp/a501](http://amiga.resource.cx/exp/a501)

[2]
[http://en.wikipedia.org/wiki/Amiga_500](http://en.wikipedia.org/wiki/Amiga_500)

[3]
[http://www.exotica.org.uk/wiki/Skid_Row_%28old%29](http://www.exotica.org.uk/wiki/Skid_Row_%28old%29)

[4]
[https://www.youtube.com/watch?v=uqfcrViBGn8](https://www.youtube.com/watch?v=uqfcrViBGn8)

~~~
aidenn0
This says 50fps, so I assume it was the 7.09MHz version...

~~~
guru_meditation
Correct, just like with the Commodore 64, the CPU clock actually differed
based on the graphics hardware output, which was back in the day adjusted for
the household CRT TV sets.

The master clock crystal oscillator on the motherboard was set to be 2 clock
cycles per pixel and other chips clocks were derived from that.

Hence the CPU was set to 1/4th of master clock, so the European PAL[1]
machines (a 50fps TV standard) actually ran slightly slower than the American
NTSC[2] machines (a 60fps TV standard with a smaller vertical resolution).

[1] [http://en.wikipedia.org/wiki/PAL](http://en.wikipedia.org/wiki/PAL)

[2] [http://en.wikipedia.org/wiki/NTSC](http://en.wikipedia.org/wiki/NTSC)

------
WhitneyLand
It's pretty cool to click on the link and be able to run a ray tracer on your
phone. Maybe more exciting because you get the drama of it taking a couple
seconds to render.

Ironic that compute has come so far yet real time movie quality graphics are
still only a dream.

We have GPU based ray tracing, and if you stuff a 44u rack full of them it
becomes more tolerable, but still nothing approaching 24fps for complex scenes
and effects,

This has a lot to do with the content being more complex compared to say, what
was done for a movie like Tron. But it's more than that. How many other
problem domains could eat 5 orders of magnitude of performance increases and
easily make use of it for everyday consumer applications? That still might not
even be enough to get us out of the uncanny valley.

------
peterashford
Heh. I thought it was going to be animated.

------
szimmer1
This has nothing to do with the Amiga, but shameless plug for a cool in-
browser ray-tracer we made for a school project
[http://camargo.github.io/tracejs/#/](http://camargo.github.io/tracejs/#/)

Rendering times become exponentially slower with more objects in the scene
(100% native Javascript, hence 0 hardware acceleration) but it's fun to play
with if you're in the mood!

~~~
david-given
If you want the other extreme, these days you can do real-time raytracing
entirely in an OpenGL shader:

[https://www.shadertoy.com/view/XdfXDB](https://www.shadertoy.com/view/XdfXDB)

(There's no geometry in that scene --- the shader is run for each pixel
independently!)

------
TazeTSchnitzel
It's interesting that they chose to port the source to JS by hand, rather than
compiling the C to asm.js with emscripten. It'd probably have been easier, and
the resulting code faster, if this approach was taken.

~~~
mrspeaker
They should have just taken a still of the original and pasted it as a png.
Would have been easier, and requires less CPU. But I don't think that was the
point of the whole exercise.

------
wiso
Multithreaded ray tracing C# version:
[https://github.com/wieslawsoltes/rt](https://github.com/wieslawsoltes/rt)

------
indypb
Project Amiga Juggler:
[http://meatfighter.com/juggler/](http://meatfighter.com/juggler/)

Step by step tutorial in Java.

------
jheriko
i'm surprised to see so much badness in the original code.

it kind of takes away from the rose tinted view i have of the past being
dominated by awesome programmers who got the most out of the hardware...

~~~
chipsy
For what it was aiming to do, I think it makes a lot of sense, albeit it might
be a little bit too factored for the data(e.g. passing in the whole world to
functions called only once).

You can kind of tell that this is more "proof of concept" than "artistic
triumph" because the scene itself is relatively bland stuff, with its most
impressive aspect today being that the juggler actually animates somewhat like
a person. Everything else is just a straightforward demonstration of the
Amiga's compute resources and display capability. Since the output was always
going to be a single prerendered animation, deep optimization probably
wouldn't be worth it.

~~~
jheriko
i mean stuff like the wonky reflection code and checkerboard logic... its a
bit 'special', even for a proof of concept.

its unexpected given the apparent intuition for rendering/geometry/maths from
the simple, yet clever animation used.

------
donatj
I wish he hadn't made so many modifications.

