>binaervarianz >projects >CocoaRay
Chapter 1: Technical Background

Raytracing describes a rendering mechanism for displaying a three-dimensional scene on a two-dimensional, rasterized plane like a computer display or any 2D image inside a window. Although this is a very old technique, it's not what is done in modern graphic hardware to produce its images. This is cause it's quite computational expensive. Nevertheless, this method also has its advantages. The initial computations to calculate the scene may be very complex, but advanced features then come for free. This includes shading, reflection, refraction and occlusion. This leads to a point, where raytracing beats other techniques in term of performance, if the scene is very complex. For this reason Intel is researching in hardware-supported raytrace rendering for example.

But how does it work? The principle is simple: we take a point in space to represent our camera or our eye. In front of this point hovers a rcetangular plane out of small raster elements. This is our display or our window or whatever is displaying the picture we want to create. Behind all that is the scene of 3D objects to render. So we need to do:

  1. Send a ray of light from the camera through the first pixel of our screen into the scene.
  2. Determine if it has hit an object, if not paint the pixle black (or white).
  3. If it hits an object, ask it about its color and paint the pixel accourdingly.
  4. Repeat that for every pixel.

This creates a simple image of our screen. If we now the point where a light ray has hit an object, we can do further calculations:

  • With a new light ray from the hit point to the nearest light source we see if it hits another object (shadow) and how far the light source is away (brightness);
  • If we bounce of the light ray and see what it hits next, we calculate reflexion.
  • If we let the incoming ray right through the first object and look for a second hit, we manage to produce refraction.

Raytracing Concept

>binaervarianz >projects >CocoaRay