## Introduction

In using standard rendering methods the effect of lighting on the relations between objects is not considered. The effect of lighting is calculated for every object separately. This means that for every object the effects of light are locally calculated. But from a global view for a photo-realistic model also the effect of light reflected from other objects which are situated in the given scene is calculated. The are two methods (photo-realistic rendering) aimed at achieving a photo-realistic model as realistic as possible. This approach is, however, highly time-consuming compared to simpler models.

## Ray tracing

In displaying objects and scenes a quality outcome means that it looks as far as possible photo-realistic. For this it is necessary that the scene considers all physical phenomena which are in effect here. The first method based on searching for light rays, passing through the given scene, is the ray tracing method. An assessment of the resulting intensity of a point in the screen is the assessment of amplitude of the intensity of rays passing through a given point, and following from the observer's eye. In calculating a scene, it is necessary to integrate for a realistic outcome also the removal of hidden surfaces, the calculation of shade and the refraction of a ray.

### Lighting model

For every pixel we apply two steps [1]:

• To form a tree of reflected and refracted rays
• To evaluate, in accordance with a lighting model, the resulting intensity from leaves to the root of the tree.

The equation for the intensity of lighting is given in [1].

### Ray tracing algorithm

The most simple variant of algorithms is ray tracing to an intersection with the closest objects, and then, to find out the color for this point. The classic version of this algorithm is given in [1]. The most simple variant of algorithms is ray tracing to an intersection with the closest objects, and then, to find out the color for this point. The classic version of this algorithm is given in [1]. The most simple variant of algorithms is ray tracing to an intersection with the closest objects, and then, to find out the color for this point. The classic version of this algorithm is given in [1].

\$\$\$APPLET

Applet Raytracing Author: Juraj Onderik

First row of options:

First choice selects view panels
Second choice selects the number of reflections (TraceCount)
Next two choices defines the size of rendered image

Second row of options:
First choice selected object type to create
Clear button removes all objects from the scene

In the view panels:
Zooming - mouse wheel
Panning - right mouse button

By clicking in the camera view a ray visualization is shown.

### General

Version 1.2

• Raycater Draw mode Menu bug fixed
• Raycaster Draw mode "Draw All" improved

Version 1.1

• Added rectangle for moving the whole raycaster
• Moving on scene now with clicking on the rendered image
• Interface improved
• 2D - 3D render option added
• Normalize to screen option added

The main goal is to demostrate functionality of raytracing, more about raytracing on http://de.wikipedia.org/wiki/Raytracing and http://de.wikipedia.org/wiki/Raycasting

### Help

• First start by creating a scene, go to Scene -> Demo Scene -> Empty (you can use this anytimeif you want to clear your scene)
• Continue by adding some objects from Scene -> Add Object -> choose 1 of 4 objects
• Drag and drop the single filled red point with mouse, to change te position of the raycaster
• Drag and drop the two red nonfilled points to change the viewport
• The two big circles (Raycaster in the middle) represents the perspective of view, for most natural render, keep the two circles over each other, so they form one circle
• The single filled red point, with 8 rays, represents the light, you can change its position by drag and drop
• By draging the red rectangle, you move the whole raycaster
• You can move in the scene, by clicking on the 4 rectangle areas in the right render image
• If you change an option (like "enable Light"), you have to raytrace the whole scene again, by going to Actions -> Raycast
• If you want to achive a high end render (better resolution), place the viewport behind the object, try the 3 cubes demos

\$\$\$APPLET

Applet Raytracing 2D Author: Peter Paulis

### Ray tracing acceleration methods

Because the ray tracing algorithm is highly time-consuming, there have been several methods designed for its acceleration. The issue of acceleration can be split into two approaches:

• to accelerate the calculation of an intersection with a ray
• to reduce the number of intersections with objects of the scene

One method for acceleration of the calculation of an object intersection with a ray is based on the use of limit bodies.

### Envelope use

Objects in the scene are arranged according coordinates x, y, z. If the ray is in the direction x, then we take the list of objects arranged by x. After finding out the first object on which the ray falls, the test is finished.

\$\$\$APPLET

### Limiting object use

Because objects are often complex, and have many edges, it is, in order to find object penetrations quickly, advantageous to minimize testing also of those objects which are outside the scene or which are hidden by others. Therefore, we can, instead of complex bodies, use more simple objects, which limit them.

\$\$\$APPLET

Accordingly, where the objects are located in a scene, we can proceed as follows: we establish for each object a limiting body, we establish a limiting body for a group of objects, we establish several limiting bodies for one object, we establish a hierarchy of limiting bodies.

The ray tracing method has one disadvantage: it does not generate all rays coming from a source, but only a finite number. Because ray tracing does not respect all physical laws, we cannot use this method for obtaining some effects, for instance the change of color of the shade of an object due to reflected light from another object.

The radiosity method is based on the physical law of light propagation as a carrier of energy. In describing this method, we consider a closed scene split into small patches. The patches act as light sources, and concurrently, as reflection patches. Each patch can reflect diffusion light and also emit. We are interested now in how light goes from a source to these patches. For each patch we can assign energy E which is emitted by this patch. Energy, which is reflected by this patch, is B. Radiosity is one of the methods for generating attractive and realistic pictures. Moreover, it can be used as an ideal pre-process for a 3D-engine lighting. This method was originally designed for the calculation of heat transfer within a closed environment. Then, Cornell University researchers adopted it for light propagation. The most important thing was to calculate the energy transfer between patches, rather than just direct lighting using a light source.

Example:
Take a scene with a square room, completely closed; so that no light can enter in, nor escape out. Let us imagine that this room has one light source at the top with a positive emitted value. In a conventional rendering, we get lit only those parts directly opposite to the light, however from our practical life we know, that also other walls are lit, despite the fact that the light source is visible from such walls only partially, or it is not visible at all. Light is transferred to these surfaces with the help of surfaces reflecting outside of the scene, hitting several surfaces and lighting them, until the whole energy is dispersed. Often we meet a demonstration of radiosity in pictures which have such a box scene, perhaps with several smaller boxes inside for a presentation of shades.

## Comparison of global rendering methods

The ray tracing method can be used for practically any type of body (objects in a scene), while the classic radiosity method is suitable for plane surfaces. The light source in the ray tracing method is a point, while in the radiosity method it is a patch emitting light. The disadvantage of the radiosity method is the fact that it has no mirror reflection, while the ray tracing method does have this. Despite this, the radiosity method depicts diffusion reflections excellently, while in the ray tracing method they are only from direct sources.

As is seen it is not possible to say that one method is better than others. But, all these methods excellently complement one each another. Perhaps, these methods could be combined in an appropriate way with the purpose of establishing the best rendering method.

Copyright (c) 1999-2018 Juraj Štugel. www.netgraphics.sk