News for hackers. Stuff that matters.
Re:Javascript Ray Tracer by kmm on Monday January 02, 2012 @09:07AM (#3415933)
I had to do a raytracer for a class in university this semester, too bad I didn't think of portals. It's almost a trivial example of recursive raytracing.

The interlacing is a nice touch too. I shuffled an array of pixels and filled it sequentially.

The low speed is unfortunate though. Any plans for using NaCl or Dart?

Re:Javascript Ray Tracer by vjeux on Monday January 02, 2012 @09:27AM (#3415983)
I've not looked much for optimization. First, what you can do is reduce the number of allocations. Instead of creating a new vector3 for each operation, you can do it in place.

Another way to optimize is to make all the ray calculation on the GPU with WebGL shaders. There are a lot of demos of real time small ray tracers. It works well because it's massively parallel and vector operations are hard-wired. The downside is it's harder to debug and you cannot make long operations or it will crash the graphic driver.

Re:Javascript Ray Tracer by bsenftner on Monday January 02, 2012 @11:45AM (#3416418)
Try doing a stochastic spread of the rays sent through each pixel, with attenuation based upon differences in the surfaces reached by the rays. I was able to create an adaptive raytracer with 4 test rays per pixel and up to 56 when adaptively needed. The speed gain is quite significant, with visual clarity equal to simpler renders requiring much more time.
Re:Javascript Ray Tracer by berkut on Monday January 02, 2012 @10:08AM (#3416102)
You could use WorkerThreads to do it in tiles - that parallelises nicely and would give you almost linear speedup.