Lux Cymex Rendering Pipeline

Lux Cymex is a 3D puzzle platformer where the player uses the intersection of different colored light volumes to solve puzzles. The OpenGL renderer needed to be able to show unique particle effects over the exact space where intersections of spheres, cones, and cylinders of light intersected - which proved to be an interesting challenge to implement into a deferred shading, PBR pipeline.

The initial step the renderer takes each frame is to save the positions, depth, normals, and PBR material values of models in the scene into a buffer to reduce the time complexity of lighting the scene.

For lighting, the max distance (based on attenuation levels) from each light source that it could light geometry is written into the stencil buffer to reduce work needed for fragment shading.

With the scene fully lit, the rendering algorithm unique to Lux Cymex comes into play with the rendering of translucent items.

The light volumes with unique effects upon intersection are RGB, and any combination of two or more colors has a unique effect. So through one way or another, these areas had to be written to the stencil buffer as a bitfield for the particles render pass to know where to draw. The initial idea was to use specialized constructive solid geometry algorithms to find these spaces, but that quickly proved to be unfeasible in real-time, particularly with the number of lights.

The solution used in the end was to draw both back faces and front faces of light volumes to the stencil buffer with specialized logic for what to write. The RGB colors are each represented by a bit in the stencil buffer. While writing the back face bits, these are overwritten on passing the depth test. When going through front faces, however, the mask is OR’d onto the stencil buffer if it passes the depth test.

Previous
Previous

QuickShade

Next
Next

Inkpossible