3 ms·
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
by kmm 15y ago
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?
- vjeux 15y agoI'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.
- berkut 15y agoYou could use WorkerThreads to do it in tiles - that parallelises nicely and would give you almost linear speedup.
- bsenftner 15y agoTry 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.