Code Samples

Small selection of C++ code samples from personal projects. More examples on my GitHub.

CPU-RTRM raymarching loop

Real-time CPU raymarcher main loop. Working on packs of rays, making use of SIMD (SSE/AVX) intrisincs. Full file here.

This method works on a RayPack (a cache and SIMD friendly struct of Rays) and returns a CollisionPack with information of the collisions of the rays with the scene, if they occurred. It also returns a bit mask indicating which of the rays of the pack collided.

GLSL code generation

This method belongs to a system that generates a scene SDF (signed distance function) from a tree of CSG operators (Union, Intersection, etc) and operands (Spheres, Cubes, etc). The output is a string of GLSL code that will be inserted on a GLSL raymarching template. The algorithm is mostly similar to a RPN calculator, with input created from a depth-first traversal of the scene tree.

LagEngine Viewport declaration

On LagEngine, a viewport is a section of a render target associated to a camera. Full file here.