Efficient Image-Based Methods for Rendering Soft Shadows
Total Page:16
File Type:pdf, Size:1020Kb
Efficient Image-Based Methods for Rendering Soft Shadows Maneesh Agrawala Ravi Ramamoorthi Alan Heirich Laurent Moll Pixar Animation Studios Stanford University∗ Compaq Computer Corporation Figure 1: A plant rendered using our interactive layered attenuation-map approach (left), rayshade (middle), and our efficient high-quality coherence-based raytracing approach (right). Note the soft shadows on the leaves. To emphasize the soft shadows, this image is rendered without cosine falloff of light intensity. Model courtesy of O. Deussen, P. Hanrahan, B. Lintermann, R. Mech, M. Pharr, and P. Prusinkiewicz. Abstract The cost of many soft shadow algorithms grows with the geomet- ric complexity of the scene. Algorithms such as ray tracing [5], We present two efficient image-based approaches for computation and shadow volumes [6], perform visibility calculations in object- and display of high-quality soft shadows from area light sources. space, against a complete representation of scene geometry. More- Our methods are related to shadow maps and provide the associ- over, some interactive techniques [12, 27] precompute and display ated benefits. The computation time and memory requirements for soft shadow textures for each object in the scene. Such approaches adding soft shadows to an image depend on image size and the do not scale very well as scene complexity increases. number of lights, not geometric scene complexity. We also show Williams [30] has shown that for computing hard shadows from that because area light sources are localized in space, soft shadow point light sources, a complete scene representation is not nec- computations are particularly well suited to image-based render- essary. He performs the visibility calculations in image space, ing techniques. Our first approach—layered attenuation maps— against shadow maps—image-based representations of scene ge- achieves interactive rendering rates, but limits sampling flexibility, ometry. Although the shadows may suffer undersampling, bias, while our second method—coherence-based raytracing of depth and aliasing artifacts, the cost of the algorithm is relatively inde- images—is not interactive, but removes the limitations on sampling pendent of scene complexity. Further, it is possible to implement and yields high quality images at a fraction of the cost of conven- this method as a post-shading pass that modulates a shadowless tional raytracers. Combining the two algorithms allows for rapid rendering from the base renderer to include shadows. This makes previewing followed by efficient high-quality rendering. it simple to add the method to any existing renderer, without mod- ifying the base renderer, and does not limit the approach to partic- CR Categories: I.3.7 [Computer Graphics]: Three-Dimensional ular geometric primitives. In this paper, we describe two efficient Graphics and Realism—Shadowing, Raytracing image-based techniques for rendering soft shadows that can be seen as logical extensions of Williams’ approach. In both methods, shadows are computed in image space. There- Keywords: Shadows, Raytracing, Image-Based Rendering fore the time and memory requirements for adding soft shadows to an image are dependent only on image complexity and the number 1 Introduction of lights, not geometric scene complexity. Neither algorithm com- putes per object textures, so texture mapping is not a bottleneck Soft shadows from area light sources can greatly enhance the vi- for us. This independence from geometric scene complexity allows sual realism of computer-generated images. However, accurately us to efficiently compute soft shadows for large scenes, including computing penumbrae can be very expensive because it requires those which have complex patterns of self-shadowing. determining visibility between every surface point and every light. We will also show that soft shadows are a particularly good ap- ∗ plication for image-based rendering approaches. Since area light (maneesh,ravir)@graphics.stanford.edu (Alan.Herich,Laurent.Moll)@compaq.com Address: Gates Wing 3B-386, Stanford University, Stanford, CA 94305. sources are localized in space, visibility changes relatively little across them. The depth complexity of the visible or partially visi- ble scene as seen from a light (and stored in our shadow maps) is generally very low. Further, shadow maps rendered from the light source sparsely sample surfaces that are oblique to the light source. However, these surfaces are less important to sample well, because they are precisely the surfaces that are dimly lit. The contributions of this paper are the two algorithms summa- rized below, which represent two ends of a spectrum. Layered Attenuation Maps: Our first approach achieves inter- object-based, and the precomputation time can grow quadratically active rendering rates but limits sampling flexibility, and can there- with the number of objects being shadowed, making it impractical fore generate undersampling and banding artifacts. We precom- for large scenes. Furthermore, a separate (generally large) texture is pute a modified layered depth image (LDI) [25] by warping and created for each shadowed object. Our layered attenuation map ap- combining depth maps rendered from a set of locations on the light proach is analogous in that we combine a similar number of depth source. The LDI stores both depth information and layer-based at- images rendered from different points on the light. However, we tenuation maps which can be thought of as projective soft shadow improve on Herf and Heckbert’s method by precomputing image- textures. During display, the proper attenuation is selected from based textures simultaneously for the entire scene. the LDI in real time in software, and is used to modulate normal Soler and Sillion [27] use convolution on blocker images to rendering without shadows. The precomputation is performed in a compute fast approximate soft shadows. A primary advantage few seconds, and soft shadows are then displayed at several frames of their technique is that sampling artifacts that sometimes occur a second. Since the light source sample positions are chosen a pri- when averaging hard shadows are avoided. A disadvantage of their ori, they are correlated for each surface location and this correlation method is that they cluster geometry in object-space and the clus- can appear as banding in the final image. ters cannot shadow themselves; to correct this for complex objects like plants or trees would require a very large number of clusters for Coherence-Based Raytracing: Our second approach removes the leaves. This increased number of clusters can greatly increase limitations on sampling and yields high quality images, suitable the computation time, obviating the benefits of the method. Sep- for high resolution prerendered animations, but is not interactive. arate textures are needed for each cluster being shadowed, which We precompute shadow maps from a few points on the light, often can strain the texture mapping hardware for complex objects. Fur- the boundary vertices. To shade a surface point, we trace shadow thermore, robust error control and automated clustering algorithms rays through the shadow maps rather than the scene geometry. The can be complicated to implement [26]. shadows rays are decorrelated since they are chosen independently Hart et al. [10] develop a view dependent method to accelerate for each surface point, and therefore banding is replaced by noise. soft shadow computations for a standard ray tracer. They precom- While the general approach to ray tracing depth images is well- pute a blocker list of geometry, stored in object space, for each im- known1 [15, 16, 18, 20], we develop several novel acceleration age pixel by tracing a small number (often only one) of shadow rays techniques for accelerating shadow ray computations. to the light. When a blocker is found, they check if adjacent im- The visible portion of a light source tends to change very little age pixels also “see” the same blocker using a recursive 4-connect for surface points close to one another. We describe a new image- flood-fill algorithm. The main stage of their algorithm first projects based technique for exploiting this coherence when sampling vis- and clips each blocker to the light source and then computes the ir- ibility along shadow rays. Our image-based raytracing approach radiance from the remaining portion of the light. While this method with coherence-based sampling produces soft shadows at a fraction can greatly accelerate shadow computation, it is not well-suited for of the cost of conventional raytracers. While we combine both the handling large amounts of tiny blocker geometry. As the size of ge- image-based ray-tracing and sampling algorithms in a single ren- ometric elements decreases, the probability that a blocker is missed derer, they can be used independently (i.e. a standard geometric ray in the blocker list precomputation phase increases, which can re- tracer might incorporate our coherence-based sampling method). sult in light leaks. Moreover, the storage of the blocker list and the projection and clipping of each blocker against the light source Our algorithms can be combined in an interactive lighting sys- can become very expensive. While our coherence-based sampling tem; our fast layered attenuation map method can be used to in- bears some similarities to this approach, we remove two limita- teractively set the viewing transformation, and position the light tions. First, our approach is view independent. From a given set