Ray Tracing 6

Total Page:16

File Type:pdf, Size:1020Kb

Ray Tracing 6 Ray Tracing Assignment Goal is to reproduce the following So You Want to Write a Ray Tracer Checkpoint 6 – Refraction Whitted, 1980 Ray Tracing Assignment Ray Tracing Assignment Seven checkpoints Seven checkpoints Setting the Scene Setting the Scene Camera Modeling Camera Modeling Basic Shading Basic Shading Procedural Shading Procedural Shading Recursive Ray Tracing – Reflection Recursive Ray Tracing – Reflection Recursive Ray Tracing – Transmission Recursive Ray Tracing – Transmission Tone Reproduction Tone Reproduction Refraction Recursive Ray Tracing color illuminate (ray, depth) Perform recursive ray tracing by find closest intersect considering reflection and refraction if (!intersection) return background color else Parameters to add: spawn shadow ray For each object retcolor = local illumination if (depth < MAX_DEPTH) kr, kt – reflection and transmission constants if (kr > 0) kt ≠ 0 for this checkpoint spawn reflection ray retcolor += kr * illuminate (reflect ray, depth+1) Index of refraction (example 0.95) if (kt > 0) spawn transmission ray retcolor += kt * illuminate (trans ray, depth +1) return retcolor 1 Recursive Ray Tracing Calculating Transmission Ray For each pixel Starting with Snell’s law d ! n spawn ray from camera pos to pixel i !i η sinθ =η sinθ pixel_color = illuminate (ray, 1) i i t t ηt θ t t Assume d and n are normalized. We can find the equation for t, the d is the incoming transmission ray: ray, t is the η (d −n(d •n)) η2 (1 −(d •n)2 ) transmission ray. t = i +n 1- i η η 2 t t If negative – total internal reflection Total Internal Reflection Total Internal Reflection an optical phenomenon that occurs when light is refracted (bent) at a medium boundary enough to send it backwards, effectively reflecting all of the light. In these cases, the transmission ray will be spawned in the reflection direction. Wikipedia Total Internal Reflection Calculating transmission ray Snell’s law applet http://www.physics.northwestern.edu/ugrad/vpl/opt ics/snell.html Index of refraction of air = 1.0 Optimization If indices of refractions are the same Total internal reflection occurs around boundary of no bending transparent sphere Transmission direction is the same as incoming direction 2 Things to think about Things to think about Must keep track if you are inside or 2 ways to deal outside If n • d < 0 then Index of Inside Use –n as normal for calculations η refraction Use inside η as !i Normal vector Keep track as you are spawning rays Things to think about Refraction public Vector3f faceForward (Vector3f A Vector3f B) For sake of checkpoint { Make one sphere transparent (k = 0.8) // For acute angles, dot product will t // be positive Make other sphere non-transparent if (A.dot(B) >= 0) return A; // Obtuse angle, reverse the first vector May wish to test first with index of refraction = 1.0 Vector3f V = new Vector3f (A); V.scale (-1.0f); return V; } Refraction Refraction Note: Due date: If done correctly, you should now have a faithful reproduction of the target image. Must be posted to Web site by May 2nd Sample parameters Recall: 10% penalty per day Sphere1 – front Sphere2 – rear Color (all) = white Color (amb/diffuse) Having trouble? (0.7, 0.7, 0.7) Ka = 0 .0 7 5 Color (spec) = white Let me know EARLY. Kd = 0 .0 7 5 Ka = 0 .1 5 Ks = 0 .2 Kd = 0 .2 5 Questions? Ke = 2 0 .0 Ks = 1 .0 Kr = 0 .0 1 Ke = 2 0 .0 Kt = 0 .8 5 Kr = 0 .7 5 Kt = 0 .0 3 Extra extra For 5 points: Adjust shadow ray based upon transparency of objects. 4.
Recommended publications
  • Glossary Physics (I-Introduction)
    1 Glossary Physics (I-introduction) - Efficiency: The percent of the work put into a machine that is converted into useful work output; = work done / energy used [-]. = eta In machines: The work output of any machine cannot exceed the work input (<=100%); in an ideal machine, where no energy is transformed into heat: work(input) = work(output), =100%. Energy: The property of a system that enables it to do work. Conservation o. E.: Energy cannot be created or destroyed; it may be transformed from one form into another, but the total amount of energy never changes. Equilibrium: The state of an object when not acted upon by a net force or net torque; an object in equilibrium may be at rest or moving at uniform velocity - not accelerating. Mechanical E.: The state of an object or system of objects for which any impressed forces cancels to zero and no acceleration occurs. Dynamic E.: Object is moving without experiencing acceleration. Static E.: Object is at rest.F Force: The influence that can cause an object to be accelerated or retarded; is always in the direction of the net force, hence a vector quantity; the four elementary forces are: Electromagnetic F.: Is an attraction or repulsion G, gravit. const.6.672E-11[Nm2/kg2] between electric charges: d, distance [m] 2 2 2 2 F = 1/(40) (q1q2/d ) [(CC/m )(Nm /C )] = [N] m,M, mass [kg] Gravitational F.: Is a mutual attraction between all masses: q, charge [As] [C] 2 2 2 2 F = GmM/d [Nm /kg kg 1/m ] = [N] 0, dielectric constant Strong F.: (nuclear force) Acts within the nuclei of atoms: 8.854E-12 [C2/Nm2] [F/m] 2 2 2 2 2 F = 1/(40) (e /d ) [(CC/m )(Nm /C )] = [N] , 3.14 [-] Weak F.: Manifests itself in special reactions among elementary e, 1.60210 E-19 [As] [C] particles, such as the reaction that occur in radioactive decay.
    [Show full text]
  • EMT UNIT 1 (Laws of Reflection and Refraction, Total Internal Reflection).Pdf
    Electromagnetic Theory II (EMT II); Online Unit 1. REFLECTION AND TRANSMISSION AT OBLIQUE INCIDENCE (Laws of Reflection and Refraction and Total Internal Reflection) (Introduction to Electrodynamics Chap 9) Instructor: Shah Haidar Khan University of Peshawar. Suppose an incident wave makes an angle θI with the normal to the xy-plane at z=0 (in medium 1) as shown in Figure 1. Suppose the wave splits into parts partially reflecting back in medium 1 and partially transmitting into medium 2 making angles θR and θT, respectively, with the normal. Figure 1. To understand the phenomenon at the boundary at z=0, we should apply the appropriate boundary conditions as discussed in the earlier lectures. Let us first write the equations of the waves in terms of electric and magnetic fields depending upon the wave vector κ and the frequency ω. MEDIUM 1: Where EI and BI is the instantaneous magnitudes of the electric and magnetic vector, respectively, of the incident wave. Other symbols have their usual meanings. For the reflected wave, Similarly, MEDIUM 2: Where ET and BT are the electric and magnetic instantaneous vectors of the transmitted part in medium 2. BOUNDARY CONDITIONS (at z=0) As the free charge on the surface is zero, the perpendicular component of the displacement vector is continuous across the surface. (DIꓕ + DRꓕ ) (In Medium 1) = DTꓕ (In Medium 2) Where Ds represent the perpendicular components of the displacement vector in both the media. Converting D to E, we get, ε1 EIꓕ + ε1 ERꓕ = ε2 ETꓕ ε1 ꓕ +ε1 ꓕ= ε2 ꓕ Since the equation is valid for all x and y at z=0, and the coefficients of the exponentials are constants, only the exponentials will determine any change that is occurring.
    [Show full text]
  • Chapter 22 Reflection and Refraction of Light
    Chapter 22 Reflection and Refraction of Light Problem Solutions 22.1 The total distance the light travels is d2 Dcenter to R Earth R Moon center 2 3.84 108 6.38 10 6 1.76 10 6 m 7.52 10 8 m d 7.52 108 m Therefore, v 3.00 108 m s t 2.51 s 22.2 (a) The energy of a photon is sinc nair n prism 1.00 n prism , where Planck’ s constant is 1.00 8 sinc sin 45 and the speed of light in vacuum is c 3.00 10 m s . If nprism 1.00 1010 m , 6.63 1034 J s 3.00 10 8 m s E 1.99 1015 J 1.00 10-10 m 1 eV (b) E 1.99 1015 J 1.24 10 4 eV 1.602 10-19 J (c) and (d) For the X-rays to be more penetrating, the photons should be more energetic. Since the energy of a photon is directly proportional to the frequency and inversely proportional to the wavelength, the wavelength should decrease , which is the same as saying the frequency should increase . 1 eV 22.3 (a) E hf 6.63 1034 J s 5.00 10 17 Hz 2.07 10 3 eV 1.60 1019 J 355 356 CHAPTER 22 34 8 hc 6.63 10 J s 3.00 10 m s 1 nm (b) E hf 6.63 1019 J 3.00 1029 nm 10 m 1 eV E 6.63 1019 J 4.14 eV 1.60 1019 J c 3.00 108 m s 22.4 (a) 5.50 107 m 0 f 5.45 1014 Hz (b) From Table 22.1 the index of refraction for benzene is n 1.501.
    [Show full text]
  • 9.2 Refraction and Total Internal Reflection
    9.2 refraction and total internal reflection When a light wave strikes a transparent material such as glass or water, some of the light is reflected from the surface (as described in Section 9.1). The rest of the light passes through (transmits) the material. Figure 1 shows a ray that has entered a glass block that has two parallel sides. The part of the original ray that travels into the glass is called the refracted ray, and the part of the original ray that is reflected is called the reflected ray. normal incident ray reflected ray ␪ ␪i r ␪r ϭ ␪i air glass ␪2 refracted ray Figure 1 A light ray that strikes a glass surface is both reflected and refracted. Refracted and reflected rays of light account for many things that we encounter in our everyday lives. For example, the water in a pool can look shallower than it really is. A stick can look as if it bends at the point where it enters the water. On a hot day, the road ahead can appear to have a puddle of water, which turns out to be a mirage. These effects are all caused by the refraction and reflection of light. refraction The direction of the refracted ray is different from the direction of the incident refraction the bending of light as it ray, an effect called refraction. As with reflection, you can measure the direction of travels at an angle from one medium the refracted ray using the angle that it makes with the normal. In Figure 1, this to another angle is labelled θ2.
    [Show full text]
  • Descartes' Optics
    Descartes’ Optics Jeffrey K. McDonough Descartes’ work on optics spanned his entire career and represents a fascinating area of inquiry. His interest in the study of light is already on display in an intriguing study of refraction from his early notebook, known as the Cogitationes privatae, dating from 1619 to 1621 (AT X 242-3). Optics figures centrally in Descartes’ The World, or Treatise on Light, written between 1629 and 1633, as well as, of course, in his Dioptrics published in 1637. It also, however, plays important roles in the three essays published together with the Dioptrics, namely, the Discourse on Method, the Geometry, and the Meteorology, and many of Descartes’ conclusions concerning light from these earlier works persist with little substantive modification into the Principles of Philosophy published in 1644. In what follows, we will look in a brief and general way at Descartes’ understanding of light, his derivations of the two central laws of geometrical optics, and a sampling of the optical phenomena he sought to explain. We will conclude by noting a few of the many ways in which Descartes’ efforts in optics prompted – both through agreement and dissent – further developments in the history of optics. Descartes was a famously systematic philosopher and his thinking about optics is deeply enmeshed with his more general mechanistic physics and cosmology. In the sixth chapter of The Treatise on Light, he asks his readers to imagine a new world “very easy to know, but nevertheless similar to ours” consisting of an indefinite space filled everywhere with “real, perfectly solid” matter, divisible “into as many parts and shapes as we can imagine” (AT XI ix; G 21, fn 40) (AT XI 33-34; G 22-23).
    [Show full text]
  • The Shallow Water Wave Ray Tracing Model SWRT
    The Shallow Water Wave Ray Tracing Model SWRT Prepared for: BMT ARGOSS Our reference: BMTA-SWRT Date of issue: 20 Apr 2016 Prepared for: BMT ARGOSS The Shallow Water Wave Ray Tracing Model SWRT Document Status Sheet Title : The Shallow Water Wave Ray Tracing Model SWRT Our reference : BMTA-SWRT Date of issue : 20 Apr 2016 Prepared for : BMT ARGOSS Author(s) : Peter Groenewoud (BMT ARGOSS) Distribution : BMT ARGOSS (BMT ARGOSS) Review history: Rev. Status Date Reviewers Comments 1 Final 20 Apr 2016 Ian Wade, Mark van der Putte and Rob Koenders Information contained in this document is commercial-in-confidence and should not be transmitted to a third party without prior written agreement of BMT ARGOSS. © Copyright BMT ARGOSS 2016. If you have questions regarding the contents of this document please contact us by sending an email to [email protected] or contact the author directly at [email protected]. 20 Apr 2016 Document Status Sheet Prepared for: BMT ARGOSS The Shallow Water Wave Ray Tracing Model SWRT Contents 1. INTRODUCTION ..................................................................................................................... 1 1.1. MODEL ENVIRONMENTS .............................................................................................................. 1 1.2. THE MODEL IN A NUTSHELL ......................................................................................................... 1 1.3. EXAMPLE MODEL CONFIGURATION OFF PANAMA .........................................................................
    [Show full text]
  • Reflection, Refraction, and Total Internal Reflection
    From The Physics Classroom's Physics Interactives http://www.physicsclassroom.com Reflection, Refraction, and Total Internal Reflection Purpose: To investigate the effect of the angle of incidence upon the brightness of a reflected ray and refracted ray at a boundary and to identify the two requirements for total internal reflection. Getting Ready: Navigate to the Refraction Interactive at The Physics Classroom website: http://www.physicsclassroom.com/Physics-Interactives/Refraction-and-Lenses/Refraction Navigational Path: www.physicsclassroom.com ==> Physics Interactives ==> Refraction and Lenses ==> Refraction Getting Acquainted: Once you've launched the Interactive and resized it, experiment with the interface to become familiar with it. Observe how the laser can be dragged about the workspace, how it can be turned On (Go button) and Cleared, how the substance on the top and the bottom of the boundary can be changed, and how the protractor can be toggled on and off and repositioned. Also observe that there is an incident ray, a reflected ray and a refracted ray; the angle for each of these rays can be measured. Part 1: Reflection and Refraction Set the top substance to Air and the bottom substance to Water. Drag the laser under the water so that you can shoot it upward through the water at the boundary with air (don't do this at home ... nor in the physics lab). Toggle the protractor to On. Then collect data for light rays approaching the boundary with the following angles of incidence (Θincidence). If there is no refracted ray, then put "--" in the table cell for the angle of refraction (Θrefraction).
    [Show full text]
  • Interactive Rendering with Coherent Ray Tracing
    EUROGRAPHICS 2001 / A. Chalmers and T.-M. Rhyne Volume 20 (2001), Number 3 (Guest Editors) Interactive Rendering with Coherent Ray Tracing Ingo Wald, Philipp Slusallek, Carsten Benthin, and Markus Wagner Computer Graphics Group, Saarland University Abstract For almost two decades researchers have argued that ray tracing will eventually become faster than the rasteri- zation technique that completely dominates todays graphics hardware. However, this has not happened yet. Ray tracing is still exclusively being used for off-line rendering of photorealistic images and it is commonly believed that ray tracing is simply too costly to ever challenge rasterization-based algorithms for interactive use. However, there is hardly any scientific analysis that supports either point of view. In particular there is no evidence of where the crossover point might be, at which ray tracing would eventually become faster, or if such a point does exist at all. This paper provides several contributions to this discussion: We first present a highly optimized implementation of a ray tracer that improves performance by more than an order of magnitude compared to currently available ray tracers. The new algorithm makes better use of computational resources such as caches and SIMD instructions and better exploits image and object space coherence. Secondly, we show that this software implementation can challenge and even outperform high-end graphics hardware in interactive rendering performance for complex environments. We also provide an brief overview of the benefits of ray tracing over rasterization algorithms and point out the potential of interactive ray tracing both in hardware and software. 1. Introduction Ray tracing is famous for its ability to generate high-quality images but is also well-known for long rendering times due to its high computational cost.
    [Show full text]
  • Physics 30 Lesson 8 Refraction of Light
    Physics 30 Lesson 8 Refraction of Light Refer to Pearson pages 666 to 674. I. Reflection and refraction of light At any interface between two different mediums, some light will be reflected and some will be refracted, except in certain cases which we will soon discover. When problem solving for refraction, we usually ignore the reflected ray. Glass prism II. Index of refraction The fastest that light can travel is in a vacuum (c = 3.00 x 108 m/s). In other substances, the speed of light is always slower. The index of refraction is a ratio of the speed of light in vacuum with the speed of light in the medium: speed in vacuum (c) index of refraction (n) speed in medium (v) c n= v Some common indices of refraction are: Substance Index of refraction (n) vacuum 1.0000 Notice that the index of refraction (n) air 1.0003 is always greater than or equal to 1 water 1.33 ethyl alcohol 1.36 and that it has no units. quartz (fused) 1.46 glycerine 1.47 Lucite or Plexiglas 1.51 glass (crown) 1.52 sodium chloride 1.53 glass (crystal) 1.54 ruby 1.54 glass (flint) 1.65 zircon 1.92 diamond 2.42 Dr. Ron Licht 8 – 1 www.structuredindependentlearning.com Example 1 The index of refraction for crown glass was measured to be 1.52. What is the speed of light in crown glass? c n v c v n 3.00 108 m v s 1.52 8 m v 1.97 ×10 s III.
    [Show full text]
  • General Optics Design Part 2
    GENERAL OPTICS DESIGN PART 2 Martin Traub – Fraunhofer ILT [email protected] – Tel: +49 241 8906-342 © Fraunhofer ILT AGENDA Raytracing Fundamentals Aberration plots Merit function Correction of optical systems Optical materials Bulk materials Coatings Optimization of a simple optical system, evaluation of the system Seite 2 © Fraunhofer ILT Why raytracing? • Real paths of rays in optical systems differ more or less to paraxial paths of rays • These differences can be described by Seidel aberrations up to the 3rd order • The calculation of the Seidel aberrations does not provide any information of the higher order aberrations • Solution: numerical tracing of a large number of rays through the optical system • High accuracy for the description of the optical system • Fast calculation of the properties of the optical system • Automatic, numerical optimization of the system Seite 3 © Fraunhofer ILT Principle of raytracing 1. The system is described by a number of surfaces arranged between the object and image plane (shape of the surfaces and index of refraction) 2. Definition of the aperture(s) and the ray bundle(s) launched from the object (field of view) 3. Calculation of the paths of all rays through the whole optical system (from object to image plane) 4. Calculation and analysis of diagrams suited to describe the properties of the optical system 5. Optimizing of the optical system and redesign if necessary (optics design is a highly iterative process) Seite 4 © Fraunhofer ILT Sequential vs. non sequential raytracing 1. In sequential raytracing, the order of surfaces is predefined very fast and efficient calculations, but mainly limited to imaging optics, usually 100..1000 rays 2.
    [Show full text]
  • Chapter 22 Reflection and Refraction of Light Wavelength the Distance Between Any Two Crests of the Wave Is Defined As the Wavel
    Chapter 22 Reflection and Refraction of Light Wavelength Dual Nature of Light The distance between any two crests of the • Experiments can be devised that will wave is defined as the wavelength display either the wave nature or the particle nature of light • Nature prevents testing both qualities at the same time Geometric Optics – Using a Ray The Nature of Light Approximation • “Particles” of light are called photons • Light travels in a straight-line path in a • Each photon has a particular energy homogeneous medium until it –E = h ƒ encounters a boundary between two – h is Planck’s constant different media • h = 6.63 x 10-34 J s •The ray approximation is used to – Encompasses both natures of light represent beams of light • Interacts like a particle •A ray of light is an imaginary line drawn • Has a given frequency like a wave along the direction of travel of the light beams Ray Approximation Geometric Optics •A wave front is a surface passing through points of a wave that have the same phase and amplitude • The rays, corresponding to the direction of the wave motion, are perpendicular to the wave fronts Reflection QUICK QUIZ 22.1 Diffuse refection: The objects has irregularities that spread out an initially parallel beam of Which part of the figure below shows specular reflection of light in all directions to produce light from the roadway? diffuse reflection Specular reflection (mirror): When a parallel beam of light is directed at a smooth surface, it is specularly reflected in only one direction. The color of an object we see depends on two things: Law of Reflection The angle of incidence = the angle of reflection The kind of light falling on it and nature of its surface For instance, if white light is used to illuminate an object that absorbs all color other than red, the object will appear red.
    [Show full text]
  • Light Refraction with Dispersion Steven Cropp & Eric Zhang
    Light Refraction with Dispersion Steven Cropp & Eric Zhang 1. Abstract In this paper we present ray tracing and photon mapping methods to model light refraction, caustics, and multi colored light dispersion. We cover the solution to multiple common implementation difficulties, and mention ways to extend implementations in the future. 2. Introduction Refraction is when light rays bend at the boundaries of two different mediums. The amount light bends depends on the change in the speed of the light between the two mediums, which itself is dependent on a property of the materials. Every material has an index of refraction, a dimensionless number that describes how light (or any radiation) travels through that material. For example, water has an index of refraction of 1.33, which means light travels 33 percent slower in water than in a vacuum (which has the defining index of refraction of 1). Refraction is described by Snell’s Law, which calculates the new direction of the light ray based on the ray’s initial direction, as well as the two mediums it is exiting and entering. Chromatic dispersion occurs when a material’s index of refraction is not a constant, but a function of the wavelength of light. This causes different wavelengths, or colors, to refract at slightly different angles even when crossing the same material border. This slight variation splits the light into bands based on wavelength, creating a rainbow. This phenomena can be recreated by using a Cauchy approximation of an object’s index of refraction. 3. Related Work A “composite spectral model” was proposed by Sun et al.
    [Show full text]