
Cray - A Clojure Ray Tracer - fogus
http://code.google.com/p/cray/
======
cubedice
They should have called it clay (you know, model stuff, like with clay ;); the
first thing I thought of was <http://www.cray.com> supercomputers. Maybe that
was intentional.

After browsing the source, it seems they are using Java2D primitives,
specifically BufferedImage to do textures and shaders. I wonder if this
project could use JOGL bindings...

EDIT: btw, I meant to say that this looks pretty badass

~~~
cesare
> I wonder if this project could use JOGL bindings...

It wouldn't make much sense. Opengl is for realtime 3d graphics. Here you just
output the final rendered image, which is a bitmap.

~~~
tamas
Right, although there are options to combine the two.

Shader language can be used to write raytracers running entirely on the GPU,
rendering the output to merely two textured triangles streched over the
screen.

However as we are talking about Clojure, not shader languages, an alternative
way would be offloading some of the weight lifting to OpenGL, for example by
calculating visibility using the videocard's z-buffers or creating shadow maps
by rendering the scene from the lights' viewpoint into shadow buffers and
using the results in the raytracer.

------
rbanffy
Looking at it made me curious. Is there any ray tracer that includes the
effects of gravity when tracing the rays? You would have to model in terms of
solids and give materials densities.

It would be a really interesting project.

~~~
grogers
Unless you were planning on ray-tracing a scene near a black hole, what good
would this be?

~~~
rbanffy
This is _hacker_ news. It doesn't need to be good for something as long as
it's cool.

~~~
icey
How would you know it was working?

------
oliveoil
There's a sample image below which it says "First results, 83 lines of code."
Is that the total number of source lines in that version of the raytracer?
Wow! I mean, the sample doesn't look especially beautiful, but 83!! WOW!!

~~~
fsm
Hi there, I wrote this ray tracer. Thanks to everyone for your positive
comments. I don't have a copy of that version any more, but it was 83 lines
from start to finish, including the scene description and dealing with Java to
display the image. No AA or multi-CPU support, but point-light sources and
reflection, and a little general-purpose vector library.

There was probably more code on each line than is typical Lisp style, though.

There are some techniques in the code for getting good performance (as good as
Java at least) for mathematical routines - the JVM is the limiting factor
rather than Clojure.

I hope it helps to show that Clojure is a practical language, since the
concepts in it are going to be important in the near future. Also, if anyone
is impressed by shiny spheres and wants to talk of entrepreneurial things,
email's on the project page. :)

