English | 2012 | ISBN: 978-1936420223 | 754 Pages | PDF | 20 MB

This updated bestseller provides an introduction to programming interactive computer graphics, with an emphasis on game development using DirectX 11. The book is divided into three main parts: basic mathematical tools, fundamental tasks in Direct3D, and techniques and special effects. It includes new Direct3D 11 features such as hardware tessellation, the compute shader, dynamic shader linkage and covers advanced rendering techniques such as screen-space ambient occlusion, level-of-detail handling, cascading shadow maps, volume rendering, and character animation.

Using the Ambient Occlusion Map

Thus far we have constructed a nice ambient occlusion map. The final step is to apply it to the scene. One might think to use alpha blending and modulate the ambient map with the back buffer. However, if we do this, then the ambient map modifies not just the ambient term, but also the diffuse and specular term of the lighting equation, which is incorrect. Instead, when we render the scene to the back buffer, we bind the ambient map as a shader input. We then generate projective texture coordinates (with respect to the camera), sample the SSAO map, and apply it only to the ambient term of the lighting equation:

…

The advantage of SSAO is most apparent when objects are in shadow. When objects are in shadow, the diffuse and specular terms are killed; thus only the ambient term shows up. Without SSAO, objects in shadow will appear flatly lit by a constant ambient term, but with SSAO they will keep their 3D definition.

When we render the scene to the normal/depth render target, we also build the depth buffer for the scene. Consequently, when we render the scene the second time with the SSAO map, we modify the depth comparison test to “EQUALS.” This prevents any overdraw in the second rendering pass, as only the nearest visible pixels will pass this depth comparison test. Moreover, the second rendering pass does not need to write to the depth buffer because we already wrote the scene to the depth buffer in the normal/depth render target pass.

…

1. The ambient term of the lighting equation models indirect light. In our lighting model, the ambient term is simply a constant value. Therefore, when an object is in shadow and only ambient light is applied to the surface, the model appears very flat with no solid definition. The goal of ambient occlusion is to find a better estimate for the ambient term so that the object still looks 3D even with just the ambient term applied.

2. The idea of ambient occlusion is that the amount of indirect light a point p on a surface receives is proportional to how occluded it is to incoming light over the hemisphere about p. One way to estimate the occlusion of a point p is via ray casting. We randomly cast rays over the hemisphere about p, and check for intersections against the mesh. If the rays do not intersect any geometry, then the point is completely unoccluded; however, the more intersections there are, the more occluded p must be.

3. Ray casted ambient occlusion is too expensive to do in real-time for dynamic objects. Screen space ambient occlusion (SSAO) is a real-time approximation that is based on the view space normal/depth values. You can definitely find flaws and situations where it gives wrong results, but the results are very good in practice with the limited information it has to work with.

Resolve the captcha to access the links!