project: Interactive ray tracing2017-06-15
I have always liked the idea of interactive ray tracing where scenes are rendered fast enough that one can move the camera and look around.
To our luck, ray tracing is trivially parallelizable and we have very wide processing units called GPUs at our disposal. Ray tracing happens to have lots of memory dancing and branching too, so a GPGPU library like OpenCL will help us make this.
We will need to blit an OpenGL texture to draw the output to the screen. OpenCL has a
cl_khr_gl_sharing extension for this which enables it to write directly onto the GL texture. Sadly enough beignet for HD4000 doesn't have it, so we will copy CL->host->GL every frame.
Rest is plain recursive ray tracing except there is no recursion in OpenCL. We maintain a stack to emulate it- conductors push one more ray after them, dielectrics push two rays.
Cornellbox in rt 4.
Glass plates in rt 5.
Both recordings are on Intel HD 4000 with Beignet 1.3.