Saturday, December 16, 2006

Real-time ray tracing




















My last adventure the interesting places in the universe of maths and software engineering involved real-time ray tracing. I took an existing demo from the JOGL (Java OpenGL) code, and converted it from the ARB shading language to the OpenGl shading language (GLSL). The demo shows a glass rabbit, which you can interactively rotate. Minimalistic ray tracing is done to create the effects of fresnel reflection variance, and chromatically variant refraction. The ray tracing is minimalistic, since only 4 rays are traced per fragment, and they are only traced to a cube-map texture.

First, I extended the the original demo by making the indices of refraction variable, as well as making the fresnel factors variable. Thus in real-time you can make the object become invisible (index = 1 ), or totally reflective (i.e. appears silver coated).

Then, once I got it going in GLSL, I extended it by adding colour filtering to both the reflected and refracted components. Now you can change the "glass" colour. Setting reflective to red, and transmissive to blue looked really cool too.

Aesthetically, taking such a minimalistic approach to ray tracing works fine, since in real-time ray tracing, each frame is transient, so there is "no time" to spend finding the flaws due to the gross simplification.

0 Comments:

Post a Comment

<< Home