Physically Based Shading (2017)

Windows/Linux, C++, OpenGL 4, Vulkan, Direct3D 11, Direct3D 12

Physically based shading & image based lighting implemented in multiple graphics APIs.

Shading model combines Lambertian diffuse BRDF with Cook-Torrance microfacet specular BRDF. For direct lighting up to three analytical light sources are supported. Indirect lighting is approximated by an irradiance map and a reflection environment map pre-filtered for various roughness values. Split-sum approximation is used to achieve sufficient image quality without taking multiple samples of the environment.

Environment map filtering and split-sum specular BRDF 2D LUT generation is performed at startup via compute shaders.

The goal of this project is to showcase the use of various modern graphics APIs and to provide a clear side-by-side comparison of them. I believe that an implementation of physically based shading is a sufficiently non-trivial use case for that comparison to be useful.

Each implementation is completely self contained within a single source/header pair. The coding style is mostly procedural ("C with classes") using simple POD structs for grouping related data together. This was done for simplicity, readability, and to not impose any particular renderer design/organization.

Shaders are heavily commented because there's where interesting stuff happens. :)

Supported APIs:

Links