Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required:

Similar documents
Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required: Watt, sections , (handout) Further reading:

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Geometric optics. The University of Texas at Austin CS384G Computer Graphics Don Fussell

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

Lecture 10: Ray tracing

Supplement to Lecture 16

Intro to Ray-Tracing & Ray-Surface Acceleration

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

Implementation Issues

Photorealism: Ray Tracing

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Illumination. Courtesy of Adam Finkelstein, Princeton University

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

Questions??? Announcements Assignment 3 due today

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Reading. 8. Distribution Ray Tracing. Required: Watt, sections 10.6,14.8. Further reading:

Physically Realistic Ray Tracing

Distribution Ray Tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

MIT Ray Tracing Ray Tracing

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

Sung-Eui Yoon ( 윤성의 )

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

Ray Tracing. Last Time? Reading for Today. Reading for Today

COMP371 COMPUTER GRAPHICS

CS 4620 Midterm, March 21, 2017

COMP 175 COMPUTER GRAPHICS. Lecture 11: Recursive Ray Tracer. COMP 175: Computer Graphics April 9, Erik Anderson 11 Recursive Ray Tracer

Reading. Distribution Ray Tracing. BRDF, revisited. Pixel anti-aliasing. ω in. Required: Shirley, section Further reading:

CS-184: Computer Graphics. Administrative

Ray Tracing I: Basics

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

Physics 202, Lecture 23

CPSC GLOBAL ILLUMINATION

Lecture Ray Model of Light. Physics Help Q&A: tutor.leiacademy.org

Graphics 2009/2010, period 1. Lecture 8: ray tracing

CS 325 Computer Graphics

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Ray-tracing Cont. Ray-tracing

Ray tracing. EECS 487 March 19,

CS348B Lecture 2 Pat Hanrahan, Spring Greeks: Do light rays proceed from the eye to the light, or from the light to the eye?

Shading, Advanced Rendering. Week 7, Wed Feb 28

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Outline The Refraction of Light Forming Images with a Plane Mirror 26-3 Spherical Mirror 26-4 Ray Tracing and the Mirror Equation

PHYS 219 General Physics: Electricity, Light and Modern Physics

CS5620 Intro to Computer Graphics

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

Computer Graphics. Shi-Min Hu. Tsinghua University

Indirect Illumination

A Little Background. Motivation. Motivation

SUMMARY. CS380: Introduction to Computer Graphics Ray tracing Chapter 20. Min H. Kim KAIST School of Computing 18/05/29. Modeling

Light. Electromagnetic wave with wave-like nature Refraction Interference Diffraction

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Lighting and Reflectance COS 426

Lecture 11: Ray tracing (cont.)

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Ray-Tracing. Misha Kazhdan

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Indirect Illumination

Ray Tracing. Kjetil Babington

Reflection and Shading

Chapter 26 Geometrical Optics

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

Illumination. Thomas Funkhouser Princeton University C0S 426, Fall 2000

Raytracing. COSC 4328/5327 Scott A. King

Chapter 24. Geometric optics. Assignment No. 11, due April 27th before class: Problems 24.4, 24.11, 24.13, 24.15, 24.24

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

specular diffuse reflection.

782 Schedule & Notes

6.837 Introduction to Computer Graphics Final Exam Tuesday, December 20, :05-12pm Two hand-written sheet of notes (4 pages) allowed 1 SSD [ /17]

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

COMP 4801 Final Year Project. Ray Tracing for Computer Graphics. Final Project Report FYP Runjing Liu. Advised by. Dr. L.Y.

Chapter 26 Geometrical Optics

The Rendering Equation and Path Tracing

Illumination Modelling

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lecture 14: Refraction

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Illumination Models and Surface-Rendering Methods. Chapter 10

CS3500 Computer Graphics Module: Lighting and Shading

Computer Graphics. Illumination and Shading

CS 465 Program 5: Ray II

Comp 410/510 Computer Graphics. Spring Shading

Computer Vision Systems. Viewing Systems Projections Illuminations Rendering Culling and Clipping Implementations

Lighting and Shading

Ray Tracing. Last Time? Today. Ray Casting. Durer s Ray Casting Machine. Reading for Today

Phys102 Lecture 21/22 Light: Reflection and Refraction

Distribution Ray Tracing

Ray optics! Postulates Optical components GRIN optics Matrix optics

3D Rendering. Course Syllabus. Where Are We Now? Rendering. 3D Rendering Example. Overview. Rendering. I. Image processing II. Rendering III.

Lecture Outline Chapter 26. Physics, 4 th Edition James S. Walker. Copyright 2010 Pearson Education, Inc.

EDAN30 Photorealistic Computer Graphics. Ray tracing. Michael Doggett Department of Computer Science Lund university. Copyright 2011 Michael Doggett

Lecture 7 Notes: 07 / 11. Reflection and refraction

Transcription:

Reading Required: Watt, sections 1.3-1.4, 12.1-12.5.1 (handout) Triangle intersection handout Further reading: Ray Tracing Watt errata on syllabus page, needed if you work from his book instead of the handout. T. Whitted. An improved illumination model for shaded display. Communications of the ACM 23(6), 343-349, 1980. A. Glassner. An Introduction to Ray Tracing. Academic Press, 1989. K. Turkowski, Properties of Surface Normal Transformations, Graphics Gems, 1990, pp. 539-547. 1 2 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. Eye vs. light ray tracing Where does light begin? At the light: light ray tracing (a.k.a., forward ray tracing or photon tracing) 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). At the eye: eye ray tracing (a.k.a., backward ray tracing) 3 We will generally follow rays from the eye into the scene. 4

Precursors to ray tracing Local illumination Cast one eye ray, then shade according to light 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 Appel (1968) Cast one eye ray + one ray to light 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 L i to light sources Reflected ray in direction R. Refracted ray or transmitted ray in direction T. 5 6 Whitted algorithm (cont'd) Let's look at this in stages: Ray casting and local illumination Now let s actually build the ray tracer in stages. We ll start with ray casting and local illumination: 7 8

Direct illumination Ray-tracing pseudocode We build a ray traced image by casting rays through each of the pixels. 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 a ray. Then: where I(P, d) = I direct I direct is computed from the Phong model function traceimage (scene): for each pixel (i,j) in image A = pixeltoworld(i,j) P = COP d = (A - P)/ A P I(i,j) = traceray(scene, P, d) end for function traceray(scene, P, d): (t, N, mtrl) scene.intersect (P, d) Q ray (P, d) evaluated at t I = shade( ) return I 9 10 Shading pseudocode Next, we need to calculate the color returned by the shade function. Ray casting with shadows Now we ll add shadows by casting shadow rays: function shade(mtrl, scene, Q, N, d): I mtrl.k e + mtrl. k a * I a for each light source L do: atten = L -> distanceattenuation( ) I I + atten*(diffuse term + specular term) end for return I 11 12

Shading with shadows To include shadows, we need to modify the shade function: function shade(mtrl, scene, Q, N, d): I mtrl.k e + mtrl. k a * I a for each light source L do: atten = L -> distanceattenuation( Q ) * L -> shadowattenuation( ) I I + atten*(diffuse term + specular term) end for return I Shadow attenuation Computing a shadow can be as simple as checking to see if a ray makes it to the light source. For a point light source: function PointLight::shadowAttenuation(scene, P) d = (this.position - P).normalize() (t, N, mtrl) scene.intersect(p, d) Compute t light if (t < t light ) then: atten = 0 else atten = 1 end if return atten 13 14 Shadow attenuation (cont d) Q: What if there are transparent objects along a path to the light source? [Suppose for simplicity that each object has a multiplicative transparency constant, k t.] Photon mapping Combine light ray tracing (photon tracing) and eye ray tracing: to get photon mapping. Renderings by Henrik Wann Jensen: http://graphics.ucsd.edu/~henrik/ images/caustics.html 15 16

Shading in Trace The Trace project uses a version of the Phong shading equation we derived in class, with two modifications: Recursive ray tracing with reflection Now we ll add reflection: Shadow attenuation is clamped to be at least 1: Shadow attenuation A shadow is included. Here s what it should look like: I=k +k L e a a shadow dist + A L j A j k ( NL ) +k ( VR ) j dist A j 1 = min 1, 2 a+bd+cd j j j j j ns j d j + s j + I.e., we are not using the OpenGL shading equation, which is somewhat different. Note: the R here is the reflection of the light about the surface normal. 17 18 Shading with reflection Reflection Let I(P, d) be the intensity seen along a ray. Then: where I(P, d) = I direct + I reflected I direct is computed from the Phong model I reflected = k r I (Q, R) Law of reflection: θ i = θ r R is co-planar with d and N. Typically, we set k r = k s. 19 20

Ray-tracing pseudocode, revisited Terminating recursion function traceray(scene, P, d): (t, N, mtrl) scene.intersect (P, d) Q ray (P, d) evaluated at t I = shade(scene, mtrl, P, N, -d) R = reflectdirection( ) I I + mtrl.k r traceray(scene, Q, R) return I Q: How do you bottom out of recursive ray tracing? Possibilities: 21 22 Whitted ray tracing Shading with reflection and refraction Finally, we ll add refraction, giving us the Whitted ray tracing model: Let I(P, d) be the intensity seen along a ray. Then: where I(P, d) = I direct + I reflected + I transmitted I direct is computed from the Phong model I reflected = k r I (Q, R) I transmitted = k t I (Q, T) Typically, we set k r = k s and k t = 1 k s (or 0, if opaque). [Generally, k r and k t are determined by Fresnel reflection, which depends on angle of incidence and changes the polarization of the light.] 23 24

Refraction Snell's law of refraction: η i sinθ i = η t sin θ t Total Internal Reflection The equation for the angle of refraction can be computed from Snell's law: where η i, η t are indices of refraction. In all cases, R and T are coplanar with d and N. The index of refraction is material dependent. It can also vary with wavelength, an effect called dispersion that explains the colorful light rainbows from prisms. (We will generally assume no dispersion.) 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. 25 26 Watt handout Watt uses different symbols. Here is the translation between them: I= d φ = θi θ = θr µ 1 = ηi µ = η Also, Watt had some important errors that have already been corrected in the handout. 2 But, if you re consulting the original text, be sure to refer to the errata posted on the syllabus for corrections. r Ray-tracing pseudocode, revisited function traceray(scene, P, d): (t, N, mtrl) scene.intersect (P, d) Q ray (P, d) evaluated at t I = shade(scene, mtrl, P, N, -d) R = reflectdirection(n, -d) I I + mtrl.k r traceray(scene, Q, R) if ray is entering object then n_i = index_of_air n_t = mtrl.index else n_i = mtrl.index n_t = index_of_air if (nottir ( )) then T = refractdirection ( ) I I + mtrl.k t traceray(scene, Q, T) end if return I 27 28

Terminating recursion, incl. refraction Q: Now how do you bottom out of recursive ray tracing? Intersecting rays with spheres Now we ve done everything except figure out what that scene.intersect(p, d) function does. Mostly, it calls each object to find out the t value at which the ray intersects the object. Let s start with intersecting spheres Given: The coordinates of a point along a ray passing through P in the direction d are: x = Px + td y = Py + td z = P + td z A unit sphere S centered at the origin defined by the equation: x y z 29 Find: The t at which the ray intersects S. 30 Intersecting rays with spheres Ray-plane intersection Solution by substitution: where 2 2 2 x + y + z 1= 0 2 2 2 ( Px + tdx) + ( Py + tdy) + ( Pz + tdz) 1= 0 2 at + bt + c = 0 2 2 2 a= dx + dy + dz b= 2( Px dx + Pydy + Pzdz) 2 2 2 c= P + P + P 1 x y z Q: What are the solutions of the quadratic equation in t and what do they mean? We can write the equation of a plane as: ax + by + cz = d The coefficients a, b, and c form a vector that is normal to the plane, n = [a bc] T. Thus, we can rewrite the plane equation as: We can solve for the intersection parameter (and thus the point): Q: What is the normal to the sphere at a point (x,y,z) on the sphere? 31 32

Ray-triangle intersection 3D inside-outside test One way to do this inside-outside test, is to see if Q lies on the left side of each edge as we move counterclockwise around the triangle. To intersect with a triangle, we first solve for the equation of its supporting plane. How might we compute the (un-normalized) normal? Given this normal, how would we compute d? How might we use cross products to do this? Using these coefficients, we can solve for Q. Now, we need to decide if Q is inside or outside of the triangle. 33 34 2D inside-outside test Without loss of generality, we can perform this same test after projecting down a dimension: Barycentric coordinates As we ll see in a moment, it is often useful to represent Q as an affine combination of A, B, and C: Q= α A+ βb+ γc where: α + β + γ = 1 We call α, β, and γ, the barycentric coordinates of Q with respect to A, B, and C. If Q is inside of A B C, then Q is inside of ABC. Why is this projection desirable? Which axis should you project away? 35 36

Barycentric coordinates Given a point Q that is inside of triangle ABC, we can solve for Q s barycentric coordinates in a simple way: Area( QBC) Area( AQC) Area( ABQ) α = β = γ = Area( ABC) Area( ABC) Area( ABC) Interpolating vertex properties The barycentric coordinates can also be used to interpolate vertex properties such as: material properties texture coordinates normals For example: k ( Q) = αk ( A) + βk ( B) + γk ( C) d d d d How can cross products help here? Interpolating normals, known as Phong interpolation, gives triangle meshes a smooth shading appearance. (Note: don t forget to normalize interpolated normals.) In the end, these calculations can be performed in the 2D projection as well! 37 38 Epsilons Due to finite precision arithmetic, we do not always get the exact intersection at a surface. Q: What kinds of problems might this cause? Summary What to take home from this lecture: The meanings of all the boldfaced terms. Enough to implement basic recursive ray tracing. How reflection and transmission directions are computed. How ray--object intersection tests are performed on spheres, planes, and triangles How barycentric coordinates within triangles are computed How ray epsilons are used. Q: How might we resolve this? 39 40