How it works...

Once we've created the diffuse convolution, there's not much to this technique. We just simply look up the value in the convolved map DiffConvTex and multiply it with the base color of the surface. In this example, the base color for the surface is taken from a second texture map (ColorTex). We apply gamma decoding to the base color texture to move it into linear color space before multiplying with the environment map. This assumes that the texture is stored in sRGB or has already been gamma encoded. The final value is then gamma encoded before display. The values in the environment map are in linear color space, so we need to move everything to linear space before combining. For some details about gamma encoding/decoding, ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.