Rendering Competition 2007/08
Rubik's Cube

Author:
Holger Bornträger
Covered Topics:
Displacement Mapping
Multithreading
Reflection and Refraction
Displacement Mapping
Displacement Mapping is used to create the wave surface.
Files:
<PHDisplacementMap.h>
<PHDisplacementInformation.h>
The first file contains the actual logic of the displacement. In this case it is only implemented for parallelograms, but could easily be changed to work on triangles as well (based on uv map).
It creates a raster in the given plane, defined by to vectors and a point, displaces the points, and builds the triangles as they are imported into an object.
The second file contains a baseclass that represents the displacement information. This could be an image (not implemented) or as in this case a functional representation that delivers data for the displacement.
In this special case, its a sinus wave starting at a specific location of the plane: <PHWaveDisplacement.h>.

The picture shows the initial position of the wave, using a PhongShader rather then the refraction/reflection shader used in the movie.
Multithreading
Multithreading is implemented, using a basic eventmanager system, specialy implemented for this application.
Files:
<PHEventManager.h>
<PHEvent.h>
<PHWait.h>
<PHSemaphore.h>
<PHEventManager.h> contains the main Eventmanager, it starts and monitors threads and events. Though this it is the heart of the multithreading and removes most responsibilitys from the threads.
<PHEvent.h> is the blueprint of the basic events, used by the eventmanager.
<PHWait.h> is a class to sync threads. It can be increased from 0. Uppon calling Wait(), it blocks, until the internal counter is zero again.
As it's name suggests, <PHSemaphore.h> implements the concept of a semaphore in C++.
As the results of this only impact the rendertime, not the image (which was only the case before making some of the given code threadsave), I provide a table with some results on the performance.
These values are average values.
worker threads
|
render time
|
1
|
4.5 minutes
|
2
|
3.5 minutes
|
4
|
3 minutes
|
9
|
2.5 minutes
|
All tests performed on an MacBook wit 2Gb RAM and an Intel CoreDuo processor with 2GHz, running OS 10.5 Leopard.
Tests on a server with two 2.4GHz dualcore Xeon processors showed similar results, but the cores where not fully used (about 30%).

The image shows the OS X Activiy Monitor during the rendering process.
Reflection and Refraction
Files:
<PHPhongRefractionMirrorShader.h>
This shader implements refrection/reflection as well as phongshader.
The direction of the refraced ray is computed according to Snell's law, the weight of reflection and refraction is determined by Fresnel term.
The result of the phongshader is then added, by linear interpolation, weighted by an additional parameter, the opacity.
The shader is applied to the waves, and can be seen on every picture.
Here, for better visibility, a special picture moving the cube into the water surface: