Computer Graphics Basic Mapping Techniques

One of my first computer graphics assignments: a real time scene with shadow mapping, reflections and refractions from cube maps, normal and parallax occlusion mapping, and physically based shading, with object selection and transforms through the UI.

The source code is on my GitHub, and builds with Visual Studio 2026 with its dependencies included. It is made with C++, old OpenGL (client states and the fixed function matrices) with GLSL shaders, GLEW, GLFW, GLM and AntTweakBar for the UI. The scene is loaded from obj files, and mtl files give each object its textures, normal map, height map and material.

The objects turn and bob, and two coloured spot lights orbit them, each casting its own soft shadow (3x3 PCF).

The floor uses parallax occlusion mapping. It marches the view ray through a height map in tangent space, so the paving stones occlude each other and keep their depth at grazing angles, where normal mapping alone looks flat.

Shading is Cook-Torrance with a GGX distribution, Smith-Schlick geometry and Schlick Fresnel, in the metallic and roughness workflow, read from the mtl PBR keys (Pm, Pr, map_Pr). The output is tone mapped and gamma corrected. Reflections and refractions sample a mipmapped cube map, rougher surfaces reading blurrier levels, with a procedural sky around the scene. Blinn-Phong shading is a toggle in the UI.

The UI selects an object to move, rotate, scale or change its material, and toggles every effect:


comments powered by Disqus