ray tracing fall, 2009. introduction simple idea forward mapping natural phenomenon infinite...

42
Ray Tracing Fall, 2009

Upload: lewis-casey

Post on 21-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray Tracing

Fall, 2009

Page 2: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Introduction

Simple idea Forward Mapping Natural phenomenon

• infinite number of rays from light source to object to viewer

Backward Mapping Ray Tracing• finite number of rays from viewer through each sample to object

to light source (or other object)

Page 3: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Rendering with Ray Tracing

Ray Tracing Algorithm Generate primary (‘eye’) ray

• ray goes out from eye through a pixel center (or any other sample point on image plane)

Find closest object along ray path• find first intersection between ray and an object in scene

Compute light sample • use illumination model to determine direct contribution from

light sources for greater accuracy

• recursively generate secondary rays at equal

Page 4: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Raytracing versus scan conversion

Raytracing versus scan conversion scan conversion

• After meshing and projection

• 3D 2D Image

• Based on transforming geometry

• for each triangle in scene

Raytracing• 3D Image

• Geometric reasoning about light rays

• for each sample in pixel image…

Page 5: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray Tracing: Global Illumination Effects

Page 6: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Raytracing

Overview Eye, view plane section, and scene Launch ray from eye through pixel (Generating Rays) see what it hits (Ray-Scene Intersection) Compute color and fill-in the pixel (Computing light sample)

Page 7: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Generating Rays (1/2)

Ray equation

Through eye at t = 0 At pixel center at t = 1

R(t) = E + td

E

E + td

Page 8: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Scene Intersection

Ray-Scene Intersection Intersections with geometric primitives

• Sphere

• Triangle

• Groups of primitives (scene)

Acceleration techniques• Bounding volume hierarchies

• Spatial partitions– Uniform grids– Octrees– BSP trees

Page 9: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Sphere Intersection

Page 10: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Sphere Intersection

Page 11: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Sphere Intersection

Need normal vector at intersection for lighting calculations

Page 12: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Triangle Intersection

Ray-Triangle Intersection First, intersect ray with plane Then, check if point is inside triangle

Page 13: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Triangle Intersection

intersect ray with plane

Page 14: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Triangle Intersection

Check if point is inside triangle algebraically

Page 15: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Other Ray-Primitive Intersections

Cone, cylinder, ellipsoid: Similar to sphere

Box Intersect 3 front-facing planes, return closest

Convex polygon Same as triangle (check point-in-polygon algebraically)

Concave polygon Same plane intersection More complex point-in-polygon test

Page 16: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Ray-Scene Intersection

Find intersection with front-most primitive in group

Page 17: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Bounding Volumes

Check for intersection with simple shape first If ray doesn’t intersect bounding volume, then it doesn’t

intersect its contents If found another hit closer than hit with bounding box, then

can skip checking contents of bounding box

Page 18: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Bounding Volume Hierarchies

Use hierarchy to accelerate ray intersections Intersect node contents only if hit bounding volume

Page 19: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Computing light sample

Local Illumination Ray Casting

Page 20: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Computing light sample

Recursive Ray Tracing Shadows and direct lighting Reflection and refraction Antialiasing, motion blur, soft shadows, and depth of field

Page 21: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Shadow Rays

Detect shadow by rays to light source

Page 22: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Shadow Rays

Test for occluder No occluder, shade normally ( e.g. Phong model ) Yes occluder, skip light ( don’t skip ambient )

Page 23: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Reflection Ray

Recursive shading Ray bounces off object Treat bounce rays (mostly) like eye rays Shade bounce ray and return color

• Shadow rays

• Recursive reflections

Add color to shading at original point• Specular or separate reflection coefficient

V B

S

Page 24: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Refracted Ray

Transparent materials bend light Snell’s Law

Page 25: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing

Send multiple rays through each pixel

Average results together Jittering trades aliasing for noise Use multiple rays for reflection and refraction

How many rays???

Page 26: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing : Soft Shadows

Soft shadows result from non-point lights Some part of light visible, some other part occluded

Area Light

Occluder

Page 27: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing : Soft Shadows

Distribute shadow rays over light surface

Page 28: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Soft Shadows

Page 29: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing : Glossy Reflection

multiple reflection rays

polished surfaceθθ

Justin Legakis

Page 30: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing : Glossy Translucency

Jittering the rays about the actual transmission angle produces a blurred effect

N

I

T

I

Bound of jittered reflection rays

Page 31: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing : Motion Blur

Distribute rays over time More when we talk about animation...

Page 32: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Pinhole camera – everything in focus. Camera with lens – utilized depth of field

“Distributed” Raytracing : Depth of Field

Image Plane Image Plane Focal Plane

Pinhole Camera Camera with lens

Page 33: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

“Distributed” Raytracing : Depth of Field (DoF)

Distribute rays over a lens assembly multiple rays per pixel

Page 34: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Depth of Field

multiple rays per pixel

Justin Legakisfocal lengthfilm

Page 35: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Depth of Field

Page 36: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Bidirectional Ray tracing

Created by H. Wann Jensen

caustic

Page 37: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Bidirectional Ray tracing

Caustic - (Concentrated) specular reflection/refraction onto a diffuse surface

Standard ray tracing cannot handle caustics caustic

Created by H. Wann Jensen

Page 38: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Examples: POV-ray

created using POV-ray, http://www.povray.org/

Page 39: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

POV-ray

created using POV-ray, http://www.povray.org/

Page 40: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

POV-ray

created using POV-ray, http://www.povray.org/

Page 41: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

POV-ray

created using POV-ray, http://www.povray.org/

Page 42: Ray Tracing Fall, 2009. Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer

Summary

Writing a simple ray casting renderer is easy Generate rays Intersection tests Lighting calculations

Recursive Ray Tracing Shadows and direct lighting Reflection and refraction Antialiasing, motion blur, soft shadows, and depth of field

Bidirectional Ray tracing Caustic : specular reflection/refraction onto a diffuse surface Standard ray tracing cannot handle caustics