Realistic, Hardware-Accelerated Shading and Lighting
Total Page:16
File Type:pdf, Size:1020Kb
Realistic, Hardware-accelerated Shading and Lighting Wolfgang Heidrich∗ Hans-Peter Seidel Max-Planck-Institute for Computer Science Abstract be inappropriate a long time ago [4]. Moreover, techniques for vi- sualizing non-diffuse global illumination are not widely applied, With fast 3D graphics becoming more and more available even on although several researchers have worked on such methods. low end platforms, the focus in hardware-accelerated rendering is In this paper, we present a class of techniques to improve the beginning to shift towards higher quality rendering and additional quality of shading and lighting in hardware-accelerated computer functionality instead of simply higher performance implementa- graphics. We start with algorithms for high-quality local illumina- tions based on the traditional graphics pipeline. tion using alternative lighting models such as the one by Torrance In this paper we present techniques for realistic shading and and Sparrow [39]. This approach is based on an analytic factoriza- lighting using computer graphics hardware. In particular, we dis- tion of the respective model into bivariate terms that can be rep- cuss multipass methods for high quality local illumination using resented as texture maps. We then discuss methods for visualiz- physically-based reflection models, as well as techniques for the in- ing non-diffuse global illumination solutions based on environment teractive visualization of non-diffuse global illumination solutions. maps. We introduce both a Fresnel term for simulating reflections These results are then combined with normal mapping for increas- in non-metallic objects, as well as a pre-filtering method for envi- ing the visual complexity of rendered images. ronment maps. To this end, we also review an alternative parameter- Although the techniques presented in this paper work at interac- ization for environment maps that we recently introduced [20], and tive frame rates on contemporary graphics hardware, we also dis- that allows us to use one map for all viewing positions and direc- cuss some modifications of the rendering pipeline that help to fur- tions. These techniques are finally combined with normal mapping ther improve both performance and quality of the proposed meth- to increase the visual complexity of the scene. ods. Although the techniques presented here produce renderings at interactive frame rates on contemporary graphics hardware, a more CR Categories: I.3.1 [Computer Graphics]: Hardware direct support by future hardware could be achieved through some Architecture—Graphics processors; I.3.3 [Computer Graphics]: modifications of the rendering pipeline. These will be outlined at Picture/Image Generation—Bitmap and frame buffer operations; the end of this paper. I.3.6 [Computer Graphics]: Methodology and Techniques— Standards I.3.7 [Computer Graphics]: Three-Dimensional Graph- ics and Realism—Color, Shading, Shadowing and Texture 2 Previous Work Keywords: reflectance functions, illumination effects, shading, texture mapping, rendering hardware, frame buffer techniques Most of today’s graphics hardware uses either the Phong [7], or the Blinn-Phong [4] illumination model. Many other, physically more plausible models have been proposed, but have so far only 1 Introduction been used in software rendering systems or by hardware that has programmable shaders, such as [30]. The most important of these Until recently, the major concern in the development of new graph- models are the ones by Torrance and Sparrow [39] and Cook and ics hardware has been to increase the performance of the tradi- Torrance [11]. The Torrance-Sparrow model uses a Gaussian micro tional rendering pipeline. Today, graphics accelerators with a per- facet distribution function and a geometric attenuation factor based formance of several million textured, lit triangles per second are on the assumption of v-shaped grooves on the surface. Other dis- within reach even for the low end. As a consequence, we see that tribution functions have been proposed, for example, by Beckmann the emphasis is beginning to shift away from higher performance and Spizzichino [3], while Smith [36] presented a more accurate towards higher quality renderings and an increased feature set that geometry term under the assumption of a Gaussian facet distribu- makes graphics hardware applicable to more demanding applica- tion. He et al. [18] proposed the HTSG model based directly on the tions. Kirchhoff theory of electromagnetic fields. This model is capable Despite this development, most current graphics hardware still of simulating even more physical effects, although at significantly only uses a local Phong illumination model, which was shown to increased computational cost. In addition to the isotropic models listed above, anisotropic mod- ∗Computer Graphics Group, Im Stadtwald, 66123 Saarbruck¨ en, Ger- els have also been proposed. Banks [1] described a very simple many, fheidrich,[email protected] model based on results from the illumination of lines in 3-space, while Cabral et al. [8] and Poulin and Fournier [32] use simula- tions of different kinds of micro geometry. Ward [42] modified the Torrance-Sparrow model by using an anisotropic micro facet distri- bution function. Several different methods for interactively visualizing non- diffuse global illumination have been suggested in the literature. Environment maps as a means of computing a mirror term were proposed by Blinn [6], while the spherical parameterization used by most graphics hardware today was presented by Haeberli and Se- gal [16]. Diefenbach [13] demonstrated a multipass method for ren- dering mirror and glossy reflections on planar surfaces. Ofek and ➞ Rappoport [29] interactively compute mirror reflections off curved n reflectors by warping the reflected geometry. Miller et al. [28] pro- pose an approach where the glossy reflection on a surface is stored ➞ in a compressed light field, and Walter et al. [41] place virtual lights h in the scene to simulate glossy reflections. Sturzlinger¨ and Bas- ➞ tos [38] employ multipass rendering to visualize the result of a pho- v ton tracing algorithm. Finally, in some work developed in parallel δ to ours, Bastos et al. [2] use textures and filtering techniques to ren- β der reflections in planar objects based on physically correct reflec- α ➞ tion models, and Cabral et al. [9] propose an environment mapping l technique for glossy reflections not unlike ours. θ θ ➞ Bump maps, originally introduced by Blinn [5], have recently t found their way into hardware-accelerated rendering. Some re- searchers [14, 26, 31] built or proposed dedicated graphics hard- φ ➞ ware to implement bump maps, while others [25] use multipass h' techniques to realize bump maps with traditional graphics hard- ware. In contrast to bump maps, which define the variation of the surface normal in terms of a bump height, normal maps directly Figure 1: The local geometry of reflection at a rough surface. specify the direction of the surface normal. On the one hand, nor- mal maps are less expensive to compute than bump maps, and can also be generated more easily, for example by measurements [33], This is true for all widely used choices of distribution functions, in- or surface simplification [10]. On the other hand, normal maps are cluding a Gaussian distribution of δ or of the surface height, as well attached to the underlying geometry, while bump maps can be ap- as the distribution by Beckmann [3]. Since the roughness is gen- plied to any surface. erally assumed to be constant for a given surface, this is again a univariate function D(cos δ). Finally, when using the geometry term G proposed by 3 Alternative Lighting Models for Smith [36], which describes the shadowing and masking of light Local Illumination for surfaces with a Gaussian micro facet distribution, this term is a bivariate function G(cos α, cos β). In this section we describe techniques for applying physically ac- The contribution of a single point- or directional light source curate reflection models to the computation of local illumination with intensity Ii to the intensity of the surface is given as Io = ~ x ~ in hardware-based rendering. Rather than replacing the standard fr(l ~v) cos α Ii. The term fr( ; l ~v) cos α can be split into two bi!variate parts· F (cos θ) D(cos δ!) and G(cos α, cos β)=(π Phong model by another single, fixed model, we seek a method that · · allows us to utilize a wide variety of different models so that the cos β), which are then stored in two independent 2-dimensional most appropriate model can be chosen for each application. lookup tables. To achieve this flexibility without introducing procedural shad- Regular 2D texture mapping can be used to implement the ing, a sample-based representation of the BRDF seems most lookup process. If all vectors are normalized, the texture coordi- promising. However, a faithful sampling of 3D isotropic or 4D nates are simple dot products between the surface normal, the view- anisotropic BRDFs requires too much storage to be useful on con- ing and light directions, and the micro facet normal. These vectors temporary graphics hardware. Wavelets or spherical harmonics and their dot products can be computed in software and assigned as could be used to store this data more compactly, but these represen- texture coordinates to each vertex of the object. tations do not easily lend themselves to hardware implementations. The interpolation of these texture coordinates across a polygon corresponds to a linear interpolation of the vectors without renor- malization. Since the reflection model itself is highly nonlinear, 3.1 Isotropic Models this is much better than simple Gouraud shading, but not as good as We propose a different approach. It turns out that most lighting evaluating the illumination in every pixel (Phong shading). The in- models in computer graphics can be factored into independent com- terpolation of normals without renormalization is commonly known ponents that only depend on one or two angles. Consider, for ex- as fast Phong shading.