Reflections and Refractions in Ray Tracing

Similar documents
You can take the arccos of both sides to get θ by itself.

PHY 112: Light, Color and Vision. Lecture 11. Prof. Clark McGrew Physics D 134. Review for Exam. Lecture 11 PHY 112 Lecture 1

11.2 Refraction. December 10, Wednesday, 11 December, 13

Ch. 26: Geometrical Optics

Refraction and Lenses. Honors Physics

Reflection & refraction

Reflection and Refraction of Light

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

Light. Form of Electromagnetic Energy Only part of Electromagnetic Spectrum that we can really see

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

Physics 202, Lecture 23

1. What is the law of reflection?

Physics 102: Lecture 17 Reflection and Refraction of Light

Physics 102: Lecture 17 Reflection and Refraction of Light

Algebra Based Physics

Ray Optics. Ray model Reflection Refraction, total internal reflection Color dispersion Lenses Image formation Magnification Spherical mirrors

Polar Coordinates. 2, π and ( )

CALCULUS II. Parametric Equations and Polar Coordinates. Paul Dawkins

Physics. Bending Light ID: 8878

GEOMETRIC OPTICS. LENSES refract light, so we need to know how light bends when entering and exiting a lens and how that interaction forms an image.

Physics 1C. Lecture 25B. "There are two ways of spreading light: to be the candle or the mirror that reflects it." --Edith Wharton

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

Chapter 5 Mirror and Lenses

IJSO Training: Light and Colour Mini-experiment Refractive Index and Snell s Law

Physics 11 Chapter 18: Ray Optics

θ =θ i r n sinθ = n sinθ

Lecture 7 Notes: 07 / 11. Reflection and refraction

Refraction Ch. 29 in your text book

Lighting and Shading

specular diffuse reflection.

No Brain Too Small PHYSICS

LIGHT. Speed of light Law of Reflection Refraction Snell s Law Mirrors Lenses

speed of light in vacuum = speed of light in the material

Chapter 12 Notes: Optics

Refraction: Snell's Law. October 26, 2010

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

(Equation 24.1: Index of refraction) We can make sense of what happens in Figure 24.1

SM 2. Date: Section: Objective: The Pythagorean Theorem: In a triangle, or

1.7 Limit of a Function

Lecture 19: All Together with Refraction

Episode 317: Reflection and refraction of waves

Experiment 3: Reflection

10.2 Calculus with Parametric Curves

Refraction and Dispersion

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

Today s Topic: Refraction / Snell s Law

Part 1: Plane Mirrors!

REFLECTION & REFRACTION

Purpose: To determine the index of refraction of glass, plastic and water.

P H Y L A B 1 : G E O M E T R I C O P T I C S

COMP371 COMPUTER GRAPHICS

Efficacy of Numerically Approximating Pi with an N-sided Polygon

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

Ray Tracing. CS116B Chris Pollett Apr 20, 2004.

Unit 9 Light & Optics

Chapter 5 Mirrors and Lenses

OPTICAL POTPOURRI (L-21)

Chapter 18 Ray Optics

Home Lab 7 Refraction, Ray Tracing, and Snell s Law

Name Section Date. Experiment Reflection and Refraction

Reflection, Refraction and Polarization of Light

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

Recap: Refraction. Amount of bending depends on: - angle of incidence - refractive index of medium. (n 2 > n 1 ) n 2

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

M = h' h = #i. n = c v

Lab 10 - GEOMETRICAL OPTICS

Reflection and Refraction

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

The Ray model of Light. Reflection. Class 18

Calculus II. Step 1 First, here is a quick sketch of the graph of the region we are interested in.

The path of light is bent. Refraction and Lenses 5/3/2018. The angle of incidence equals the angle of reflection. Not so for refraction.

Chapter 26 Geometrical Optics

Supplement to Lecture 16

Geometrical Optics. Name ID TA. Partners. Date Section. Please do not scratch, polish or touch the surface of the mirror.

Lecture 10: Ray tracing

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

4.5 Images Formed by the Refraction of Light

Wallace Hall Academy

Light: Geometric Optics

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

Unit 11 Light and Optics Holt Chapter 14 Student Outline Light and Refraction

How can the body make sound bend?

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

Reflection and Refraction

Introduction: The Nature of Light

General Physics II. Mirrors & Lenses

EE119 Homework 3. Due Monday, February 16, 2009

Figure 27a3See Answer T5. A convex lens used as a magnifying glass.

Unit 2: Trigonometry. This lesson is not covered in your workbook. It is a review of trigonometry topics from previous courses.

CALCULATING SNELL S LAW

GRADE 11 SUTHERLAND HIGH SCHOOL 2018

Exp No.(9) Polarization by reflection

Reflection and Refraction

The liquid s index of refraction is. v liquid = nm = = 460 nm 1.38

Chapter 7: Geometrical Optics. The branch of physics which studies the properties of light using the ray model of light.

Reflection, Refraction and Polarization of Light Physics 246

Chapter 3. Physical phenomena: plane parallel plate. This chapter provides an explanation about how rays of light physically behave when

The Rendering Equation. Computer Graphics CMU /15-662

TEAMS National Competition High School Version Photometry Solution Manual 25 Questions

16/05/2016. Book page 110 and 112 Syllabus 3.18, Snell s Law. cgrahamphysics.com 2016

Transcription:

Reflections and Refractions in Ray Tracing Bram de Greve (bram.degreve@gmail.com) 10th October 2004 When you re writing a ray tracer, soon or late you ll stumble on the problem of reflection and refraction. When you want to visualize mirror-like objects, you need to reflect our viewing ray. To simulate a lens, you need refraction. While most people have heard of the law of reflection[1] and Snell s law[2], they often have difficulties how to actually calculate the direction vectors of the reflected and refracted rays. And when googling around for info, you find a lot of theory but only a little of practice. In this tutorial, I ll try to show you how to apply the theory in practice. In the first section, we ll describe the setup. We ll name the used variables and put some conditions on them. In the two sections following on that, we ll derive equations for the reflected and refracted direction vectors based on the law of reflection and Snell s law. I know it s a bit of theory, but it isn t too hard. If you re a bit scared, you can skip to the conclusions though. 1 The Beginnings In Figure 1 we have an interface (= surface) between two materials with different indexes of refraction η 1 and. These two materials could be air (η 1) and water (20 C: η 1.33). It does not matter which of η 1 and is the greater one. η 1 could be air and water, or vice versa. All that counts is that η 1 is the index of refraction of the material you come from, and of the material you go to (in case of refraction). This is a very important concept and sometimes misunderstood. The direction vector of the incident ray (= incoming ray) is i, and we assume this vector is normalized. The direction vectors of the reflected and transmitted rays are r and t and will be calculated in this tutorial. These vectors are (or will be) normalized as well. We also have the normal vector n, orthogonal to the interface and points towards the first material η 1. Again, n is normalized. i = r = t = n = 1 (1) The direction vectors of the rays can be split in components orthogonal and parallel to the interface. We call these the normal part v and the tangent part v of a vector v (in this paragraph I ll use the generic vector v, but the story really is for i, r and t ). The normal part v can be found by orthogonal projection[3] on n. Taking in account (1), this is: 1

n i i r r i r 1 i r 2 t t t t Figure 1: the situation 2

v = v n n 2 n = ( v n ) n (2) The tangent part v is the difference between v and v : The dot product between v and v is zero: v = v v (3) v v = v v v v = v ( v n ) n ( v n ) 2 n n = ( v n ) 2 ( v n ) 2 n 2 = 0 (4) That proves two things: v and v are orthogonal, and v is indeed an orthogonal projection on n. Hence, we can apply Pythagoras: v v (5) v 2 = v 2 + v 2 (6) Furthemore, all normal parts are parallel to each other and n. The tangent parts are parallel as well. i r t n (7) i r t (8) The angles of incidence, reflection and refraction are θ i, θ r and θ t and they are the smallest positive angles between the respective rays and the normal vector n. Basic trigonometry and equations (1) and (5) tell us for any of this angles θ the following properties apply: In fact, (9) says nothing else than 1 : cosθ = v v = v (9) v sinθ = v = v (10) Now we had all that, we can start with the fun stuff. 1 The used sign in (11) depends on the relative orientation of v and n. cosθ = ± v n (11) 3

2 Reflection We start with the easiest of both problems: the calculation of the reflected ray. In case of specular reflection, this is very easy: the law of reflection says that the angle of incidence θ i is equal to the angle of reflection θ r [1]. Using equations (9) and (10), this law tells us: θ r = θ i (12) r = cosθ r = cosθ i = i (13) r = sinθ r = sinθ i = i (14) Because of (7) and (8) and Figure 1, we can figure out that both parts are: r = i (15) r = i (16) After summation, we get the desired direction of reflection: r = r + r = i i (17) By using equations (2) and (3), we can work this out to: r = i i = [ i ( i n ) n ] ( i n ) n = i 2 ( i n ) n (18) That s it! But can we be sure r calculated in (18) is normalized as requested? Yes, using (6), (13), (14) and (1) we have: r 2 = r 2 + r 2 = i 2 + i 2 = i 2 = 1 (19) And that s very cool, since we can avoid a costly normalisation because of this. 3 Refraction The calculation of the refracted ray starts with Snell s law [2] which tells that the products of the index of refraction and sines of the angles must be equal: η 1 sinθ i = sinθ t (20) 4

You can write this as: sinθ t = η 1 sinθ i (21) With this equation you can already see there will be a bit of a problem if sinθ 1 > η 1. If that s the case, sinθ 2 would have to be greater than 1. BANG! That s not possible. What we have here is total internal reflection or TIR. What exactly this TIR is will be addressed later. For now, we ll just add a condition to our law: sinθ t = η 1 sinθ i sinθ i η 1 (22) In what follows, we ll assume this condition is fullfilled, so we don t have to worry about it. Fine, now we know the theory, we should try to find a formula for t. This first thing we ll do is to split it up in a tangent and normal part: t = t + t (23) Of both parts, we ll do t first, because Snell s law tells us something about sines, and the norms of the tangent parts happen to be equal to sines. Hence, because of 10 and 22, we can write: t = η 1 i (24) Since t and i are parallel and point in the same direction, this becomes: t = η 1 i = η 1 [ i cosθi n ] (25) Don t worry about the cosθ i, later on it will make things easier if we just leave it there. If you need it, you can easily calculate it with (11), it equals i n. Great, so we have one part already (it s not that bad, is it? ;-) Now the other one, and that s quite simple if you use Pythagoras (6) and the knowledge that we re dealing with normalized vectors (1): t = 1 t 2 n (26) Now we have both parts. It s time to substitute (25) and (26) in (23) to get the refracted direction vector. If we do that and we regroup a little so we get only one term in n, we get (hold on!): ( η 1 η1 t = i cosθ i + 1 ) t 2 n (27) It s a bit unfortunate we still need t under the square root. Luckely, we don t really need the vector t, but its norm. And this norm equals to sinθ t (10). We get: 5

( ) η 1 η1 t = i cosθ i + 1 sin 2 θ t n (28) Now instead, we need sin 2 θ t, but we know that s given by Snell s law (20): sin 2 θ t = ( η1 ) 2 sin 2 θ i = ( η1 ) 2 ( 1 cos 2 θ i ) (29) The last two equations are all we need to calculate the refracted direction vector. 4 Total Internal Reflection If we take a closer look to equation (28), you will notice it s only valid if the value under the square root isn t negative. At first glance, that seems to be a second condition next to the one in Snell s law (22). However, that changes if you take a closer look to what this new condition means: That s exactly the same als the original condition: 1 sin 2 θ t 0 (30) sin 2 θ t 1 (31) Isn t this beautiful? In two completely different situations, we have noticed restrictions on the equations: the value of a sine that shouldn t be greater than one, and the value under a square root that shouldn t be negative. And yet, it turns out they re one and the same. Anyway, if this condition is not fullfilled, we can t find a refracted direction vector. That means we can t do transmission: if the condition isn t fullfilled, there s no transmission. Why exactly is this called total internal reflection, and why is it called a reflection while it s a restriction for refraction? First of all, it can only happen if you go from a denser material to a less dense material (e.g. from glass to air). This is because sinθ t can only become greater than one if η 1 > 1. In other words: it can only happen if you re inside a denser material. Hence the internal. Secondly, physics says that each photon (= a packet of light) that arrives at the interface, but go through it (= transmission) or be reflected. Well, it can be absorbed too, but let s ignore that :-). If no photons can go through because the condition in Snell s law isn t fullfilled, then they all must be reflected: total reflection. Together, this gives total internal reflection. 6

5 Conclusion By now, we have derived two equations to calculate the reflected and refracted direction vectors by using vector arithmetic only. Here they are again: with r = i 2cosθi n t = η 1 i ( η1 cosθ i + 1 sin 2 θ t ) n cosθ i = i n ( ) 2 sin 2 η1 ( θ t = 1 cos 2 ) θ i In case of refraction, there s a condition that limits the range of incoming angles θ i. Outside this range, the refracted direction vector does not exists. Hence, there s no transmission. This is called total internal reflection. The condition is: sin 2 θ t 1 Algorithm 1 the code Vector reflect(const Vector& normal, const Vector& incident) { const double cosi = dot(normal, incident); return incident - 2 * cosi * normal; } Vector refract(const Vector& normal, const Vector& incident, double n1, double n2) { const double n = n1 / n2; const double cosi = dot(normal, incident); const double sint2 = n * n * (1.0 - cosi * cosi); if (sint2 > 1.0) { return Vector::invalid; } return n * incident - (n + sqrt(1.0 - sint2)) * normal; } 7

References [1] Eric Weisstein s World of Physics, Law of Reflection, http://scienceworld.wolfram.com [2] Eric Weisstein s World of Physics, Snell s Law, http://scienceworld.wolfram.com [3] 3D Geometry Primer, More On Vector Arithmetic, http://www.flipcode.com/geometry 8