rendoir / vulkan

Vulkan physically-based renderer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vulkan

Physically-based Rendering with Image-based Lighting in Vulkan.

PBR with IBL

Physically-based Rendering

PBR

The direct lighting term is calculated with Cook-Torrance's Bidirectional Reflective Distribution Function (BRDF). This implementation uses Trowbridge-Reitz GGX Normal Distribution Function, Schlick-Smith GGX Geometry Function, and Schlick Fresnel Function.

$$ L_o(p, w_o) = {\int_{\Omega} f_r(p, w_i, w_o) L_i(p, w_i) n \cdot w_idw_i } $$

$$ f_r = {k_d f_{Lambert} + k_s f_{Cook-Torrance}} $$

$$ f_{Lambert} = {c \over \pi} $$

$$ f_{Cook-Torrance} = {{D \cdot F \cdot G} \over {4(w_o \cdot n)(w_i \cdot n)}} $$

$$ D_{Trowbridge-Reitz} = {a^2 \over {\pi ((n \cdot h)^2(\alpha^2-1)+1)^2}} $$

$$ F_{Schlick} = {F_0 + (1-F_0)(1-(h \cdot v))^5} $$

$$ G_{Schlick-Smith} = {{{n \cdot v} \over {(n \cdot v)(1-k)+k}} * {{n \cdot l} \over {(n \cdot l)(1-k)+k}}} $$

Image-based Lighting

IBL

The indirect lighting term is approximated with Image-based Lighting.
The diffuse term is pre-computed by calculating an irradiance cube map which stores the light radiated from the surrounding environment.

skybox

irradiance

The specular term also requires the pre-computation of two maps: a BRDF Lookup table and a prefiltered cubemap. The BRDFLUT contains environment BRDF values for different roughness and view angle inputs. The prefiltered cubemap stores the specular contribution from the surrounding environment, with the multiple mipmaps storing this value for increasing values of roughness.

brdflut

prefilter_mip0 prefilter_mip1 prefilter_mip2 prefilter_mip3 prefilter_mip4 prefilter_mip5 prefilter_mip6 prefilter_mip7 prefilter_mip8 prefilter_mip9

Getting started

Clone the repository

git clone --recursive https://github.com/rendoir/vulkan.git

Configure the project

cmake -S . -B .build

Build the project

cmake --build .build

Acknowledgements

Sascha Willems' Vulkan glTF PBR IBL: For the overall vulkan codebase, model loading and PBR with IBL pipelines.
Joey de Vries' OpenGL Tutorial: For the computer graphics theory and shaders.
Alexander Overvoorde's Vulkan Tutorial: For the vulkan API tutorial.

About

Vulkan physically-based renderer


Languages

Language:C++ 93.5%Language:GLSL 5.2%Language:CMake 1.3%