Ray Tracing Article Index for
Ray
Articles about
Ray Tracing
Website Links For
Ray Tracing
 

Information About

Ray Tracing




Ray tracing is a general technique from Geometrical Optics of modelling the path taken by light by following Rays of light as they interact with optical surfaces. It is used in the design of optical systems, such as Camera Lenses , Microscope s, Telescope s and Binocular s. The term is also applied to mean a specific Rendering algorithmic approach in 3D Computer Graphics , where mathematically-modelled visualisations of programmed scenes are produced using a technique which follows rays from the eyepoint outward, rather than originating at the light sources. It produces results similar to Ray Casting and Scanline Rendering , but facilitates more advanced optical effects, such as accurate simulations of reflection and refraction, and is still efficient enough to frequently be of practical use when such high quality output is sought.


BROAD DESCRIPTION OF RAY TRACING COMPUTER ALGORITHM


Ray tracing describes a more realistic method than either ray casting or scanline rendering, for producing visual images constructed in 3D Computer Graphics environments. It works by tracing in reverse, a path that could have been taken by a ray of Light which would intersect the imaginary camera lens. As the scene is traversed by following in reverse the path of a very large number of such rays, visual information on the appearance of the scene as viewed from the point of view of the camera, and in lighting conditions specified to the software, is built up. The ray's reflection, refraction, or absorption are calculated when it intersects objects and media in the scene.

Scenes in raytracing are described mathematically, usually by a programmer, or by a visual artist using intermediary tools, but they may also incorporate data from images and models captured by various technological means, for instance digital photography.

Following rays in reverse is many orders of magnitude more efficient at building up the visual information than would be a genuine simulation of light interactions, since the overwhelming majority of light rays from a given light source do not wind up providing significant light to the viewers eye, but instead may bounce around until they diminish to almost nothing, or bounce off into the infinite. A computer simulation starting with the rays emitted by the light source and looking for ones which wind up intersecting the viewpoint is not practically feasible to execute and obtain accurate imagery.

The obvious shortcut is to pre-suppose that the ray ends up at the viewpoint, then trace backwards. After a stipulated number of maximum reflections has occurred, the light intensity of the point of last intersection is estimated using a number of algorithms, which may include the classic rendering algorithm, and may perhaps incorporate other techniques such as Radiosity .


DETAILED DESCRIPTION OF RAY TRACING COMPUTER ALGORITHM AND ITS GENESIS



What happens in nature

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 , Reflection , and Refraction . 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 or Translucent properties, it refracts a portion of the light beam into itself in a different direction while absorbing some (or all) of the Spectrum (and possibly altering the color). Between absorption, reflection, and refraction, 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, and reflective properties are again calculated based on 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. Attempting to simulate this real-world process of tracing light rays using a computer can be considered extremely wasteful, as only a minuscule fraction of the rays in a scene would actually reach the eye.


Ray casting algorithm

The first ray casting (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 is its ability to easily deal with non-planar surfaces and solids, such as Cones and Sphere 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 Modelling techniques and easily rendered.

Ray casting for producing computer graphics was first used by scientists at Mathematical Applications Group, Inc. , (MAGI) of Elmsford, New York , New York . In 1966, the company was created to perform Radiation Exposure calculations for the Department Of Defense . MAGI's software calculated not only how the Gamma Rays 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 s, and eventually feature films – they created much of the animation in the film '' Tron '' 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 of ray tracing

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


Disadvantages of ray tracing

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 and improve image quality where needed.


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. Research over the past decades has explored combinations of computations done using both of these directions, as well as schemes to generate more or fewer rays in different directions from an intersected surface. For example, Radiosity algorithms typically work by computing how photons emitted from lights affect surfaces and storing these results. This data can then be used by a standard recursive ray tracer to create a more realistic and physically correct image of a scene. In the context of Global Illumination algorithms, such as Photon Mapping and Metropolis Light Transport , ray tracing is simply one of the tools used to compute light transfer between surfaces.


Algorithm: classical recursive ray tracing


For each pixel in image {
Create ray from eyepoint passing through this pixel
Initialize NearestT to INFINITY and NearestObject to NULL

For every object in scene {
If ray intersects this object {
If t of intersection is less than NearestT {
Set NearestT to t of the intersection
Set NearestObject to this object
}
}
}

If NearestObject is NULL {
Fill this pixel with background color
} Else {
Shoot a ray to each light source to check if in shadow
If surface is reflective, generate reflection ray: recurse
If surface is transparent, generate refraction ray: recurse
Use NearestObject and NearestT to compute shading function
Fill this pixel with color result of shading function
}
}


IN OPTICAL DESIGN

Ray tracing in computer graphics derives its name and principles from a much older technique used for is not important. It is not only used for designing lenses, as for photography, but can also be used for longer Wavelength applications such as designing microwave or even radio systems, and for shorter wavelengths, such as Ultraviolet and X-ray optics.

The principles of ray tracing for computer graphics and optical design are similar, but the technique in optical design usually uses much more rigorous and physically correct models of how light behaves. In particular, optical effects such as Dispersion , diffraction and the behaviour of Optical Coating s are important in lens design, but are less so in computer graphics.

Before the advent of the is often used in the design of Optical Resonator s used in Laser s.


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.
The general equation of a sphere, where I is a point on the surface of the sphere, '''C''' is its centre and ''r'' is its radius, is
  :<math>\mathbf{S}+t\mathbf{d}-\mathbf{C}^{2} r^{2}\ </math>
  :<math>\mathbf{V}+t\mathbf{d}^{2} r^{2}</math>



This is merely the math behind a straight ray-sphere intersection. There is of course far more to the general process of raytracing, but this demonstrates an example of the algorithms used.


SEE ALSO



REFERENCES



EXTERNAL LINKS