O'Reilly logo

GPU PRO 3 by Wolfgang Engel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3
VI
Interactive Ray Tracing Using the
Compute Shader in DirectX 11
Arturo Garc
´
ıa, Francisco
´
Avila,
Sergio Murgu
´
ıa, and Leo Reyes
3.1 Introduction
Currently, the most widely used technique for real-time 3D rendering is ras-
terization, mainly because of its low computational cost and the availability of
efficient hardware implementations. DirectX and OpenGL are the most common
rasterization-based APIs used for high-end video game graphics programming.
Rasterization is well suited for handling animated scenes, and no auxiliary data
structures are needed to display geometrical changes. On the other hand, ray
tracing is traditionally associated with high computational costs, although it
could eventually become the video game rendering algorithm of the future as
hardware becomes more powerful and ray-tracing techniques grow more sophisti-
cated. Recent advances in ray-tracing engines, acceleration structures, and GPU
programmability are making interactive frame rates possible for ray-tracing ap-
plications.
This chapter presents an original GPU ray-tracing application running
solely on the compute shader and Shader Model 5.0 in DirectX 11. (DirectX 11.1
was released shortly after this writing. The demo uses only DX11.0 features,
and a few implementation details may change in DX11.1) The implementation
includes gloss mapping, normal mapping, texturing, shadowing, reflections, and a
bounding volume hierarchy (BVH) for fast ray-intersection discovery. We analyze
the advantages and disadvantages of using multipass ray tracing for handling a
number of infinite concurrent textures versus a strategy that handles a limited
number of textures in one pass. The ray tracer achieves interactive frame rates
on high-end video cards and can be used as a starting point to implement more
advanced rendering techniques. (See Figure 3.1.)
353
354 VI GPGPU
Figure 3.1. Sample picture generated by the ray tracer explained in this chapter.
3.2 Ray Tracing
Ray tracing is an advanced illumination technique that simulates the effects of
light by tracing rays through the screen on an image plane. The degree of vi-
sual realism of the images generated via this technique is considerably higher
than that obtained through other rendering methods such as rasterization. How-
ever, the computational cost is so high that ray tracing has mostly been used
for offline rendering. Nevertheless, real-time ray-tracing applications are avail-
able today thanks to constant hardware improvements and algorithmic advances,
which ultimately yield more efficient algorithms.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required