# Raytracing

A far more popular method is raytracing, in which Eqn. (9.5) is solved point by point. The emitted light of a surface point in a certain direction is yielded, in that first the direct lighting for the position is computed. This includes the direct light emitted from the light sources, as well as the shadow computation. For doing so, from the object point outgoing search rays are sent to all sources of light, and it is determined whether further objects of the scene lie between the object point and the light source. If this is the case, then the object point lies in the shadow.

Figure 9.3

Raytracing algorithm: a ray is sent from a virtual viewer eye through the pixel into the scene and is reflected by the surface object

Additionally, for the current point the incident light is determined. This cor­responds to the numeric evaluation of the above integral, and is implemented here, for example, via an amount of randomly distributed search rays in differ­ent directions in space. The points of impact of these rays onto other objects are computed (if available), and the outgoing radiance of these points is deter­mined in the same way. If the outgoing radiance has been computed, the values of all search rays are averaged and added to the direct light term of the current point. The desired image is created by sending a search ray from the eye of the virtual viewer through each pixel of the image into the scene, and intersecting it with the objects [230].

Chapter 9 In this way, a recursive procedure results, which sends rays, intersects them Rendering with objects, determines direct and indirect light terms, averages the intensities

of several rays, and finally passes on the result.

The computation is especially easy if the indirect light is assumed to be emitted only from mirror surfaces. For the definition of the indirect illumination it then is sufficient to just send one ray in the reflection direction and another ray in the transmission direction for transparent surfaces. In Fig. 9.3 we see such a simplified process.

However, for computing the pixels it is often not sufficient to send one search antialiasing ^ ray per pixel into the scene. The results are most likely not satisfactory, es­pecially with data that shows sharp edges. Along the edges, particularly if these run diagonally, jagged patterns appear. In computer graphics, this effect is termed “aliasing”. Here special “antialiasing” procedures are applied to soften the effect.

Within ray tracing, the antialiasing can be implemented so that per pixel sev­eral rays are sent into the scene. The results are then averaged. If an edge runs through the pixels, the colors of the objects are mixed and hence softened. A jagged pattern is here less noticeable [75]. Unfortunately, the price is a consid­erably higher computing time.

Most of the plant images shown in this book were computed with raytracing and antialiasing, though often with simplified versions. Thus, in many scenes it is sufficient to use local lighting in combination with the shadow computa­tion. The tracing of reflection or transmission rays is here not necessary. The processing of the primary rays outgoing from the viewer eye can also be accel­erated by preprocessing, as is shown later in this chapter.