Stochastic Depth of Field using Hardware Accellerated Rasterization

MSc Thesis
Lund University

Robert Toth and Erik Linder

Advisors: Jacob Munkberg and Jon Hasselgren

Completed: 2008-06-09



Depth of field is a desired, but computationally expensive effect in computer graphics. A number of algorithms exist, each having distinct drawbacks or limitations. Accumulation buffering is readily hardware accelerated but requires much computation time in order to eliminate unnatural artifacts. Post-processing techniques are popular because of their performance but are inaccurate. Stochastic ray tracing gives excellent quality but is computationally intense and not easily accelerated using contemporary graphics hardware.

In this thesis, we implement stochastic rasterization on contemporary GPUs, and it is shown to be as efficient as accumulation buffering with comparable image quality with less obvious artifacts. We show that it is already viable to use stochastic rasterization in real-time applications, although several graphics hardware optimizations are unavailable using this technique. Some of these optimizations can be extended to support stochastic rasterization with only slight hardware modifications, making the proposed method likely to outperform accumulation buffering for depth of field effects.


In photography, certain objects are sharp, while others are blurry. This can be caused by objects being closer or more distant than the focal distance. This is the effect called depth of field.

Depth of field occurs as soon as a three-dimensional object is being projected onto a flat surface through a lens of non-zero radius. This means that all real-world optical systems - most notably cameras, and even human eyes - experience some degree of depth of field.

With proper care, depth of field can be used to direct the attention of a viewer to specific areas of an image by making surrounding details less prominent and also to enhance the sense of depth in the scene.

Current techniques

Depth of field has previously been solved by

  • Stochastic ray-tracing
  • Post-processing
  • Accumulation buffering
  • Stochastic rasterization
  • Ray-tracing is not readily accelerated by current graphics hardware, and is thus very time consuming and not appropriete for real-time applications.

    Post-processing does not take actual light-transport mechanisms into account and produces faulty images.

    Accumulation buffering works rather well and has been considered the only viable hardware accelerated technique of rendering depth of field. The scene is rendered from multiple points on the virtual lens and the images are then averaged into the final result. A high amount of passes is necessary to avoid artifacts called ghosting. The geometry is sent through the pipeline once per pass.

    Stochastic rasterization was investigated for motion blur by Wexler et al. [1], but was found to be inferior to accumulation buffering. Time-continuous triangles [2] were introduced in order to make stochastic rasterization for single-degree-of-freedom systems, such as motion blur, efficient on graphics hardware. Akenine-Möller et al. proposed a hybrid accumulation buffered stochastic rasterization technique in order to achieve real-time depth of field.

    Our technique

    We have reversed the depth-of-field problem from image-space circles of confusion into an equivalent system of 3D-space discs of confusion. We have developed several techniques for calculating bounds of the blurred geometry extents, significantly reducing unnecessary computations. Each of our techniques excell at different visual cases, and they are easily combined into an efficient dynamic system performing well for virtually all scenes.

    We show that depth of field allows for detail reduction in new areas without percievable loss of quality. We also show that our technique - in contrast to accumulation buffering - significantly gains performance when reducing geometric detail in these areas.

    Our results show that our technique outperforms accumulation buffering in many cases even without mesh reduction. With the addition of mesh reduction indications are that it will be superior to accumulation buffering in all aspects.




    Quality comparison between accumulation buffering techniques (ABT) and stochastic rasterization (SR).

    Illustration of mesh reduction in blurry regions.

    Performance gain when reducing mesh detail.

    Lack of visual impact for heavy reduction.


    [1] Wexler, D., Gritz, L., Enderton, E., and Rice, J. 2005. GPU-Accelerated High-Quality Hidden Surface Removal. In Graphics Hardware, 7-14.

    [2] Akenine-Möller, T., Munkberg, J., and Hasselgren, J. 2007. Stochastic Rasterization using Time-Continuous Triangles. In GH '07: Proceedings of the 22nd ACM SIGGRAPH/EUROGRAPHICS symposium on Graphics hardware, Eurographics Association, 7-16.