Interactive real-time raytracing in WebGL
jonathan-olson.com
jonathan-olson.com
I think the rationale for using ANGLE is to avoid driver bugs, but in my experience, it causes much more damage than the problems it solves. Practically any page with a non-trivial shader freezes Firefox for up to a minute or sometimes even more on my machine.
>Practically any page with a non-trivial shader freezes Firefox for up to a minute or sometimes even more on my machine.
That makes me glad I disabled it.
[1]: In about:config, I set webgl.disabled to true.
Nowadays, NVIDIA provides GLES2/3 apis, but not sure about AMD/Intel.
Firefox might upgrade this sometime, but Aurora (Firefox 32) still uses Direct3D 9.
Rasterization is just too cool of a hack to avoid the tracing of primary rays. In fact, it's rather all the hardware and software hacks that evolved around rasterization for 2 decades combined that make it so, not rasterization by itself per se. Various GPU & CPU based culling methods, early & hierarchical Z-buffer, today's realtime rendering pipeline is an amazing combination of cool techniques that keeps getting better. Raytracers say "pff, with real raytracing we wouldn't need all those dirty hacks", but for one most of them come with the GPU or are well-known and intuitive to implement, plus to get anywhere near-realtime they need to implement another set of even more (and less comprehensible/intuitive/hardware-accelerated) hacks of their own.
All shading stages are also designed around rasterization and matured over the last decade. It's good fun to write some pixel-shader-based raytracer but that alone doesn't make it the better fit for current/next-gen gamedev at all.
The oft-antipicated "hybrid" approach however is finally arriving. Once you have some "depth-aware screen-space" (whether voxelized or N-layers), you can shoot specialized and rather simple rays to create diverse outstanding effects in post-process, from much smoother water surfaces to of course "screen-space raytraced reflections" (SSRR).
Besides that, what would you say to ilaksh’s comment? https://news.ycombinator.com/item?id=8060197
I don't believe that any individual school, professor or course can really be up-to-date with the most leading edge practices or even theory, especially in high technology.
I think that the only really interesting area now in computer graphics is in doing path-tracing in hardware.
There is a massive culture that still is interested in other things but I think they are behind the times.
Sooner or later nVidia or ATI/AMD will put some native capabilities for path tracing a scene (not like OptiX where you program the existing architecture for it, but circuits/architecture that is truly optimized for path tracing) given a set of geometry, materials and lights into their graphics cards.
At that point all of the rasterization and lighting calculation tricks will be obsolete.
Probably this will be buried because there is an enormous amount of effort going into those old-fashioned approaches, but oh well. I have to say it.
My project, https://Clara.io, also features interactive ray-tracing but we do it server side using V-Ray. Example here:
https://clara.io/view/a82f8a80-8a5e-4e61-8faf-3de9eb4313c2/r...
Error: WebGL: drawArrays: incomplete framebuffer
Chrome: GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glDrawArrays: framebuffer incomplete (clear)
GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glDrawArrays: framebuffer incomplete (check) (repeated many times)Pathtracing is the art of tracing paths of rays using raytracing.
It's a bit trickier due to restrictions in WebGL (OpenGL ES based) compared to the desktop (e.g. no bitwise operators makes it a pain to get randomness that doesn't bias the result), but it's basically the same.
Fresnel reflectance is based off of http://mathinfo.univ-reims.fr/IMG/pdf/Combined_rendering_of_..., although I'm not doing any spectral or polarization-dependent code right now (I wanted to leave that open, and it allows accurate metal simulation).
I tinkered with a blend of some pseudorandomness functions until getting something that worked.
https://www.siggraph.org/education/materials/HyperGraph/rayt... was used for ray-box intersection.
The distance function experiment for the drinking glass is based off of the concept of http://www.iquilezles.org/www/articles/distfunctions/distfun... (like raymarching, includes normal computation).
I consulted http://madebyevan.com/webgl-path-tracing/ to see the best way to do accumulation (and made some realism fixes in https://github.com/jonathanolson/webgl-path-tracing, see https://github.com/evanw/webgl-path-tracing/pull/1 for details).
Many other things can be pulled from online or from books like http://www.amazon.com/Game-Engine-Design-Interactive-Technol....
Please let me know if you have any questions, (see my email at http://jonathan-olson.com/about), and please feel free to use my code however you like (things I wrote are MIT, but I use CC-by and CC-by-non-commercial HDR images).
[1] http://www.amazon.com/Physically-Based-Rendering-Second-Impl...