The majority of CGI (Computer Generated Imagery) is created using ray tracing and rasterising algorithms. These complex calculations are commonly referred to as the process of 3D rendering. The algorithms are applied to a virtual environment, including several 3D models, materials and a range of lights, allowing the creation of a final 3D rendered image.
In the reality we can see the world, because light rays are emitted from a source (the sun), reflects off an object and makes their way to the human eye, where they are detected. In most cases light will bounce off more than one object before being received.
Ray tracing works in the same way but reversed. Light is emitted from a virtual camera and traced for a specified number off bounces (collisions with objects). At each bounce, a radiance is calculated by averaging the surrounding rays, this is used to calculate the colour of each individual pixel.
Ray tracing is very accurate and is classed as an “unbiased” 3D rendering algorithm, unfortunately it can be incredibly time consuming. When millions of light rays need to be calculated, a single image can take hours or even days to render. To reduce render times, ray tracing can be used in conjunction with faster, less accurate methods. Often, ray tracing is used as the primary method, with a faster secondary stage such as rasterisation.
To represent a 3D model in a 2D image, the 3D data needs to be flattened and converted into pixels. The process of rasterisation is used to create the pixels that make up the image.
As a "biased" algorithm, rasterisation is used to project a 3D object into a 2D shape. To calculate what each pixel will then show, the 2D shape is used as a guide to colour each individual pixel. Each pixel’s colour will be chosen dependant on whether it sits within or outside of the projected 2D shape.
The colour of a rasterised pixel is only based on its position and therefore does not consider any form of radiance. This often leaves sharp jagged edges on rasterised images. Anti-aliasing can be used to solve this.
In some 3D rendering processes, anti-aliasing renders the image at twice the resolution and uses the data to take an average, producing a smoother image. To speed up render times, anti-aliasing can be used selectively, in only the areas that need it, such in high detail areas of a scene. Anti-aliasing is quite commonly used within the gaming industry to account for the fast rasterising algorithms.