News for hackers. Stuff that matters.
Re:Cray - A Clojure Ray Tracer by cubedice on Wednesday October 07, 2009 @09:45AM (#866677)
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

Re:Cray - A Clojure Ray Tracer by cesare on Wednesday October 07, 2009 @09:54AM (#866695)
> 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.

Re:Cray - A Clojure Ray Tracer by tamas on Wednesday October 07, 2009 @10:17AM (#866750)
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.

Re:Cray - A Clojure Ray Tracer by cubedice on Wednesday October 07, 2009 @09:56AM (#866706)
Ah, thanks, that makes sense. What I was thinking of was the many times I've crashed java by trying to load/render decently sized images in memory (something about how heap space takes awhile to dynamically allocate). You could specify initial heap size with a command line flag, but it was hacky and I had a hard time getting it to work consistently.
Re:Cray - A Clojure Ray Tracer by drewr on Wednesday October 07, 2009 @12:02PM (#866961)
I'll take anything over "clj-ray" or "rayjure."
Re:Cray - A Clojure Ray Tracer by sunkencity on Wednesday October 07, 2009 @10:19AM (#866758)
why not "craj" like clojure does "cons" "conj" :)
Re:Cray - A Clojure Ray Tracer by rbanffy on Wednesday October 07, 2009 @11:41AM (#866910)
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.

Re:Cray - A Clojure Ray Tracer by grogers on Wednesday October 07, 2009 @12:26PM (#867005)
Unless you were planning on ray-tracing a scene near a black hole, what good would this be?
Re:Cray - A Clojure Ray Tracer by rbanffy on Wednesday October 07, 2009 @01:12PM (#867109)
This is _hacker_ news. It doesn't need to be good for something as long as it's cool.
Re:Cray - A Clojure Ray Tracer by icey on Thursday October 08, 2009 @12:26PM (#869312)
How would you know it was working?
Re:Cray - A Clojure Ray Tracer by msie on Wednesday October 07, 2009 @03:43PM (#867478)
Thanks for giving me the laugh of the day! :D
Re:Cray - A Clojure Ray Tracer by Hexstream on Wednesday October 07, 2009 @08:41PM (#868010)
"As you can see, adding this feature slows down the rendering by a factor of 4, but I think it's a small price to pay for the added accuracy, even if you can't see it."
Re:Cray - A Clojure Ray Tracer by oliveoil on Wednesday October 07, 2009 @01:03PM (#867093)
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!!
Re:Cray - A Clojure Ray Tracer by fsm on Wednesday October 07, 2009 @05:05PM (#867638)
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. :)

Re:Cray - A Clojure Ray Tracer by spicyj on Wednesday October 07, 2009 @02:12PM (#867282)
I'm pretty sure that's the number of lines in the rendering code, which is interpreted by the (many-LOC) raytracer.