ray tracing primer ref: siggraph hypergraphhypergraph

Post on 25-Dec-2015

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Ray Tracing Primer

Ref: SIGGRAPH HyperGraph

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

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

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

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.

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.

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.

Recursive Reflection

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.

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.

Computing Reflection

nnIIr

nnIInnIr

2

)()(

Refraction

Ray-Object Intersection

Ray-sphereRay-quadricRay-planeRay-polygonRay-box

See Funkhouser notes on ray castSee Funkhouser notes on ray cast

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.

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

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

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.

Fast square root

Aliasing Problems

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

Aliasing in Computer Graphics

One scanline

Aliasing in CG -2

Aliasing in CG -3

Aliasing Artifact

Anti-aliasing by Supersampling

More than one samples per pixel

Adaptive supersampling

Supersampling with jitter

Ray-object intersection

top related