A Shading Reuse Method for Efficient Micropolygon Ray Tracing • 151:3
Total Page:16
File Type:pdf, Size:1020Kb
A Shading Reuse Method for Efficient Micropolygon Ray Tracing Qiming Hou Kun Zhou State Key Lab of CAD&CG, Zhejiang University∗ Abstract We present a shading reuse method for micropolygon ray trac- ing. Unlike previous shading reuse methods that require an ex- plicit object-to-image space mapping for shading density estima- tion or shading accuracy, our method performs shading density con- trol and actual shading reuse in different spaces with uncorrelated criterions. Specifically, we generate the shading points by shoot- ing a user-controlled number of shading rays from the image space, while the evaluated shading values are assigned to antialiasing sam- ples through object-space nearest neighbor searches. Shading sam- ples are generated in separate layers corresponding to first bounce ray paths to reduce spurious reuse from very different ray paths. This method eliminates the necessity of an explicit object-to-image space mapping, enabling the elegant handling of ray tracing effects Figure 1: An animated scene rendered with motion blur and re- such as reflection and refraction. The overhead of our shading reuse flection. This scene contains 1.56M primitives and is rendered with operations is minimized by a highly parallel implementation on the 2 reflective bounces at 1920 × 1080 resolution and 11 × 11 su- GPU. Compared to the state-of-the-art micropolygon ray tracing al- persampling. The total render time is 289 seconds. On average gorithm, our method is able to reduce the required shading evalua- only 3.48 shading evaluations are performed for each pixel and are tions by an order of magnitude and achieve significant performance reused for other samples. gains. high-quality rendering [Parker et al. 2010], this may become a ma- Keywords: micropolygon, GPU, Reyes, ray tracing jor obstacle in future applications. Links: DL PDF In this paper, we introduce a simple but effective method to reuse shading evaluations for efficient micropolygon ray tracing. Com- 1 Introduction pared to the state-of-the-art micropolygon ray tracing algorithm, our method is able to reduce the required shading evaluations by an order of magnitude and achieve significant performance gains. Shading is typically the performance bottleneck in cinematic- quality rendering, which is often based on the Reyes architecture and uses micropolygons to represent high order surfaces or highly 1.1 Related Work detailed objects [Cook et al. 1987]. In order to reduce shading costs, Extensive research has been done on micropolygon rendering and state-of-the-art micropolygon renderers (e.g., Pixar’s RenderMan) ray tracing. perform shading computation on micropolygon vertices, and reuse the shading values to evaluate the color of each visibility sample (or Researchers have explored efficient parallel implementations of mi- antialiasing sample) and composite the final image. Such a shad- cropolygon rendering on GPUs [Wexler et al. 2005; Patney and ing reuse strategy enables a shading rate significantly lower than Owens 2008; Zhou et al. 2009; Hou et al. 2010]. In particular, the visibility sampling rate, which is vital for efficient high-quality Hou et al. [2010] introduced a GPU-based micropolygon ray trac- rendering where extremely high supersampling of visibility is nec- ing algorithm. They demonstrated that for high-quality defocus and essary, especially when rendering defocus and motion blur. motion blur ray tracing can greatly outperform rasterization meth- ods. In their method, ray tracing is only used for visibility sampling Existing shading reuse methods for micropolygon rendering are and shading is still performed on micropolygon vertices. Another primarily designed for rasterization based pipelines. Ray trac- branch of research also seeks to accelerate micropolygon rendering ing effects such as reflection and refraction are typically consid- using GPUs [Fisher et al. 2009; Fatahalian et al. 2009; Fatahalian ered as a part of shading in such methods. Consequently, all re- et al. 2010; Ragan-Kelley et al. 2011; Burns et al. 2010]. The key flected/refracted samples have to be shaded, incurring significant difference between our work and theirs is that while they propose overhead. As ray tracing achieves more significance in modern new GPU architecture designs that support real-time micropolygon rasterization, we aim to accelerate high-quality, off-line ray tracing ∗Email: [email protected], [email protected] using software approaches on current GPU hardware. ACM Reference Format A majority of micropolygon rendering algorithms are designed to Hou, Q., Zhou, K. 2011. A Shading Reuse Method for Effi cient Micropolygon Ray Tracing. ACM Trans. Graph. 30, 6, Article 151 (December 2011), 7 pages. DOI = 10.1145/2024156.2024185 reuse the expensive shading computations across multiple visibility http://doi.acm.org/10.1145/2024156.2024185. samples, assuming that shading is continuous and does not vary sig- Copyright Notice nificantly across adjacent visibility samples. Existing shading reuse Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profi t or direct commercial advantage methods can be categorized into object-space methods [Cook et al. and that copies show this notice on the fi rst page or initial screen of a display along with the full citation. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with 1987; Burns et al. 2010] and image-space methods [Ragan-Kelley credit is permitted. To copy otherwise, to republish, to post on servers, to redistribute to lists, or to use any et al. 2011]. In [Cook et al. 1987], shading is performed on microp- component of this work in other works requires prior specifi c permission and/or a fee. Permissions may be requested from Publications Dept., ACM, Inc., 2 Penn Plaza, Suite 701, New York, NY 10121-0701, fax +1 olygon vertices and reused within the same micropolygon. Burns (212) 869-0481, or [email protected]. © 2011 ACM 0730-0301/2011/12-ART151 $10.00 DOI 10.1145/2024156.2024185 et al. [2010] define a shading grid based on a priori shading density http://doi.acm.org/10.1145/2024156.2024185 estimation, while shading values are evaluated lazily after visibility ACM Transactions on Graphics, Vol. 30, No. 6, Article 151, Publication date: December 2011. 151:2 • Q. Hou et al. is resolved and reused within the same shading grid cell. Decoupled Listing 1 Pseudocode of our shading reuse method sampling [Ragan-Kelley et al. 2011] implicitly partitions antialias- 1 //Generate and shade seeding rays ing samples into equivalent classes using shading density control- 2 shading_rays = generateShadingRays(n*shading_rate) ling hash functions. Shading is reused within the same equivalent 3 shading_samples = pathTraceAll(shading_rays) class. 4 shade(shading_samples) 5 //Trace antialiasing rays and reuse shading Stoll et al. [2006] introduced object-space shading reuse into a ray 6 aa_rays = generateAntialiasRays(n*m) tracing pipeline. They use ray derivatives [Igehy 1999] to control 7 aa_samples = pathTraceAll(aa_rays) shading computation rates. Specifically, they conservatively dis- 8 failed = new List cretize the minimum width of the derivative beam cross section 9 for each s in aa_samples into a few predefined object space tessellation grids. Shading is 10 s.shading = shading_samples.findNearest(s) then computed for all tessellation grids hit by at least one ray. As 11 if s.shading == NOT_FOUND: noted in their paper, such an approach may result in considerable 12 failed.add(s) over-shading when there are highly anisotropic derivatives or sig- 13 //Shade failure samples with image space reuse nificant over-tessellation. To avoid such reliance on ray derivative 14 cache = new Hash behaviors, our method controls shading reuse using nearest neigh- 15 for each s in failed bor searches, which are independent of tessellation and automati- 16 if cache.canReuseShadingAt(s): cally adapt to anisotropy. 17 s.shading = cache.fetch(s) 18 else 19 shade(s) 1.2 Challenge and Contribution 20 cache.add(s) 21 //Filter all samples to produce the final image The main challenge in generalizing existing shading reuse methods 22 final_image = downSampleAndFilter(aa_samples) to ray tracing is that ray tracing complicates the object-to-image space mapping. Such a mapping is inherently required for shading reuse as the ideal shading evaluation density is defined in the im- age space while the shading continuity assumption is only valid in 2 Shading Reuse Method the object space. Object-space methods such as [Burns et al. 2010] reuse shading values based on object-space proximities and rely on Our shading reuse method works as the top level rendering loop of the image-space polygon size to control the shading evaluation den- a ray tracer. For an image rendered at the resolution of n pixels sity. In a rasterization-based pipeline, the size can be directly com- with m× supersampling, Listing 1 shows the pseudocode of our puted by simply projecting polygons to the image space. However, method. ray tracing may introduce arbitrary distortion and the image-space The method mainly consists of four steps. First, a certain num- polygon size is no longer practical to compute. Image-space meth- ber of shading rays are generated uniformly in the image space and ods (e.g., [Ragan-Kelley et al. 2011]) reuse shading values based traced to get the shading samples, which are then shaded. Second, on image-space proximities and rely on a continuous object-image antialiasing rays are generated and traced to obtain the antialiasing space mapping for shading accuracy. This assumption is trivially samples. For each antialiasing sample, the nearest reusable shading valid for direct rasterization. Defocus and motion blur effects can sample is located and its shading value is assigned to the antialias- be handled by using the non-blurred image space for the shading ing sample. Third, for those antialiasing samples that cannot find reuse purpose.