410 likes | 415 Views
Two Methods for Fast Ray-Cast Ambient Occlusion. NVIDIA Research. Samuli Laine and Tero Karras. Ambient Occlusion in Theory. Occlusion of incoming ambient light. Light from these directions does not reach the surface. Light from these directions reaches the surface. What It Looks Like.
E N D
Two Methods for Fast Ray-Cast Ambient Occlusion NVIDIA Research Samuli Laine and Tero Karras
Ambient Occlusion in Theory • Occlusion of incoming ambient light Light from these directions does not reach the surface Light from thesedirections reachesthe surface
Ambient Occlusion in Practice • Use limited range for occlusion • Otherwise everything would be occluded in indoor scenes • Also faster to calculate because of finite radius • Use falloff function to smooth the transition • Do not solve analytically • Theoretically doable, but would be ridiculously expensive • Solution: Monte Carlo sampling • 256 – 1024 samples is usually enough
Ray Casts for Ambient Occlusion • Cast a number of rays from the point to be shaded • Determine occlusion distance, apply falloff, sum • In reality use a fancy low-discrepancy sampling pattern
Using Shadow Rays • Shadow rays are usually faster than ordinary rays • Enough to detect any intersection, not necessarily closest one • Can do if we bake falloff function into the rays
Our Contributions • Two methods for calculating ambient occlusion faster • One for rasterization-based renderers • One for ray tracing -based renderers • No approximations as in screen-space methods • Up to ~10–15x speedup over state-of-the-art ray caster
Common Part: Occlusion Masks • Both methods keep occlusion status in bit masks • Occlusion of all rays from one point = one bit mask • Utilize precalculated look-up tables for fast update of these masks • Update occlusion of all rays at once! • Resembles LUTs of hemispherical rasterization paper by Kautz et al. 2004, but more versatile
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion Look-up Table • Store binary plane vs. ray occlusion • Plane normal & distance from origin 3D table • Clever parameterization to avoid singularity at the center
Occlusion of a Triangle • Combination of four occlusion masks
Using Pre-Calculated Masks • 1283 look-up table is sufficiently accurate • To calculate occlusion of one triangle vs. all occlusion rays from a single receiver point • Transform triangle into coordinate space of receiver point • Calculate triangle plane and edge planes (trivial) • Fetch occlusion masks for all planes • Combine fetched masks together (binary AND) • Combine with current occlusion status (binary OR)
Method 1: Rasterization • First render depth and normal buffers • For each occluding triangle, rasterize bounds for region of influence • For each fragment inside the region of influence, calculate triangle vs. point occlusion and accumulate in frame buffer • Use logic op blending into occlusion bits in frame buffer • Bounding the region of influence similar to ambient occlusion volumes by McGuire 2010
Bounding the Region of Influence • Two choices for bounding volume • If triangle is large, construct hexagonal prism • If triangle is small, construct hemispherical billboard Large triangle Small triangle
Level of Detail Optimization • Far away occlusion doesn’t care about small details in the occluding surface • Therefore, we could use simplified geometry for larger occlusion distances • Nearby occlusion always has to be done using original geometry! • Split occlusion distance to various ranges, apply progressively more and more aggressive simplification as the distance grows • Can yield 30–140% speedup with tolerable error, depending on the scene
Method 2: BVH Traversal • Assume that BVH for scene triangles is available • Find occluding triangles by traversing the BVH around the neighborhood of the receiver point • Similarities to packet traversal of Wald et al. 2007.
BVH Traversal Algorithm • Maintain cumulative occlusion mask for all AO rays during traversal • When making traversal decision, estimate the occlusion potential of current node’s children • Occlusion potential = Number of currently non-blocked rays that are blocked by the bounds of the node • If occlusion potential is zero, don’t go there • If both children are eligible, first process the one with greater potential • Try to build up occlusion quickly to be able to cull remaining nodes
Calculating Node Occlusion Mask • Tried out two kinds of node bounds • Boxes • Find silhouette edges, use same mask LUT as for triangles • Tight bounds, but expensive to compute (6 lookups) • Spheres • Determine direction and apex angle • Needs a separate 3D LUT for finding the occlusion mask • Conservative bounds, but cheap to compute (1–2 lookups) • Found out that spheres gave best overall performance
Results • Compared against our previous GPU ray caster[Aila and Laine 2009] • Added optimizations for shadow rays • Performance measured in Mrays/second • Used various ambient occlusion radii
Future Work • Soft shadows from area light sources
Thank You • Questions