Unformatted text preview:

Ray TracingReadingGeometric opticsSynthetic pinhole cameraEye vs. light ray tracingPrecursors to ray tracingWhitted ray-tracing algorithmWhitted algorithm (cont'd)ShadingReflection and transmissionTotal Internal ReflectionError in Watt!!Ray-tracing pseudocodeRay-tracing pseudocode, cont’dTerminating recursionShading pseudocodeShadow attenuationRay-plane intersectionRay-triangle intersectionSlide 20Interpolating vertex propertiesEpsilonsIntersecting with xformed geometrySlide 24University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don FussellRay TracingUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 2ReadingRequired:Watt, sections 1.3-1.4, 12.1-12.5.1.T. Whitted. An improved illumination model for shaded display. Communications of the ACM 23(6), 343-349, 1980. [In the reader.]Further reading:A. Glassner. An Introduction to Ray Tracing. Academic Press, 1989. [In the lab.]K. Turkowski, “Properties of Surface Normal Transformations,” Graphics Gems, 1990, pp. 539-547. [In the reader.]University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 3Geometric opticsModern theories of light treat it as both a wave and a particle. We will take a combined and somewhat simpler view of light – the view of geometric optics.Here are the rules of geometric optics:Light is a flow of photons with wavelengths. We'll call these flows “light rays.”Light rays travel in straight lines in free space.Light rays do not interfere with each other as they cross.Light rays obey the laws of reflection and refraction.Light rays travel form the light sources to the eye, but the physics is invariant under path reversal (reciprocity).University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 4Synthetic pinhole cameraThe most common imaging model in graphics is the synthetic pinhole camera: light rays are collected through an infinitesimally small hole and recorded on an image plane.For convenience, the image plane is usually placed in front of the camera, giving a non-inverted 2D projection (image).Viewing rays emanate from the center of projection (COP) at the center of the lens (or pinhole).The image of an object point P is at the intersection of the viewing ray through P and the image plane.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 5Eye vs. light ray tracingWhere does light begin?At the light: light ray tracing (a.k.a., forward ray tracing or photon tracing)At the eye: eye ray tracing (a.k.a., backward ray tracing)We will generally follow rays from the eye into the scene.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 6Precursors to ray tracingLocal illuminationCast one eye ray,then shade according to lightAppel (1968)Cast one eye ray + one ray to lightUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 7Whitted ray-tracing algorithmIn 1980, Turner Whitted introduced ray tracing to the graphics community.Combines eye ray tracing + rays to lightRecursively traces raysAlgorithm: 1. For each pixel, trace a primary ray in direction V to the first visible surface.2. For each intersection, trace secondary rays:1. Shadow rays in directions Li to light sources2. Reflected ray in direction R.3. Refracted ray or transmitted ray in direction T.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 8Whitted algorithm (cont'd)Let's look at this in stages:University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 9ShadingA ray is defined by an origin P and a unit direction d and is parameterized by t:P + tdLet I(P, d) be the intensity seen along that ray. Then:I(P, d) = Idirect + Ireflected + ItransmittedwhereIdirect is computed from the Phong model Ireflected = kr I (Q, R) Itransmitted = ktI (Q, T) Typically, we set kr = ks and kt = 1 – ks .University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 10Reflection and transmissionLaw of reflection:i = rSnell's law of refraction:i sinI = t sin twhere i , t are indices of refraction.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 11Total Internal ReflectionThe equation for the angle of refraction can be computed from Snell's law:What happens when i > t?When t is exactly 90°, we say that I has achieved the “critical angle” c .For I > c , no rays are transmitted, and only reflection occurs, a phenomenon known as “total internal reflection” or TIR.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 12Error in Watt!!In order to compute the refracted direction, it is useful to compute the cosine of the angle of refraction in terms of the incident angle and the ratio of the indices of refraction. On page 24 of Watt, he develops a formula for computing this cosine. Notationally, he uses  instead of  for the index of refraction in the text, but uses  in Figure 1.16(!?), and the angle of incidence is  and the angle of refraction is .Unfortunately, he makes a grave error in computing cosHe also has some errors in the figures on the same page. Consult the errata for important corrections!University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 13Ray-tracing pseudocodeWe build a ray traced image by casting rays through each of the pixels.function traceImage (scene):for each pixel (i,j) in image S = pixelToWorld(i,j) P = COP d = (S - P)/|| S – P|| I(i,j) = traceRay(scene, P, d)end forend functionUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 14Ray-tracing pseudocode, cont’dfunction traceRay(scene, P, d):(t, N, mtrl)  scene.intersect (P, d)Q  ray (P, d) evaluated at tI = shade(q, N, mtrl, scene)R = reflectDirection(N, -d)I  I + mtrl.kr  traceRay(scene, Q, R)if ray is entering object then n_i = index_of_air n_t = mtrl.indexelse n_i = mtrl.index n_t = index_of_airif (mtrl.k_t > 0 and notTIR (n_i, n_t, N, -d)) then T = refractDirection (n_i, n_t, N, -d) I  I + mtrl.kt  traceRay(scene, Q, T)end ifreturn Iend functionUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 15Terminating recursionQ: How do


View Full Document

UT CS 384G - Lecture Notes

Documents in this Course
Shading

Shading

27 pages

Shading

Shading

27 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?