All Topics  
Ray tracing

 
Ray Tracing

   Email Print
   Bookmark   Link






 

Ray tracing



 
 
In computer graphics
Computer graphics

Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer....
, ray tracing is a technique for generating an image
Digital image

A digital image is a representation of a two-dimensional using ones and zeros . Depending on whether or not the is fixed, it may be of vector graphics or raster graphics type....
 by tracing the path of light
Light

Light, or visible light, is electromagnetic radiation of a wavelength that is Visible spectrum to the human eye , or up to 380?750 nm. In the broader field of physics, light is sometimes used to refer to electromagnetic radiation of all wavelengths, whether visible or not....
 through pixels
Pixel

In digital imaging, a pixel is the smallest item of information in an image. Pixels are normally arranged in a 2-dimensional grid, and are often represented using dots, squares, or rectangles....
 in an image plane
Image plane

In 3D computer graphics, the image plane is that Plane in the world which is identified with the plane of the monitor. If one makes the analogy of taking a photograph to rendering a 3D image, the surface of the film is the image plane....
. The technique is capable of producing a very high degree of photorealism
Photorealism

Photorealism is the genre of painting based on making a painting of a photograph. The term is primarily applied to paintings from the United States photorealism art movement that began in the late 1960s, early 1970s....
; usually higher than that of typical scanline rendering
Scanline rendering

Scanline rendering is an algorithm for Hidden surface determination#Visible surface determination, in 3D computer graphics,that works on a row-by-row basis rather than a polygon-by-polygon or pixel-by-pixel basis....
 methods, but at a greater computational cost
Computation time

In computational complexity theory, computation time is a measure of how many steps are used by some abstract machine in a particular computation....
. This makes ray tracing best suited for applications where the image can be rendered slowly ahead of time, such as in still images and film and television special effects, and more poorly suited for real-time applications like computer games
Computer Games

"Computer Games" is a single by New Zealand group, Mi-Sex released in 1981 . It was the single that launched the band, and was hugely popular, particularly in Australia and New Zealand....
 where speed is critical.






Discussion
Ask a question about 'Ray tracing'
Start a new discussion about 'Ray tracing'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer graphics
Computer graphics

Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer....
, ray tracing is a technique for generating an image
Digital image

A digital image is a representation of a two-dimensional using ones and zeros . Depending on whether or not the is fixed, it may be of vector graphics or raster graphics type....
 by tracing the path of light
Light

Light, or visible light, is electromagnetic radiation of a wavelength that is Visible spectrum to the human eye , or up to 380?750 nm. In the broader field of physics, light is sometimes used to refer to electromagnetic radiation of all wavelengths, whether visible or not....
 through pixels
Pixel

In digital imaging, a pixel is the smallest item of information in an image. Pixels are normally arranged in a 2-dimensional grid, and are often represented using dots, squares, or rectangles....
 in an image plane
Image plane

In 3D computer graphics, the image plane is that Plane in the world which is identified with the plane of the monitor. If one makes the analogy of taking a photograph to rendering a 3D image, the surface of the film is the image plane....
. The technique is capable of producing a very high degree of photorealism
Photorealism

Photorealism is the genre of painting based on making a painting of a photograph. The term is primarily applied to paintings from the United States photorealism art movement that began in the late 1960s, early 1970s....
; usually higher than that of typical scanline rendering
Scanline rendering

Scanline rendering is an algorithm for Hidden surface determination#Visible surface determination, in 3D computer graphics,that works on a row-by-row basis rather than a polygon-by-polygon or pixel-by-pixel basis....
 methods, but at a greater computational cost
Computation time

In computational complexity theory, computation time is a measure of how many steps are used by some abstract machine in a particular computation....
. This makes ray tracing best suited for applications where the image can be rendered slowly ahead of time, such as in still images and film and television special effects, and more poorly suited for real-time applications like computer games
Computer Games

"Computer Games" is a single by New Zealand group, Mi-Sex released in 1981 . It was the single that launched the band, and was hugely popular, particularly in Australia and New Zealand....
 where speed is critical. Ray tracing is capable of simulating a wide variety of optical effects, such as reflection
Reflection (physics)

Reflection is the change in direction of a wavefront at an wiktionary:interface between two differentmedium so that the wavefront returns into the medium from which it originated....
 and refraction
Refraction

Refraction is the change in direction of a wave due to a change in its speed. This is most commonly observed when a wave passes from one optical medium to another....
, scattering, and chromatic aberration
Chromatic aberration

In optics, chromatic aberration is the failure of a lens to Focus all colors to the same point. It occurs because lenses have a different refractive index for different wavelengths of light ....
.




Algorithm overview

Optical ray tracing describes a method for producing visual images constructed in 3D computer graphics
3D computer graphics

3D computer graphics are graphics that use a Cartesian coordinate system#Three-dimensional coordinate system representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images....
 environments, with more photorealism than either ray casting
Ray casting

Ray casting is the use of ray-surface intersection tests to solve a variety of problems in computer graphics. The term was first used in computer graphics in a 1982 paper by Scott Roth to describe a method for rendering Constructive solid geometry models....
 or scanline rendering techniques. It works by tracing a path from an imaginary eye through each pixel in a virtual screen, and calculating the color of the object visible through it.

Scenes in raytracing are described mathematically by a programmer or by a visual artist (using intermediary tools). Scenes may also incorporate data from images and models captured by means such as digital photography.

Typically, each ray must be tested for intersection with some subset of all the objects in the scene. Once the nearest object has been identified, the algorithm will estimate the incoming light at the point of intersection, examine the material properties of the object, and combine this information to calculate the final color of the pixel. Certain illumination algorithms and reflective or translucent materials may require more rays to be re-cast into the scene.

It may at first seem counterintuitive or "backwards" to send rays away from the camera, rather than into it (as actual light does in reality), but doing so is in fact many orders of magnitude more efficient. Since the overwhelming majority of light rays from a given light source do not make it directly into the viewer's eye, a "forward" simulation could potentially waste a tremendous amount of computation on light paths that are never recorded. A computer simulation that starts by casting rays from the light source is called Photon mapping
Photon mapping

In computer graphics, photon mapping is a two-pass global illumination algorithm developed by Henrik Wann Jensen that solves the rendering equation....
, and it takes much longer than a comparable ray trace.

Therefore, the shortcut taken in raytracing is to presuppose that a given ray intersects the view frame. After either a maximum number of reflections or a ray traveling a certain distance without intersection, the ray ceases to travel and the pixel's value is updated. The light intensity of this pixel is computed using a number of algorithms, which may include the classic rendering algorithm and may also incorporate techniques such as radiosity
Radiosity

Radiosity is a global illumination algorithm used in 3D computer graphics rendering . Radiosity is an application of the finite element method to solving the rendering equation for scenes with purely diffuse surfaces....
.

Detailed description of ray tracing computer algorithm and its genesis


What happens in nature

Glasses 800 Edit
In nature, a light source emits a ray of light which travels, eventually, to a surface that interrupts its progress. One can think of this "ray" as a stream of photon
Photon

In physics, the photon is an elementary particle, the quantum of the electromagnetic field and the basic unit of light and all other forms of electromagnetic radiation....
s traveling along the same path. In a perfect vacuum this ray will be a straight line (ignoring relativistic effects
General relativity

General relativity or the general theory of relativity is the Geometry Theoretical physics of gravitation published by Albert Einstein in 1916....
). In reality, any combination of four things might happen with this light ray: absorption
Absorption (electromagnetic radiation)

In physics, absorption of electromagnetic radiation is the way by which the energy of a photon is taken up by matter, typically the electrons of an atom....
, reflection
Reflection (physics)

Reflection is the change in direction of a wavefront at an wiktionary:interface between two differentmedium so that the wavefront returns into the medium from which it originated....
, refraction
Refraction

Refraction is the change in direction of a wave due to a change in its speed. This is most commonly observed when a wave passes from one optical medium to another....
 and fluorescense
Fluorescence

Fluorescence is a luminescence that is mostly found as an optical phenomenon in cold bodies, in which the molecular absorption of a photon triggers the emission of a photon with a longer wavelength....
. A surface may reflect all or part of the light ray, in one or more directions. It might also absorb part of the light ray, resulting in a loss of intensity of the reflected and/or refracted light. If the surface has any transparent
Transparency (optics)

In optics, transparency is the material property of allowing light to pass through. In mineralogy, another term for this property is diaphaneity....
 or translucent
Transparency (optics)

In optics, transparency is the material property of allowing light to pass through. In mineralogy, another term for this property is diaphaneity....
 properties, it refracts a portion of the light beam into itself in a different direction while absorbing some (or all) of the spectrum
Visible spectrum

The visible spectrum is the portion of the electromagnetic spectrum that is visual perception to the human eye. Electromagnetic radiation in this range of wavelengths is called visible light or simply light....
 (and possibly altering the color). Less commonly, a surface may absorb some portion of the light and fluorescently re-emit the light at a longer wavelength colour in a random direction, though this is often rare enough that it can be discounted from rendering applications. Between absorption, reflection, refraction and fluorescense, all of the incoming light must be accounted for, and no more. A surface cannot, for instance, reflect 66% of an incoming light ray, and refract 50%, since the two would add up to be 116%. From here, the reflected and/or refracted rays may strike other surfaces, where their absorptive, refractive, reflective and fluorescent properties again affect the progress of the incoming rays. Some of these rays travel in such a way that they hit our eye, causing us to see the scene and so contribute to the final rendered image.

Ray casting algorithm

The first ray casting
Ray casting

Ray casting is the use of ray-surface intersection tests to solve a variety of problems in computer graphics. The term was first used in computer graphics in a 1982 paper by Scott Roth to describe a method for rendering Constructive solid geometry models....
 (versus ray tracing) algorithm used for rendering was presented by Arthur Appel in 1968. The idea behind ray casting is to shoot rays from the eye, one per pixel, and find the closest object blocking the path of that ray – think of an image as a screen-door, with each square in the screen being a pixel. This is then the object the eye normally sees through that pixel. Using the material properties and the effect of the lights in the scene, this algorithm can determine the shading of this object. The simplifying assumption is made that if a surface faces a light, the light will reach that surface and not be blocked or in shadow. The shading of the surface is computed using traditional 3D computer graphics shading models. One important advantage ray casting offered over older scanline algorithms
Scanline rendering

Scanline rendering is an algorithm for Hidden surface determination#Visible surface determination, in 3D computer graphics,that works on a row-by-row basis rather than a polygon-by-polygon or pixel-by-pixel basis....
 is its ability to easily deal with non-planar surfaces and solids, such as cones
Cone (geometry)

A cone is a dimension geometric shape that tapers smoothly from a flat, round base to a point called the apex or vertex. More precisely, it is the solid figure bounded by a plane base and the surface formed by the locus of all straight line segments joining the apex to the perimeter of the base....
 and sphere
Sphere

A sphere is a symmetrical geometrical object. In non-mathematical usage, the term is used to refer either to a round ball or to its two-dimensional surface....
s. If a mathematical surface can be intersected by a ray, it can be rendered using ray casting. Elaborate objects can be created by using solid modeling
Solid modeling

Solid modeling is the unambiguous representation of the solid parts of an object, that is, models of solid objects suitable for computer processing....
 techniques and easily rendered.

Ray casting for producing computer graphics was first used by scientists at Mathematical Applications Group, Inc.
Mathematical Applications Group, Inc.

Mathematics Application Group, Inc., aka MAGI, was an early innovator in the area of computer graphics. They are particularly well known for their work in television and film....
, (MAGI) of Elmsford, New York
Elmsford, New York

Elmsford is a Political subdivisions of New York State#Village in Westchester County, New York, New York, United States. Roughly one mile square, the village is fully contained within the borders of the Political subdivisions of New York State#Town of Greenburgh, New York, NY....
, New York
New York

The State of New York is a U.S. state in the Mid-Atlantic States and Northeastern United States regions of the United States and is the nation's List of U.S....
. In 1966, the company was created to perform radiation exposure
Radioactive contamination

Radioactive contamination is the uncontrolled distribution of radioactive decay material in a given environment. The amount of radioactive material released in an accident is called the source term....
 calculations for the Department of Defense
United States Department of Defense

The United States Department of Defense is the federal department charged with coordinating and supervising all agencies and functions of the government relating directly to national security and the Military of the United States....
. MAGI's software calculated not only how the gamma ray
Gamma ray

Gamma rays are a form of electromagnetic radiation produced by atom particle interactions, such as electron-positron annihilation or radioactive decay....
s bounced off of surfaces (ray casting for radiation had been done since the 1940s), but also how they penetrated and refracted within. These studies helped the government to determine certain military applications; constructing military vehicles that would protect troops from radiation, designing re-entry vehicles for space exploration. Under the direction of Dr. Philip Mittelman, the scientists developed a method of generating images using the same basic software. In 1972, MAGI became a commercial animation studio. This studio used ray casting to generate 3-D computer animation for television commercials, educational film
Educational film

An educational film is a film or movie whose primary purpose is to educate. Educational films have been used in classrooms as an alternative to other teaching methods....
s, and eventually feature films – they created much of the animation in the film Tron
Tron (film)

Tron is a 1982 in film science fiction film by Disney. Starring Jeff Bridges as Kevin Flynn , Bruce Boxleitner as Alan Bradley , Cindy Morgan as Dr....
 using ray casting exclusively. MAGI went out of business in 1985.

Ray tracing algorithm


The next important research breakthrough came from Turner Whitted in 1979. Previous algorithms cast rays from the eye into the scene, but the rays were traced no further. Whitted continued the process. When a ray hits a surface, it could generate up to three new types of rays: reflection, refraction, and shadow. A reflected ray continues on in the mirror-reflection direction from a shiny surface. It is then intersected with objects in the scene; the closest object it intersects is what will be seen in the reflection. Refraction rays traveling through transparent material work similarly, with the addition that a refractive ray could be entering or exiting a material. To further avoid tracing all rays in a scene, a shadow ray is used to test if a surface is visible to a light. A ray hits a surface at some point. If the surface at this point faces a light, a ray (to the computer, a line segment) is traced between this intersection point and the light. If any opaque object is found in between the surface and the light, the surface is in shadow and so the light does not contribute to its shade. This new layer of ray calculation added more realism to ray traced images.

Advantages over other rendering methods

Ray tracing's popularity stems from its basis in a realistic simulation of lighting over other rendering methods (such as scanline rendering or ray casting). Effects such as reflections and shadow
Shadow

File:Shadow, Ronald Reagan Building - Washington, D.C..jpgA shadow is an area where direct light from a light source cannot reach due to obstruction by an object....
s, which are difficult to simulate using other algorithms, are a natural result of the ray tracing algorithm. Relatively simple to implement yet yielding impressive visual results, ray tracing often represents a first foray into graphics programming. The computational independence of each ray makes ray tracing amenable to parallelization.

Disadvantages

A serious disadvantage of ray tracing is performance. Scanline algorithms and other algorithms use data coherence to share computations between pixels, while ray tracing normally starts the process anew, treating each eye ray separately. However, this separation offers other advantages, such as the ability to shoot more rays as needed to perform anti-aliasing
Anti-aliasing

In digital signal processing, anti-aliasing is the technique of minimizing the distortion artifacts known as aliasing when representing a high-resolution signal at a lower resolution....
 and improve image quality where needed. Although it does handle interreflection and optical effects such as refraction accurately, traditional ray tracing is also not necessarily photorealistic. True photorealism occurs when the rendering equation
Rendering equation

In computer graphics, the rendering equation is an integral equation in which the equilibrium radiance leaving a point is given as the sum of emitted plus reflected radiance under a geometric optics approximation....
 is closely approximated or fully implemented. Implementing the rendering equation gives true photorealism, as the equation describes every physical effect of light flow. However, this is usually infeasible given the computing resources required. The realism of all rendering methods, then, must be evaluated as an approximation to the equation, and in the case of ray tracing, it is not necessarily the most realistic. Other methods, including photon mapping
Photon mapping

In computer graphics, photon mapping is a two-pass global illumination algorithm developed by Henrik Wann Jensen that solves the rendering equation....
, are based upon ray tracing for certain parts of the algorithm, yet give far better results.

Reversed direction of traversal of scene by the rays


The process of shooting rays from the eye to the light source to render an image is sometimes referred to as backwards ray tracing, since it is the opposite direction photons actually travel. However, there is confusion with this terminology. Early ray tracing was always done from the eye, and early researchers such as James Arvo used the term backwards ray tracing to refer to shooting rays from the lights and gathering the results. As such, it is clearer to distinguish eye-based versus light-based ray tracing.

While the direct illumination is generally best sampled using eye-based ray tracing, certain indirect effects can benefit from rays generated from the lights. Caustics are bright patterns caused by the focusing of light off a wide reflective region onto a narrow area of (near-)diffuse surface. An algorithm that casts rays directly from lights onto reflective objects, tracing their paths to the eye, will better sample this phenomena. This integration of eye-based and light-based rays is often expressed as bidirectional path tracing, in which paths are traced from both the eye and lights, and the paths subsequently joined by a connecting ray after some length.

Photon mapping
Photon mapping

In computer graphics, photon mapping is a two-pass global illumination algorithm developed by Henrik Wann Jensen that solves the rendering equation....
 is another method that uses both light-based and eye-based ray tracing; in an initial pass, energetic photons are traced along rays from the light source so as to compute an estimate of radiant flux as a function of 3-dimensional space (the eponymous photon map itself). In a subsequent pass, rays are traced from the eye into the scene to determine the visible surfaces, and the photon map is used to estimate the illumination at the visible surface points. The advantage of photon mapping versus bidirectional path tracing is the ability to achieve significant reuse of photons, reducing computation, at the cost of statistical bias.

An additional problem occurs when light must pass through a very narrow aperture to illuminate the scene (consider a darkened room, with a door slightly ajar leading to a brightly-lit room), or a scene in which most points do not have direct line-of-sight to any light source (such as with ceiling-directed light fixtures or torchieres). In such cases, only a very small subset of paths will transport energy; Metropolis light transport
Metropolis light transport

This SIGGRAPH 1997 paper by Eric Veach and Leonidas J. Guibas describes an application of a variant of the Monte Carlo method called the Metropolis-Hastings algorithm to the rendering equation for generating images from detailed physical descriptions of three dimensional scenes....
 is a method which begins with a random search of the path space, and when energetic paths are found, reuses this information by exploring the nearby space of rays.

Algorithm: classical recursive ray tracing


For each pixel in image

To the right is an image showing a simple example of a path of rays recursively generated from the camera (or eye) to the light source using the above algorithm. A diffuse surface reflects light in all directions.

First, a ray is created at an eyepoint and traced through a pixel and into the scene, where it hits a diffuse surface. From that surface the algorithm recursively generates a reflection ray, which is traced through the scene, where it hits another diffuse surface. Finally, another reflection ray is generated and traced through the scene, where it hits the light source and is absorbed. The color of the pixel now depends on the colors of the first and second diffuse surface and the color of the light emitted from the light source. For example if the light source emitted white light and the two diffuse surfaces were blue, then the resulting color of the pixel is blue.

In real time


The first implementation of a "real-time" ray-tracer was credited at the 2005 SIGGRAPH
SIGGRAPH

SIGGRAPH is the name of the annual conference on computer graphics convened by the Association for Computing Machinery ACM SIGGRAPH organization....
 computer graphics conference as the REMRT/RT tools developed in 1986 by Mike Muuss
Mike Muuss

Michael John Muuss was the author of the freeware network tool Ping.A graduate of Johns Hopkins University, Muuss was a senior scientist specializing in geometric solid modeling, ray-tracing, MIMD architectures and digital computer networks at the United States Army Research Laboratory in Maryland when he died....
 for the BRL-CAD solid modeling system. Initially published in 1987 at USENIX
USENIX

The USENIX Association is the Advanced Computing Technical Association. It was founded in 1975 under the name "Unix Users Group," focusing primarily on the study and development of Unix and similar systems....
, the BRL-CAD ray-tracer is the first known implementation of a parallel network distributed ray-tracing system that achieved several frames per second in rendering performance. This performance was attained by leveraging the highly-optimized yet platform agnostic LIBRT ray-tracing engine in BRL-CAD and by using solid implicit CSG
Constructive solid geometry

Constructive solid geometry is a technique used in solid modeling. CSG is often, but not always, a procedural modeling technique used in 3D computer graphics and CAD....
 geometry on several shared memory parallel machines over a commodity network. BRL-CAD's ray-tracer, including REMRT/RT tools, continue to be available and developed today as Open source
Open source

Open source is an approach to design, development, and distribution offering practical accessibility to a product's source . Some consider open source as one of various possible design approaches, while others consider it a critical Strategy element of their business operations....
 software.

Since then, there have been considerable efforts and research towards implementing ray tracing in real time speeds for a variety of purposes on stand-alone desktop configurations. These purposes include interactive 3D graphics applications such as demoscene productions
Demo (computer programming)

A demo is a non-interactive multimedia presentation made within the computer subculture known as the demoscene. Demogroups create demos to demonstrate their abilities in programming, music, drawing, and 3D modeling....
, computer and video games, and image rendering. Some real-time software 3D engines based on ray tracing have been developed by hobbyist demo programmers
Demoscene

The demoscene is a computer art subculture that specializes in producing Demo , which are non-interactive audio-visual presentations that run in Real-time computing on a computer....
 since the late 1990s.

The OpenRT
OpenRT

The goal of the "OpenRT Real Time Ray Tracing Project" is to develop ray tracing to the point where it offers an alternative to the current rasterization based approach for interactive 3D graphics....
 project includes a highly-optimized software core for ray tracing along with an OpenGL
OpenGL

OpenGL is a standard specification defining a cross-language cross-platform Application programming interface for writing applications that produce 2D computer graphics and 3D computer graphics....
-like API in order to offer an alternative to the current rasterisation
Rasterisation

Rasterization or Rasterisation is the task of taking an image described in a vector graphics format and converting it into a raster image for output on a computer display or computer printer, or for storage in a bitmap file format....
 based approach for interactive 3D graphics. Ray tracing hardware
Ray tracing hardware

Ray tracing hardware is a special purpose computer hardware design for accelerating real-time ray tracing.Ray Tracing vs. Rasterization ...
, such as the experimental Ray Processing Unit
Ray Processing Unit

The Ray Processing Unit is experimental ray tracing hardware, developed at the Saarland University. It will be 50-100 times faster than the most advanced graphics processing unit....
 developed at the Saarland University
Saarland University

Saarland University is a university located in Saarbr?cken, the capital of the Germany state of Saarland. It was founded in 1948 in co-operation with France and is organized in 8 Faculty that cover all major fields of science....
, has been designed to accelerate some of the computationally intensive operations of ray tracing. On March 16 2007, the University of Saarland revealed an implementation of a high-performance ray tracing engine that allowed computer games to be rendered via ray tracing without intensive resource usage.

On June 12, 2008 Intel demonstrated Enemy Territory: Quake Wars
Enemy Territory: Quake Wars

Enemy Territory: Quake Wars is a first-person shooter video game, and is the follow-up to Wolfenstein: Enemy Territory. However, it is set in the same science fiction universe as Quake II and Quake 4, with a minimal back-story serving as a prequel to Quake II....
 using ray tracing for rendering, running in basic HD (720p) resolution. ETQW operated at 14-29 frames per second. The demonstration ran on a 16-core (4 socket, 4 core) Tigerton system running at 2.93 GHz.

Example

As a demonstration of the principles involved in raytracing, let us consider how one would find the intersection between a ray and a sphere. In vector notation, the equation of a sphere with center and radius is . Any point on a ray starting from point with direction (here is a unit vector
Unit vector

In mathematics, a unit vector in a normed vector space is a Vector space whose Norm is 1 . A unit vector is often denoted by a lowercase letter with a superscribed caret or ?hat?, like this: ....
) can be written as

where is its distance between and . In our problem, we know , , (e.g. the position of a light source) and , and we need to find . Therefore, we substitute for :

Let for simplicity; then

Knowing that d is a unit vector allows us this minor simplification:

This quadratic equation
Quadratic equation

In mathematics, a quadratic equation is a polynomial equation of the second degree of a polynomial. The general form iswhere a ? 0. The letters a, b, and c are called coefficients: the quadratic coefficient a is the coefficient of x2, the linear coefficient b is the coefficient of x, and c i...
 has solutions

The two values of found by solving this equation are the two ones such that are the points where the ray intersects the sphere.

If one (or both) of them are negative, then the intersections do not lie on the ray but in the opposite half-line
Line (mathematics)

In geometry, a line is a Curvature curve. When geometry is used to model the real world, lines are used to represent straight objects with negligible width and height....
 (i.e. the one starting from with opposite direction).

If the quantity under the square root ( the discriminant ) is negative, then the ray does not intersect the sphere.

Let us suppose now that there is at least a positive solution, and let be the minimal one. In addition, let us suppose that the sphere is the nearest object on our scene intersecting our ray, and that it is made of a reflective material. We need to find in which direction the light ray is reflected. The laws of reflection
Reflection (physics)

Reflection is the change in direction of a wavefront at an wiktionary:interface between two differentmedium so that the wavefront returns into the medium from which it originated....
 state that the angle of reflection is equal and opposite to the angle of incidence between the incident ray and the normal
Surface normal

A surface normal, or simply normal, to a Flatness is a vector which is perpendicular to that surface. A normal to a non-flat surface at a Point P on the surface is a vector perpendicular to the Tangent space to that surface at P....
 to the sphere.

The normal to the sphere is simply

,

where is the intersection point found before. The reflection direction can be found by a reflection
Reflection (mathematics)

In mathematics, a reflection is a function that transforms an object into its mirror image. For example, a reflection of the small English letter p in respect to a vertical line would look like q....
 of with respect to , that is

.


Thus the reflected ray has equation

.


Now we only need to compute the intersection of the latter ray with our field of view
Field of view

The field of view is the angle extent of the observable world that is visual perception at any given moment.The range of visual abilities is not uniform across a field of view, and varies from animal to animal....
, to get the pixel which our reflected light ray will hit. Lastly, this pixel is set to an appropriate color, taking into account how the color of the original light source and the one of the sphere are combined by the reflection.

This is merely the math behind the Line–sphere intersection
Line–sphere intersection

In analytic geometry, a line and a sphere can intersection in three ways: no intersection at all, at exactly one point, or in two points. Methods for distinguishing these cases, and determining equations for the points in the latter cases, are useful in a number of circumstances....
 and the subsequent determination of the colour of the pixel being calculated. There is, of course, far more to the general process of raytracing, but this demonstrates an example of the algorithms used.

See also

  • Ray casting
    Ray casting

    Ray casting is the use of ray-surface intersection tests to solve a variety of problems in computer graphics. The term was first used in computer graphics in a 1982 paper by Scott Roth to describe a method for rendering Constructive solid geometry models....
  • Scanline rendering
    Scanline rendering

    Scanline rendering is an algorithm for Hidden surface determination#Visible surface determination, in 3D computer graphics,that works on a row-by-row basis rather than a polygon-by-polygon or pixel-by-pixel basis....
  • Beam tracing
    Beam tracing

    Beam tracing is a derivative of the ray tracing algorithm that replaces rays, which have no thickness, with beams. Beams are shaped like unbounded pyramids, with polygonal cross sections....
  • Cone tracing
    Cone tracing

    Cone tracing is a derivative of the ray tracing algorithm that replaces rays, which have no thickness, with cones. Cone tracing is related to beam tracing, but uses circular rather than polygonal cross sections....
  • Global illumination
    Global illumination

    Global illumination is a general name for a group of algorithms used in 3D computer graphics that are meant to add more realistic lighting to 3D scenes....
  • Radiosity
    Radiosity

    Radiosity is a global illumination algorithm used in 3D computer graphics rendering . Radiosity is an application of the finite element method to solving the rendering equation for scenes with purely diffuse surfaces....
  • Photon mapping
    Photon mapping

    In computer graphics, photon mapping is a two-pass global illumination algorithm developed by Henrik Wann Jensen that solves the rendering equation....
  • Distributed ray tracing
    Distributed ray tracing

    Distributed ray tracing, also called distribution ray tracing and stochastic ray tracing, is a refinement of ray tracing that allows for the rendering of "soft" phenomena....
  • Ray tracing hardware
    Ray tracing hardware

    Ray tracing hardware is a special purpose computer hardware design for accelerating real-time ray tracing.Ray Tracing vs. Rasterization ...
  • Line–sphere intersection
    Line–sphere intersection

    In analytic geometry, a line and a sphere can intersection in three ways: no intersection at all, at exactly one point, or in two points. Methods for distinguishing these cases, and determining equations for the points in the latter cases, are useful in a number of circumstances....
  • Specular reflection
    Reflection (computer graphics)

    Reflection in computer graphics is used to emulate reflection objects like mirrors and shiny surfaces....

Software

  • 3Delight
    3Delight

    3Delight is a proprietary, photorealistic, RenderMan Interface Specification-compliant Software_rendering#Offline_rendering renderer.It is developed by Montreal-based Digits 'n Art Research, or DNA in short, a subsidiary of Taarna Studios....
  • Anim8or
    Anim8or

    Anim8or is a freeware OpenGL based 3D computer graphics by R. Steven Glanville, a software engineer at NVidia. Currently at version 0.97, it is a very capable program with many features and tools....
  • Aqsis
    Aqsis

    Aqsis is an free Software rendering suite compliant with the RenderMan Interface Specification standard. It is available under GNU General Public License, with some parts under GNU Lesser General Public License....
  • ASAP
    ASAP (software)

    ASAP The Advanced Systems Analysis Program is optical engineering software used to simulate optical systems. ASAP can handle coherence as well as incoherent light sources....
  • Blender
    Blender (software)

    Blender is a free software 3D computer graphics graphics application. It can be used for 3D modeling, UV mapping unwrapping, texturing, skeletal animation, water simulations, skeletal animation, computer animation, rendering , particle system and other computer simulation, non-linear editing, compositing, and creating interactive 3D applicati...
  • Brazil r/s
    Brazil R/S

    Brazil r/s is a high-quality photorealistic rendering system, created by SplutterFish, capable of fast ray tracing and global illumination.It is used by computer graphics artists to generate content for printing, online content, Broadcasting solutions and film....
  • BRL-CAD
  • Bryce
    Bryce (software)

    Bryce is a 3D computer graphics 3d modeling, rendering and computer animation program specializing in fractal landscapes. The name is taken from Bryce Canyon National Park ? a rugged region with many of the same landscapes that were first simulated with the software....
  • Cinema 4D
    Cinema 4D

    CINEMA 4D is a commercial, cross-platform, high-end 3D computer graphics application, produced by MAXON Computer GmbH of Friedrichsdorf, Germany....
  • form•Z RenderZone Plus
    Form-Z

    form?Z is a computer-aided design tool developed by AutoDesSys for all design fields that deal with the articulation of 3D spaces and forms and which is used for 3D modeling, drafting, Computer animation and Rendering ....
  • Gelato
    Gelato (software)

    Gelato is a Computer hardware-accelerated, Software rendering#Offline rendering renderer created by graphics card manufacturer Nvidia. It was originally intended for use with its Quadro FX Graphics processing unit, although a Quadro class GPU is no longer a requirement, as it now also supports GeForce cards....
  • Holomatix Rendition
    Holomatix Rendition

    Holomatix Rendition is a raytracing renderer, which is broadly compatible with mental ray. Its rendering method is similar to that of FPrime in that it displays a continuously refined rendered image until final production quality image is achieved....
  • Indigo Renderer
    Indigo Renderer

    Indigo is a freeware unbiased render engine capable of highly realistic renders.Indigo uses methods such as Metropolis light transport, Spectral light calculus,...
     (unbiased renderer)
  • Kerkythea
    Kerkythea

    Kerkythea is a freeware rendering system that supports Ray tracing . Currently, it can be integrated with 3ds Max, Blender , SketchUp, Silo and Wings3D ....
  • LuxRender
    LuxRender

    LuxRender is an open source software rendering system for physically correct image synthesis. The program runs on Microsoft Windows, Mac OS X and Linux and exporters are available for Blender_, Softimage_XSI and Maya_....
  • Mental ray
    Mental Ray

    mental ray is a production-quality rendering application developed by Mental Images . Mental Images was bought in December 2007 by Nvidia....
  • Modo
    Modo (software)

    modo is an advanced polygon, subdivision surface, modeling, sculpting, 3D painting, animation and rendering package developed by Luxology, LLC....
  • Picogen
    Picogen

    Picogen is a rendering system for the creation and rendering of artificial terrain, based on Ray tracing . It is Free Software ....
  • Pixie
    Pixie (renderer)

    Pixie is a Free software, photorealistic raytracing renderer for generating photorealistic images, developed by Okan Arikan in the Department of Computer Science at The University of Texas At Austin....
  • PhotoRealistic RenderMan
    PhotoRealistic RenderMan

    PhotoRealistic RenderMan, or PRMan for short, is a proprietary photorealistic RenderMan-compliant renderer.It primarily uses the Reyes rendering algorithm but is also fully capable of doing ray tracing and global illumination....
  • POV-Ray
    POV-Ray

    The Persistence of Vision Raytracer, or POV-Ray, is a ray tracing program available for a variety of computer platforms. It was originally based on DKBTrace, written by David Kirk Buck and Aaron A....
  • Radiance
    Radiance (software)

    Radiance is a suite of tools for performing lighting simulation originally written by Greg Ward. It includes a rendering as well as many other tools for measuring the simulated light levels....
  • Real3D (3D modeling software)
    Real3D (3D modeling software)

    Real3D is the name of a 3D modeling and raytracing program, originally for the Amiga computer and later also for Unix, Mac OS X and Microsoft Windows....
  • Realsoft3D
    Realsoft3D

    Realsoft3D is the name of the successor of Real3D modeling and raytracing program, originally for the Amiga computer and later also for Linux, Irix, Mac OS X and Microsoft Windows....
  • Sunflow
    Sunflow

    Sunflow is an open source global illumination rendering system written in Java .External links...
  • TurboSilver
    TurboSilver

    TurboSilver was one of the original 3D raytracing software packages available for the Amiga and for personal computers in general. It was first revealed by its creator Impulse at the October 1986 AmiEXPO....
  • V-Ray
    V-Ray

    V-Ray is a Rendering engine that is used as an extension of certain 3D computer graphics 3D_computer_graphics_software.The core developers of V-Ray are Vladimir Koylazov and Peter Mitev of Chaos Software production studio established in 1997, based in Sofia, Bulgaria....
  • YafRay
    YafRay

    YafRay is a free software, open source ray tracing program that uses an XML scene description language. It has been integrated into the 3D modelling software Blender , and so can now be used to render scenes made within it directly, without the need for an exporter....


External links

  • - free tutorials on ray-tracing and rendering techniques with source code
  • - An ongoing tutorial of ray tracing in several parts from basic to more advanced topics
  • - Daniel Pohl's follow up on the benefits of ray tracing over rasterization for games
  • – short research articles and new links to resources
  • – thesis about real time ray tracing and its state in December 2006
  • – C++ source code for a Monte-carlo ray/pathtracer (supporting GI) - written with ease of understanding in mind.
  • – still and animated categories
  • – good information on potential for real-time ray traced games
  • - Simple open-sourced Java implementation aimed at Computer Science students.
  • - A simple and highly-optimized ray tracer that draws to a canvas (will not work in Internet Explorer)