Precomputing irradiance maps and diffuse convolution
The second part of the split sum approximation necessary to calculate the glTF2 physically based shading model comes from the irradiance cube map, which is precalculated by convolving the input environment cube map with the GGX distribution of our shading model.
Getting ready
Check out the source code for this recipe in Chapter6/Util01_FilterEnvmap
. If you want to dive deep into the math theory behind these computations, make sure you read Brian Karis's paper at https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf.
How to do it...
This code is written for simplicity rather than for speed or precision, so it does not use importance sampling and convolves the input cube map using simple Monte Carlo integration and the Hammersley sequence to generate uniformly distributed 2D points on an equirectangular projection of our input cube map.
The source code can be found in the Chapter6...