Unformatted text preview:

University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell Ray TracingUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 2 Reading ! Required: ! 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 3 Geometric optics ! Modern 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 4 Synthetic pinhole camera ! The 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 5 Eye vs. light ray tracing ! Where 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 6 Precursors to ray tracing ! Local illumination ! Cast one eye ray, then shade according to light ! Appel (1968) ! Cast one eye ray + one ray to lightUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 7 Whitted ray-tracing algorithm ! In 1980, Turner Whitted introduced ray tracing to the graphics community. ! Combines eye ray tracing + rays to light ! Recursively traces rays ! Algorithm: 1. For each pixel, trace a primary ray in direction V to the first visible surface. 2. For each intersection, trace secondary rays: ! Shadow rays in directions Li to light sources ! Reflected ray in direction R. ! Refracted ray or transmitted ray in direction T.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 8 Whitted algorithm (cont'd) Let's look at this in stages:University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 9 Shading ! A ray is defined by an origin P and a unit direction d and is parameterized by t: ! P + td ! Let I(P, d) be the intensity seen along that ray. Then: ! I(P, d) = Idirect + Ireflected + Itransmitted ! where ! Idirect 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 10 Reflection and transmission ! Law of reflection: ! θi = θr ! Snell's law of refraction: ! ηi sinθI = ηt sin θt ! where ηi , ηt are indices of refraction.University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 11 Total Internal Reflection ! The 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 12 Error 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!Reflected and refracted rays ! For incoming ray P(t)=P+td ! Compute input cosine and sine vectors Ci and Si ! Reflected ray vector R = Ci + Si ! Compute output cosine and sine vectors Ct and St ! Transmitted ray vector T = Ct + St University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 13 University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 14 Ray-tracing pseudocode We 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 for end functionUniversity of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell 15 Ray-tracing


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?