Project 4: Ambient Occlusion and Contour

「Ambient occlusion」的圖片搜尋結果

「Ambient occlusion」的圖片搜尋結果

Ambient occlusion is a shading and rendering technique used to calculate how exposed each point in a scene is to ambient lighting. For example, the interior of a tube is typically more occluded (and hence darker) than the exposed outer surfaces, and the deeper you go inside the tube, the more occluded (and darker) the lighting becomes. Ambient occlusion can be seen as an accessibility value that is calculated for each surface point. In scenes with open sky this is done by estimating the amount of visible sky for each point, while in indoor environments only objects within a certain radius are taken into account and the walls are assumed to be the origin of the ambient light. The result is a diffuse, non-directional shading effect that casts no clear shadows but that darkens enclosed and sheltered areas and can affect the rendered image's overall tone. It is often used as a post-processing effect.

Unlike local methods such as Phong shading, ambient occlusion is a global method, meaning that the illumination at each point is a function of other geometry in the scene. However, it is a very crude approximation to full global illumination. The appearance achieved by ambient occlusion alone is similar to the way an object might appear on an overcast day.

When artists design imagery to portray a visual scene, they need not just render visual information veridically. They can select the visual cues to portray, and adapt the information each carries. Their results can depart dramatically from natural scenes, but can nevertheless convey visual information effectively, because viewers' perceptual inferences still work flexibly to arrive at a consistent understanding of the imagery.

We suggest that lines in line-drawings can convey information about shape in this indirect way, and work to develop tools for realizing such lines automatically in non-photorealistic rendering. In the figure above, the picture on the left renders silhouettes. The picture in the center renders occluding contours, and shows that contours, on their own, can be quite limited in the information they convey about shape. The picture on the right, however, includes additional lines we call suggestive contours that convey an object's shape consistently and precisely.

Pros and Cons

Screen-space Ambient Occlusion advantages:

  • Advantages: 
    • Independent from scene complexity.  
    • No pre-processing, no memory allocation in RAM
    • Works with dynamic scenes
    • Works in the same way for every pixel
    • No CPU usage: executed completely on GPU  
  • Disadvantages:
    • Local and view-dependent (dependent on adjacent texel depths)  
    • Hard to correctly smooth/blur out noise without interfering with depth discontinuities, such as object edges
Algorithm Overview
  • Ambient Occlusion

Ambient occlusion is related to accessibility shading, which determines appearance based on how easy it is for a surface to be touched by various elements (e.g., dirt, light, etc.). It has been popularized in production animation due to its relative simplicity and efficiency. In the industry, ambient occlusion is often referred to as "sky light".

The ambient occlusion shading model has the nice property of offering a better perception of the 3D shape of the displayed objects. This was shown in a paper where the authors report the results of perceptual experiments showing that depth discrimination under diffuse uniform sky lighting is superior to that predicted by a direct lighting model.

The occlusion A_\bar p at a point \bar p on a surface with normal {\hat {n}} can be computed by integrating the visibility function over the hemisphere \Omega  with respect to projected solid angle:

  A_\bar p = \frac{1}{\pi} \int_{\Omega} V_{\bar p,\hat\omega} (\hat n \cdot \hat\omega ) \, \operatorname{d}\omega

where V_{\bar p,\hat\omega} is the visibility function at \bar p, defined to be zero if \bar p is occluded in the direction \hat\omega and one otherwise, and \operatorname{d}\omega is the infinitesimal solid angle step of the integration variable \hat\omega. A variety of techniques are used to approximate this integral in practice: perhaps the most straightforward way is to use the Monte Carlo method by casting rays from the point \bar p and testing for intersection with other scene geometry (i.e., ray casting). Another approach (more suited to hardware acceleration) is to render the view from \bar p by rasterizing black geometry against a white background and taking the (cosine-weighted) average of rasterized fragments. This approach is an example of a "gathering" or "inside-out" approach, whereas other algorithms (such as depth-map ambient occlusion) employ "scattering" or "outside-in" techniques.


In addition to the ambient occlusion value, a "bent normal" vector \hat{n}_b is often generated, which points in the average direction of unoccluded samples. The bent normal can be used to look up incident radiance from an environment map to approximate image-based lighting. However, there are some situations in which the direction of the bent normal is a misrepresentation of the dominant direction of illumination, e.g.,

In this example the bent normal Nb has an unfortunate direction, since it is pointing at an occluded surface.

In this example, light may reach the point p only from the left or right sides, but the bent normal points to the average of those two sources, which is, unfortunately, directly toward the obstruction.

  • Silouette and Suggestive contour:  



A non-photorealistic rendering system to convey shape using suggestive contours and highlights. Suggestive contours are lines that will most likely be contours if viewed at a different angle.

Contours are edges that join a polygon facing the viewer with one facing away. Drawing the  contours of a model is pretty simple, but gives you little more than a silhouette. Suggestive contours are "almost contours" or edges that would become contours in relatively nearby viewpoints. They give much more meaningful information about a model's shape. In the bunny on the right, contours are drawn in yellow, and suggestive contours in green. Another example of contours versus suggestive contours is below.
Contours on the left, and suggestive contours on the right. 
The Basic Task


  • Ambient Occlusion

For each hit point {

Shoot out N rays with radius R and for each ray {

Check the distance to the hit point.

If radius is smaller than R

Count 1


Determine the ambient occlusion based on the ray counting


「Ambient occlusion algorithm」的圖片搜尋結果「Ambient occlusion algorithm」的圖片搜尋結果

  • Silouette and Suggestive contours: Implementation provides a bit more detail about how contours and suggestive contours are calculated, and how the lines are drawn.
  • Contours and Suggestive Contours
To draw the contour lines, the first step is to calculate n.v for every point on the mesh. The vector n is the normal vector at the point, and v is the view vector (see the figure at the above).
Contours are the places where n.v = 0. Suggestive contours, mathematically, are the set of points on the surface at which:
  1. The radial curvature Kr at the point is 0 (meaning there is a point of inflection along the curve)
  2. DwKr > 0 (meaning that the curve switches from being convex - like a mountain - to concave - like a valley)

In the picture below (from [2]), the point p is part of the suggestive contour.
Note that you also need to cull the lines for contours and suggestive contours on the back of the mesh.
Require Functionalities
  1. Parse in the scene, material, light and other informations. 
  2. Fast local rendering with OpenGL. 
  3. Shoot out ambient ray from each hit points to collect the ambient occlusion with Monte Carlo methods to determine the ambient occlusion. (15%)
  4. Rendering the scene with ambient occlusion  (5%)
  5. Analyze the each object mesh to determine their silouette. (5%)
  6. Determine the suggestive contours (20%)
  7. Rendering with line drawing using silouettes and suggestive contours (5%)
  8. Implement Screen-space ambient occlusion with GPU. (15%)
  9. Implement GPU-based suggestive contours. (15%)
What to Hand in

All your hand-in must be put in a directory with your student ID and the following is the list of hand-in files under the directory. 

  • Program and source: As usual, you must hand in everything needed to build and run your program, including all texture files and other resources.
  • Gallery: Please put a few JPG pictures of the rendering results at least three. Please name the pictures ID-X.jpg (where X is a number).
  • Read-me.txt
    • Instructions on how to use your program (in case we want to use it when you're not around)
    • Descriptions of what your program does to meet all of the minimum requirements.
  • Technical.txt:
    • The report could contain a description of this project, what you have learned from this project, description of the algorithm you implemented, implementation details, results (either good or bad), and what extensions you have implemented. 
Advance techonologies

This paper introduces a new approximation algorithm for the near-field ambient occlusion problem. It combines known pieces in a new way to achieve substantially improved quality over fast methods and substantially improved performance compared to accurate methods. Intuitively, it computes the analog of a shadow volume for ambient light around each polygon, and then applies a tunable occlusion function within the region it encloses. The algorithm operates on dynamic triangle meshes and produces output that is comparable to ray traced occlusion for many scenes. The algorithm's performance on modern GPUs is largely independent of geometric complexity and is dominated by fill rate, as is the case with most deferred shading algorithms.

    • Suggestive contour extension
      1. Pen and Ink Shading:Often artists do pen and ink shading by drawing cross-hatching or parallel lines to indicate a shadowed region. I tried to imitate this.
      2. Varied Line Thickness: I tried varying the line thickness depending upon how "lit" the line was (so the more in shadow, the thicker the line).
      3. Varied Color: I tried to vary the shade of the line depending upon how lit the line was
      4. Implement with Chinese ink painting.
    1. Miller, Gavin (1994). "Efficient algorithms for local and global accessibility shading". Proceedings of the 21st annual conference on Computer graphics and interactive techniques. pp. 319–326.
    2. Langer, M.S.; H. H. Buelthoff (2000). "Depth discrimination from shading under diffuse lighting". Perception. 29 (6): 649–660. doi:10.1068/p3060. PMID 11040949.
    3. Oscar 2010: Scientific and Technical Awards, Alt Film Guide, Jan 7, 2010
    4. Suggestive Contours for Conveying Shape: 
    5. Highlight Lines for Conveying Shape: 
    6. Dan Maljovec:
    7. Suggestive Contours by Alyssa Daw: