Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGL Scene Renderer

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/.

Rendering Overview

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.

Feature Tour

Orbit Camera And Scene Composition

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.

Orbit camera and object placement

OBJ/MTL Mesh Loading

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.

OBJ and material loading

Direct Lighting

Direct lighting uses a Blinn-Phong model. Material diffuse/specular colors and shininess come from the MTL files, with optional diffuse texture sampling.

Blinn-Phong lighting

Indirect Lighting And Skybox

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.

Indirect lighting and skybox

Framebuffer And Post-Processing

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.

Framebuffer post-processing

Hardware Instancing

The crystal mesh can be drawn as 120 instances. Instance color and world matrix data are uploaded once and consumed through instanced vertex attributes.

Hardware instancing

Compute Shader Texture

A compute shader generates the cube texture on the GPU. The generated image combines a checker pattern with concentric rings.

Compute shader texture

ImGui Runtime Controls

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.

ImGui controls

Fresnel And Rim Lighting

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.

Fresnel and rim lighting

Build And Run

Requirements

  • Windows
  • GPU and driver with OpenGL 4.3 support
  • CMake 3.20+
  • MSYS2 MinGW64 packages:
    • mingw-w64-x86_64-gcc
    • mingw-w64-x86_64-cmake
    • mingw-w64-x86_64-glew
    • mingw-w64-x86_64-glfw

Commands

From the repository root:

cmake -S . -B build -G "MinGW Makefiles"
cmake --build build
./build/opengl_scene_renderer.exe

The executable can be launched from the repository root or from build/; asset and shader paths are resolved for both cases.

Controls

  • Left mouse drag: orbit the camera.
  • Mouse wheel: zoom in or out.
  • 1 to 4: switch post-processing mode.
  • I: toggle instanced crystals.
  • F2: save capture.bmp.
  • ImGui panel: edit lighting, colors, Fresnel, rim lighting, instancing, post-processing, and animation pause.

Repository Layout

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

Third-Party Code

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages