A C++17/OpenGL 4.3 real-time rendering demo with OBJ/MTL loading, orbit camera navigation, direct and indirect lighting, framebuffer post-processing, hardware instancing, a compute-shader texture, and live ImGui controls.
The project is intentionally small and self-contained: the application code is
in src/, GLSL programs are in shaders/, meshes and textures are in
assets/, and the required third-party single-header/source dependencies are
vendored in third_party/.
The renderer combines direct Blinn-Phong lighting with indirect ambient and environment lighting. The scene is rendered in linear color into a floating-point framebuffer, then copied to the backbuffer through a screen shader that applies gamma correction and optional post-processing.
Main techniques implemented:
- OBJ/MTL mesh loading with per-material submeshes.
- Diffuse textures and material colors from MTL files.
- Blinn-Phong specular highlights.
- Hemispheric ambient lighting for diffuse indirect light.
- Cubemap skybox and environment reflections.
- Floating-point off-screen framebuffer.
- Fullscreen post-processing pass.
- Hardware instancing with per-instance transform and color attributes.
- Compute-shader procedural texture generation.
- Fresnel-Schlick and rim/back lighting controls.
- Live ImGui panel for lighting, colors, post-processing, and animation state.
The camera orbits around the scene with spherical coordinates. Each object has its own translation, rotation speed, and scale. View and projection matrices are shared with the shaders through a uniform buffer object.
Meshes are loaded with TinyOBJLoader. The loader rebuilds interleaved position/normal/UV vertex buffers from OBJ index triplets and groups geometry by material, so each material can be rendered with its own uniforms and texture.
Direct lighting uses a Blinn-Phong model. Material diffuse/specular colors and shininess come from the MTL files, with optional diffuse texture sampling.
Diffuse indirect light is approximated with a hemispheric ambient term based on the world-space normal. Specular indirect light samples a cubemap used by the skybox.
The scene is first rendered into a floating-point color buffer with a depth texture. A second pass draws a fullscreen quad and applies selectable post-processing modes.
The crystal mesh can be drawn as 120 instances. Instance color and world matrix data are uploaded once and consumed through instanced vertex attributes.
A compute shader generates the cube texture on the GPU. The generated image combines a checker pattern with concentric rings.
The ImGui panel exposes the renderer parameters without recompilation: light position and color, sky and ground colors, Fresnel strength, rim lighting, post-processing mode, instancing, and animation pause.
Fresnel-Schlick is used to balance diffuse and specular response depending on view angle. Rim/back lighting emphasizes silhouettes when the light is behind an object.
- Windows
- GPU and driver with OpenGL 4.3 support
- CMake 3.20+
- MSYS2 MinGW64 packages:
mingw-w64-x86_64-gccmingw-w64-x86_64-cmakemingw-w64-x86_64-glewmingw-w64-x86_64-glfw
From the repository root:
cmake -S . -B build -G "MinGW Makefiles"
cmake --build build
./build/opengl_scene_renderer.exeThe executable can be launched from the repository root or from build/; asset
and shader paths are resolved for both cases.
- Left mouse drag: orbit the camera.
- Mouse wheel: zoom in or out.
1to4: switch post-processing mode.I: toggle instanced crystals.F2: savecapture.bmp.- ImGui panel: edit lighting, colors, Fresnel, rim lighting, instancing, post-processing, and animation pause.
assets/ Meshes, materials, textures, and cubemap faces
screenshots/ Reference captures used in this README
shaders/ GLSL vertex, fragment, and compute shaders
src/ C++ application sources
third_party/ Vendored Dear ImGui and TinyOBJLoader sources
This repository vendors:
- Dear ImGui, under its MIT license in
third_party/imgui/LICENSE.txt. - TinyOBJLoader, under its MIT license in
third_party/tinyobjloader/LICENSE.








