Engine-0
I built a real-time graphics engine in C++17 and OpenGL 4.6, with an entity-component architecture and a scene editor. The engine supports multi-pass deferred physically based rendering, GPU light culling, and adaptive terrain.
- C++17
- OpenGL 4.6
- GLSL
- Dear ImGui

Engine architecture
The entity-component system organizes scene data into transforms, geometry, materials, lights, terrain, and environment probes. Factories assemble entities from components and reuse meshes, shaders, and textures from shared resource libraries.
The scene registry supplies entities to the rendering, lighting, and probe systems. The Dear ImGui editor exposes scene properties and individual render targets for editing and inspection.

Rendering pipeline
- Geometry
Write positions, normals, and material data to the G-buffer.
- Directional shadows
Render a variance shadow map.
- Screen-space ambient occlusion
Calculate occlusion from view-space geometry.
- Tiled light culling
Build per-tile point-light lists on the GPU.
- Point-light shadow
Render a depth cubemap for the selected caster.
- Deferred PBR lighting
Combine direct light, environment lighting, occlusion, and emission in HDR.
- Bloom and tone mapping
Apply bloom, then tone map the HDR result.
- Sky composition
Composite the sky using scene depth.
Physically based rendering
The deferred shader evaluates a Cook-Torrance microfacet BRDF with a GGX normal distribution, a Smith geometry term using Schlick-GGX factors, and Schlick Fresnel. Materials use a metallic-roughness workflow with maps for base color, normals, roughness, metallic, and material occlusion. Base color, roughness, and metallic also support constant values.


Deferred rendering
The geometry pass writes surface and material data to the G-buffer. The deferred pass reads those attachments to combine direct and environment lighting with occlusion and emission. Emissive surfaces contribute to bloom, while analytical lights illuminate nearby geometry.
Individual attachments can be inspected to isolate material and lighting issues.

Interior render targets. Material AO is stored in the G-buffer. Screen-space ambient occlusion is computed in a separate pass.
View full resolutionImage-based lighting and shadows
HDR environments are processed into diffuse irradiance cubemaps and roughness-prefiltered specular cubemaps. Deferred lighting combines these with a BRDF integration lookup texture. Local probes blend precomputed HDR environments with the sky using distance-based weights. Reflections sample the HDR maps.
The directional light uses variance shadow mapping. One selected point light can cast shadows using a six-face radial-depth cubemap.
HDR environment lighting


Only the HDR environment changes. Camera, materials, and exposure are fixed.
Local reflection probe


The local Kloofendal probe changes the camera model’s lighting and reflections while Kloppenheim remains the visible sky.
Shadow mapping


Directional and point-light shadow mapping enabled and disabled. Lighting, ambient occlusion, and exposure remain unchanged.
Tiled deferred lighting
A compute shader projects conservative point-light bounds, assigns overlapping lights to 16 × 16 screen-space tiles, and writes candidate counts and indices to shader storage buffers. The deferred pass reads the current tile’s list and checks each candidate against its light radius at the fragment.
Point-light comparison


Both views use tiled lighting with fixed camera, exposure, environment lighting, fixture emission, and shadow caster.

Light culling results
- Uploaded point lights
- 34
- Tile size
- 16 × 16 px
- Mean candidates per tile
- 21.08
- Candidates per tile
- 10–34
- Overflowing tiles
- 0
34-light corridor at 1280 × 720.
Adaptive terrain
A 16-bit, 1025 × 1025 heightmap generates a 1024 × 1024 m terrain. Geomipmapping selects distance-based LODs on a 16 × 16 patch grid and culls patches against the camera frustum. Neighboring patches differ by at most one LOD step, with stitched indices along mixed-resolution boundaries.
World-space triplanar materials blend by slope and elevation. Stochastic hex sampling breaks up visible texture repetition.

Terrain with slope-dependent triplanar materials.
View full resolutionTerrain geometry reduction
Geomipmapping with patch frustum culling reduced submitted triangles by 91.7% from the same camera.
| Configuration | Submitted triangles |
|---|---|
| Full-resolution mesh | 2,097,152 |
| Geomipmapping with patch culling | 173,584 |
Asset credits
The Poly Haven models, textures, and HDR environments use CC0 1.0. Poly Haven asset license
Material study
- Dimitrios Savva · Wood Table
- Sergej Majboroda · Studio Small 09
Interior and reflection probes
- Jenelle van Heerden (model and photography), James Ray Cock (textures) · Vintage Video Camera
- PeterM (film reels) · 8mm Filmstrip Projector
- Ethan Place · Wooden Table 01
- Mateusz Sadek · Industrial Pipe Lamp
- DaDrood · Binder Notebook
- Ulan Cabanilla · Office Notepads
- Ulan Cabanilla · Wooden Bookshelf Worn
- John Malcolm · Book Encyclopedia Set 01
- Rob Tuytel · White Plaster 02
Environment maps
- Greg Zaal, with sky edits by Jarod Guest · Kloppenheim 06 Pure Sky
- Greg Zaal · Lebombo
- Greg Zaal · Kloofendal 43d Clear (Pure Sky)
- Greg Zaal · Rogland Clear Night
- Greg Zaal (photography), Jarod Guest (processing) · Qwantani Afternoon
Industrial corridor
- Kuutti Siitonen · Industrial Wall Lamp
- Ulan Cabanilla · Caged Hanging Light
- Jorge Camacho · Modular Industrial Pipes 01
- James Ray Cock · Utility Box 02
- Serhii Khromov · Barrel 03
- Amal Kumar · Concrete Panels
- Dimitrios Savva · Hangar Concrete Floor
- Rob Tuytel · Metal Plate 02
Terrain
- Charlotte Baglioni · Grass Ground
- Rob Tuytel · Rock 01
- Rob Tuytel · Rock Ground 02
The window frame reuses Wood Table maps. A Python script procedurally generated the 16-bit terrain heightmap offline.
The MaterialX viewer shader ball and AO map are credited to Autodesk’s Solid Angle team, with a mesh contribution by Ben Nadler at Lucasfilm. The matrix uses the MaterialX preview sphere with smooth normals added during preparation. MaterialX Apache 2.0 license