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

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

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

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

Ray Tracing. Brian Curless CSEP 557 Fall 2016

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

Intro to Ray-Tracing & Ray-Surface Acceleration

Photorealism: Ray Tracing

Sung-Eui Yoon ( 윤성의 )

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

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

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

Lecture 10: Ray tracing

Supplement to Lecture 16

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

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

Ray-Tracing. Misha Kazhdan

CS5620 Intro to Computer Graphics

Implementation Issues

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

Ray Tracing. CPSC 453 Fall 2018 Sonny Chan

CPSC GLOBAL ILLUMINATION

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

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

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

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

COMP371 COMPUTER GRAPHICS

Lighting and Shading

CS 4620 Midterm, March 21, 2017

Ray-tracing Cont. Ray-tracing

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

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]

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

Questions??? Announcements Assignment 3 due today

Chapter 26 Geometrical Optics

CS 325 Computer Graphics

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

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

Geometric Optics. The Law of Reflection. Physics Waves & Oscillations 3/20/2016. Spring 2016 Semester Matthew Jones

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

Ray tracing. EECS 487 March 19,

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

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

Computer Graphics. Shi-Min Hu. Tsinghua University

Reflection and Shading

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

Computer Graphics. Illumination and Shading

PHYS 219 General Physics: Electricity, Light and Modern Physics

Ray Tracing. Quiz Discussion. Announcements: Final Projects. Last Time? Durer s Ray Casting Machine. Today

Shading, Advanced Rendering. Week 7, Wed Feb 28

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

Chapter 32 Light: Reflection and Refraction. Copyright 2009 Pearson Education, Inc.

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

ECE-161C Cameras. Nuno Vasconcelos ECE Department, UCSD

Reflection and Refraction of Light

Raytracing. COSC 4328/5327 Scott A. King

CS-184: Computer Graphics. Administrative

specular diffuse reflection.

CS 130 Exam I. Fall 2015

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

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

Mach band effect. The Mach band effect increases the visual unpleasant representation of curved surface using flat shading.

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Chapter 26 Geometrical Optics

Light & Optical Systems Reflection & Refraction. Notes

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

Phys102 Lecture 21/22 Light: Reflection and Refraction

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

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

At the interface between two materials, where light can be reflected or refracted. Within a material, where the light can be scattered or absorbed.

Optics. a- Before the beginning of the nineteenth century, light was considered to be a stream of particles.

Illumination Modelling

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

AP Physics: Curved Mirrors and Lenses

Lecture 11: Ray tracing (cont.)

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

Ray Optics. Lecture 23. Chapter 23. Physics II. Course website:

Chapter 23. Geometrical Optics (lecture 1: mirrors) Dr. Armen Kocharian

CS 465 Program 5: Ray II

CS770/870 Spring 2017 Color and Shading

Ray Tracing. Announcements: Quiz. Last Time? Today. Durer s Ray Casting Machine. Ray Casting

Dispersion (23.5) Neil Alberding (SFU Physics) Physics 121: Optics, Electricity & Magnetism Spring / 17

Introduction to Visualization and Computer Graphics

Ray Tracing I: Basics

Physically Realistic Ray Tracing

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

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

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

Chapter 18 Ray Optics

INTRODUCTION REFLECTION AND REFRACTION AT BOUNDARIES. Introduction. Reflection and refraction at boundaries. Reflection at a single surface

Last week. Machiraju/Zhang/Möller

Ray Tracer Due date: April 27, 2011

Raytracing CS148 AS3. Due :59pm PDT

Lecture 7 Notes: 07 / 11. Reflection and refraction

Physics 202, Lecture 23

Complex Shading Algorithms

FLAP P6.2 Rays and geometrical optics COPYRIGHT 1998 THE OPEN UNIVERSITY S570 V1.1

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

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

Light: Geometric Optics

Transcription:

Ray Tracing

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). 2

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. 3

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. 4

Precursors to ray tracing Local illumination Cast one eye ray, then shade according to light Appel (1968) Cast one eye ray + one ray to light 5

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 L i to light sources Reflected ray in direction R. Refracted ray or transmitted ray in direction T. 6

Whitted algorithm (cont'd) Let's look at this in stages: 7

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) = I direct + I reflected + I transmitted where 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. 8

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. 9

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. 10

Reflected and transmitted rays For incoming ray P(t)=P+td Compute input cosine and sine vectors C i and S i Reflected ray vector R = C i + S i Compute output cosine and sine vectors C t and S t Transmitted ray vector T = C t + S t 11

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 function 12

Ray-tracing pseudocode, cont d function traceray(scene, P, d): (t, N, mtrl) scene.intersect (P, d) Q! ray (P, d) evaluated at t I = shade(q, N, mtrl, scene) 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 (mtrl.k_t > 0 and nottir (n_i, n_t, N, -d)) then T = refractdirection (n_i, n_t, N, -d) I I + mtrl.k t * traceray(scene, Q, T) end if return I end function 13

Terminating recursion Q: How do you bottom out of recursive ray tracing? Possibilities: 14

Shading pseudocode Next, we need to calculate the color returned by the shade function. function shade(mtrl, scene, Q, N, d): I mtrl.k e + mtrl. k a * scene->i a for each light source L do: atten = L -> distanceattenuation(q) atten += L -> shadowattenuation(scene, Q) I I + atten*(diffuse term + spec term) end for return I end function 15

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 = (L.position - P).normalize() (t, N, mtrl) = scene.intersect(p, d) Q = ray.intersection(t) if Q is before the light source then: atten = 0 else atten = 1 end if return atten end function Q: What if there are transparent objects along a path to the light source? 16

Ray-plane intersection We can write the equation of a plane as: ax + by + cz + d = 0 The coefficients a, b, and c form a vector that is normal to the plane, n = [a b c] T. Thus, we can re-write the plane equation as: n p(t) + d = 0 ( ) + d = 0 n P + td We can solve for the intersection parameter (and thus the point): t = n P + d n d 17

Ray-triangle intersection To intersect with a triangle, we first solve for the equation of its supporting plane: n = (A C) (B C) d = (n A) Then, we need to decide if the point is inside or outside of the triangle. Solution 1: compute barycentric coordinates from 3D points. What do you do with the barycentric coordinates? 18

Barycentric coordinates A set of points can be used to create an affine frame. Consider a triangle ABC and a point p: A p C B We can form a frame with an origin C and the vectors from C to the other vertices: u = A C v = B C t = C We can then write P in this coordinate frame p = αu + βv + t The coordinates (α, β, γ) are called the barycentric coordinates of p relative to A, B, and C. 19

Computing barycentric coordinates For the triangle example we can compute the barycentric coordinates of P: % (% α( % ( Cramer s rule gives the solution: A x B x C x p x ' *' * ' * α A + βb + γc = ' A y B y C y *' β * = ' p y * &' 1 1 1 )* &' γ )* &' 1 )* p x B x C x A x p x C x A x B x p x α = p y B y C y 1 1 1 A x B x C x β = A y p y C y 1 1 1 A x B x C x γ = A y B y p y 1 1 1 A x B x C x A y B y C y 1 1 1 A y B y C y 1 1 1 A y B y C y 1 1 1 Computing the determinant of the denominator gives: B x C y B y C x + A y C x A x C y + A x B y A y B x 20

Cross products Consider the cross-product of two vectors, u and v. What is the geometric interpretation of this cross-product? A cross-product can be computed as: u v = i j k u x u y u z v x v y v z = (u y v z u z v y )i + (u z v x u x v z )j + (u x v y u y v x )k $ u y v z u z v y ' & ) = & u z v x u x v z ) % & u x v y u y v x ( ) What happens when u and v lie in the x-y plane? What is the area of the triangle they span? 21

Barycentric coords from area ratios Now, let s rearrange the equation from two slides ago: B x C y B y C x + A y C x A x C y + A x B y A y B x = (B x A x )(C y A y ) (B y A y )(C x A x ) The determinant is then just the z-component of (B-A) (C-A), which is two times the area of triangle ABC! Thus, we find: α = SArea(pBC) SArea(ABC) β = SArea(ApC) SArea(ABC) γ = SArea(ABp) SArea(ABC) Where SArea(RST) is the signed area of a triangle, which can be computed with cross-products. 22

Ray-triangle intersection Solution 2: project down a dimension and compute barycentric coordinates from 2D points. Why is solution 2 possible? Why is it legal? Why is it desirable? Which axis should you project away? 23

Interpolating vertex properties The barycentric coordinates can also be used to interpolate vertex properties such as: material properties texture coordinates normals For example: k d (Q) = αk d (A) + βk d (B) + γ k d (C) Interpolating normals, known as Phong interpolation, gives triangle meshes a smooth shading appearance. (Note: don t forget to normalize interpolated normals.) 24

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? Q: How might we resolve this? 25

Intersecting with xformed geometry In general, objects will be placed using transformations. What if the object being intersected were transformed by a matrix M? Apply M -1 to the ray first and intersect in object (local) coordinates! 26

Intersecting with xformed geometry The intersected normal is in object (local) coordinates. How do we transform it to world coordinates? 27