two methods for fast ray-cast ambient occlusion samuli laine and tero karras nvidia research

41
Two Methods for Fast Ray- Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Upload: lesley-terry

Post on 15-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Two Methods for Fast Ray-Cast Ambient Occlusion

Samuli Laine and Tero KarrasNVIDIA Research

Page 2: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Ambient Occlusion in TheoryAmbient Occlusion in Theory

Occlusion of incoming ambient light

Light from thesedirections reachesthe surface

Light from these directions does not reach the surface

Page 3: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

What It Looks LikeWhat It Looks Like

Page 4: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Ambient Occlusion in PracticeAmbient 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

Page 5: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Ray Casts for Ambient OcclusionRay 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

Page 6: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Using Shadow RaysUsing 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

Page 7: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Our ContributionsOur 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

Page 8: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Common Part: Occlusion MasksCommon 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

Page 9: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 10: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 11: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 12: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 13: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 14: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 15: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 16: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 17: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 18: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 19: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 20: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 21: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 22: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 23: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 24: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 25: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion Look-up TableOcclusion Look-up Table

Store binary plane vs. ray occlusion

Plane normal & distance from origin 3D table

Clever parameterization to avoid singularity at the center

Page 26: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Occlusion of a TriangleOcclusion of a Triangle

Combination of four occlusion masks

Page 27: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Using Pre-Calculated MasksUsing 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)

Page 28: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Method 1: RasterizationMethod 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

Page 29: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

RasterizationRasterization

Page 30: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Two choices for bounding volume

If triangle is large, construct hexagonal prism

If triangle is small, construct hemispherical billboard

Bounding the Region of InfluenceBounding the Region of Influence

Large triangle Small triangle

Page 31: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Level of Detail OptimizationLevel 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

Page 32: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Level of Detail ExampleLevel of Detail Example

Page 33: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Method 2: BVH TraversalMethod 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.

Page 34: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

BVH Traversal AlgorithmBVH 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

Page 35: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Calculating Node Occlusion MaskCalculating 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

Page 36: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

ResultsResults

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

Page 37: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

ResultsResults

Page 38: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Results: ScalabilityResults: Scalability

Page 39: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Results: CorrectnessResults: Correctness

Page 40: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Future WorkFuture Work

Soft shadows from area light sources

Page 41: Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research

Thank YouThank You

Questions