In the second pass, we compute the ambient occlusion factor. To do so, the first step is to find the matrix that converts our kernel into camera space. We want a matrix that converts the kernel's z axis to the normal vector at the surface point, and applies a random rotation using a vector from RandTex. The columns of the matrix are the three ortho-normal vectors that define the tangent coordinate system in screen space. Since we want the kernel's z axis to be transformed to the normal vector, the third of these three vectors is the normal vector itself. The other two (tang and biTang) are determined by using cross products. To find biTang, we take the cross product of the normal vector (n) and the random rotation vector retrieved ...
How it works...
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.