|
What the heck is rayperl? As the name says its a simple
ray tracer written in Perl.
Why write a ray tracer in perl? I know ray tracers, I don't
know Perl. That and I needed a little project to keep me on my
toes.
What kind of nifty things does it do? It ray traces spheres,
thats it, no other primitives. It antialiases by sampling each
pixel 16 times using an N-Rooks kernel which is generated at run
time. There's diffuse lighting, shadows, multiple colored
lighting, and reflections. Thats about it. Adding more stuff
is pretty trivial, its written to be extensible (that doesn't mean I'm
going to do it though :) )
How long did it take to write ? A few days on and off, I'd say
about 15 hours overall.
How fast is it ? Its god awful slow, but I was surprised to find
that it wasn't as slow as one would expect. For each of the
scenes, the time it took to render is shown below.
What now ? I was somewhat inspired by this project. I
want to see how many different languages and platforms we can write ray
tracers in. In particular I'm interested in a post script ray
tracer, a ray tracer for the Palm (should be trivial since you can do it
C).
Where's the source ? Gimme source ! You can download the
source right here. rayperl.txt.
A couple things. All the scenes are defined as functions. To
render a scene, just uncomment the function call (at the bottom of the
file). Also the resolution, samples / pixel, the camera's
location, the camera's field of view are all set as variables near the
bottom. It always outputs to a file called rayperl.ppm. If
you need a PPM viewer and are running Windows, try this one, ifranview.
It also has the ability to output to an interim file, which is
rayperl_interim.ppm. WARNING: Do not run this under Windows
with ActivePerl.
I found that it writes out funky data, and so the image might look all
gibbered. I have run it just fine on two different Linux boxes and
a Solaris machine.
I have a small gallery of images that I have generated with rayperl.
Comments are most welcome.
|