PBR Shader Tool – Real-Time Shader Development in OpenGL
I developed a custom real-time shader tool in OpenGL inspired by Unreal Engine’s Principal Shader, implementing a complete Physically Based Rendering (PBR) pipeline enhanced with Image-Based Lighting (IBL). This standalone application enables dynamic previewing and tweaking of textured 3D models with industry-standard shading workflows.
The shader system supports base color, normal mapping, roughness, metallic, and ambient occlusion maps, with user control over material properties and lighting via a custom ImGui interface. The project showcases my understanding of PBR theory, Fresnel-Schlick approximation, GGX microfacet distribution, and IBL convolution techniques.
Github
Shader Architecture & Real-Time Controls
The rendering pipeline is composed of 7 GLSL shader files, covering core material shading, normal reconstruction, IBL integration, skybox generation, and irradiance map convolution. These are supported by custom C++ modules for:
-
Texture loading and mipmap generation (stb_image)
-
Mesh parsing via .obj files (tinyobjloader)
-
Shader program compilation and uniform binding
-
Cubemap generation from HDRI environments
-
Tangent-space normal mapping with correct TBN matrix setup
Users can load any .obj file and upload custom texture maps directly into the viewer. Real-time controls allow for:
-
Adjusting Roughness and Metallic via sliders
-
Changing Base Color Tint
-
Toggling each texture channel on/off
-
Modifying Light Direction, Color, and Intensity
-
Enabling/disabling IBL and skybox environment
Image-Based Lighting (IBL)
The IBL system uses a loaded HDR equirectangular environment map, which is converted to a cubemap in real-time. This cubemap is then:
-
Convolved to generate an irradiance map for diffuse ambient lighting
-
Sampled using textureLod() for specular reflections based on roughness (mipmap LOD)
Together, this produces accurate environmental lighting and reflections across rough and metallic surfaces, allowing for materials that feel grounded in their surroundings.
Technical Implementation
-
GLSL Shading: Implements GGX BRDF, Schlick Fresnel, and Smith geometry term
-
Mipmap-based LOD: Specular reflections are roughness-dependent via textureLod()
-
Modular C++: texture_utils.cpp, shader_utils.cpp, and mesh_utils.cpp handle core OpenGL setup
-
Camera system: Orbital camera with ImGui-mouse lockout and smooth zoom/pan controls
-
Debugging tools: Toggle IBL and map channels, preview specular/ambient contributions
Model Sources: