ray tracing primer ref: siggraph hypergraphhypergraph

42
Ray Tracing Primer Ref: SIGGRAPH HyperGraph

Upload: emory-willis

Post on 25-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Ray Tracing Primer

Ref: SIGGRAPH HyperGraph

Page 2: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Introduction

Rays are tested against all objects in the scene to determine if they intersect any objects.

The pixel is then set to the color values returned by the ray.

If the ray misses all objects, then that pixel is shaded the background color.

Trace rays of light from the eye back through the pixels of the image plane into the scene

Page 3: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Introduction-2

handles shadows, multiple specular reflections, and texture mapping

point sampling algorithm. We sample a continuous image in world coordinates by shooting one or more rays through each pixel. the potential problem of aliasing

Page 4: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Shadow RayWhen the ray hits an object, a secondary ray, ("shadow" ray), is shot towards the light sources

Determine if that point on the object is in a shadow.

If this shadow ray hits another object before it hits a light source, then the first intersection point is in the shadow of the second object. Only apply the ambient term for that light source at the point of intersection

Page 5: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Reflected RayWhen a ray hits an object, a reflected ray is generated and tested against all of the objects in the scene.

If the reflected ray hits an object then a local illumination model is applied at the point of intersection and the result is carried back to the first intersection point.

Page 6: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Transmitted RayIf the intersected object is transparent, then a transmitted ray is generated and tested against all the objects in the scene.

If the transmitted ray hits an object then a local illumination model is applied at the point of intersection and the result is carried back to the first intersection point.

Page 7: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Multiple Layers of Reflection

The reflected rays can generate other reflected rays that can generate other reflected rays, etc. The next sequence of three images shows a simple scene with no reflection, a single reflection, and then a double reflection.

Page 8: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Recursive Reflection

Page 9: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Ray TreeThe reflective and/or transmitted rays are continually generated until the ray leaves the scene without hitting any object or a preset recursion level has been reached. This then generates a ray tree.

DEMO

This style of ray tracing was invented by Turner Whitted in 1979.

Page 10: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 11: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Ray Tree -2

The appropriate local illumination model is applied at each level and the resultant intensity is passed up through the tree, until the primary ray is reached. Thus we can modify the local illumination model by (at each tree node)

I = Ilocal + Kr * R + Kt * T R is the intensity of light from the reflected ray T is the intensity of light from the transmitted ray Kr and Kt are the reflection and transmission coefficients.

For a very specular surface, such as plastic, we sometimes do not compute a local intensity, Ilocal, but only use the reflected/transmitted intensity values.

Page 12: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Computing Reflection

nnIIr

nnIInnIr

2

)()(

Page 13: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Refraction

Page 14: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 15: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 16: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 17: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 18: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 19: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Ray-Object Intersection

Ray-sphereRay-quadricRay-planeRay-polygonRay-box

See Funkhouser notes on ray castSee Funkhouser notes on ray cast

Page 20: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Time-Consuming

for a naïve raytracer (with no speedup techniques) the time is proportional to (number of rays) (number of objects) Each intersection requires from a few (5-7) to many (15-20) floating point (fp) operations.a scene with 100 objects and computed with a spatial resolution of 512 x 512, assuming 10 fp operations per object test there are about 250,000 X 100 X10 = 250,000,000 fps. This is just for the primary rays (from the eye through the image plane) with no anti-aliasing.

Page 21: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Computation Acceleration

Approaches Use faster machines Use specialized hardware, especially

parallel processors Speed up computations by using

more efficient algorithms Reduce the number of ray-object

computations

Page 22: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Reduce Ray-Object Computation

Adaptive depth control stop generating reflected/transmitted rays when

the computed intensity becomes less than a certain threshold.

Attenuation due to distance and multiple reflection

Bounding volumes enclose groups of objects in sets of hierarchical

bounding volumes (e.g., spheres) and first test for intersection with the bounding volume

Page 23: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Reduce Computation -2

First-hit speedup a large percentage of the work is performed in

finding the first intersection. use a modified Z-buffer algorithm to determine the

first hit The scene would be pre-processed, with the resultant z-

buffer storing pointers to the objects intersected. Then the ray tracing would proceed from that point.

Weghorst showed that incorporating the above three techniques approximately halved the intersection computational time for complex scenes.

Page 24: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 25: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Fast square root

Page 26: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Aliasing Problems

Page 27: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Aliasing (in general)Nyquist theorem: to accurately reconstruct a signal, the signal must be sampled at a rate greater than or equal to two times the highest frequency contained in the signal

Page 28: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Aliasing in Computer Graphics

One scanline

Page 29: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Aliasing in CG -2

Page 30: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Aliasing in CG -3

Page 31: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Aliasing Artifact

Page 32: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Anti-aliasing by Supersampling

More than one samples per pixel

Adaptive supersampling

Supersampling with jitter

Page 33: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 34: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 35: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 36: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph

Ray-object intersection

Page 37: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 38: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 39: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 40: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 41: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph
Page 42: Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph