Rendering techniques in computer graphics

Rendering is the process that generates two-dimensional or three-dimensional images or videos from a model or a scene compromising multiple models. This process evaluates many factors, such as lighting and shading, geometry, textures, animation, etc. It evaluates these factors and utilizes them to create the final image or video.

Before looking at the many rendering techniques, let's look at the types of rendering.

Types of rendering

There are two types of rendering. These are differentiated based on their requirements for computational resources and the computation speed for each type. The two rendering methods are as follows:

  • Real-time rendering: This type of rendering is used to create on-demand images or frames for videos, which need to be created rapidly. It requires dedicated graphics hardware to be efficient and effective.

  • Pre-rendering: This type of rendering is utilized to create images or frames for videos that are not needed rapidly and can be created ahead of time. It does not require dedicated graphics hardware but rather multi-core central processing units.

Techniques used for rendering

Now, we can look at the various techniques to render images and/or videos.

Note: These are not all the rendering techniques. However, they are the ones most commonly used.

Scanline

This rendering technique projects the three-dimensional space that contains the polygons onto a two-dimensional plane (the screen or viewport). The polygons out of this two-dimensional plane are removed from the rendering process. Afterward, horizontal scan lines are produced, and their intersections with the polygons are noted in an edge table. To evaluate the color of the gap between the edges, interpolationA process of determining the unknown values between two points is used. Finally, the image is rendered with color.

Note: In the case of polygons overlapping, the edge closer (the one with less depth) to the two-dimensional plane is selected.

Scanline
Scanline

Evaluating certain factors can help decide when to use scanline rendering. Scanline rendering is a fast and efficient process for rendering 3D scenes. It achieves this due to its relatively simple process. However, scanline rendering does not produce the highest-quality images as it struggles with handling transparency, complex overlapping geometry, and scenes with irregular shapes or textures. These factors direct us to the scenarios where scanline rendering is the most optimal rendering technique.

Ray casting

This rendering technique projects rays from the camera’s perspective to create its images. For each pixel on the screen, a ray is cast from the camera position through that pixel into the three-dimensional scene. The interactions of this ray are then checked, whether it interacts with a polygon from the three-dimensional scene. If an interaction is discovered, the object’s properties are determined, such as color, reflectivity, transparency, etc. This process is repeated for every pixel on the screen. Finally, the image is rendered with color.

Ray casting
Ray casting

Ray casting has advantages and disadvantages that inform its use cases. Ray casting is a slower process than scanline rendering because it is more computationally intensive. However, it is faster than ray tracing. The image rendered by the ray casting technique aims to produce more realistic images. The images rendered by this method are more realistic than scanline rendering but less than ray tracing. We can use these factors to evaluate when ray casting is best for rendering a scene.

Ray tracing

This rendering technique is similar to ray casting; it also projects a light ray from the camera’s position through the pixel on the screen into the three-dimensional scene. However, afterward, ray tracing processes light interaction (reflection and refraction) and generates secondary rays where necessary. These secondary rays then generate other rays. This recursive process continues until a certain maximum recursive depth (which is customizable) is reached. The color is determined by the color value of the light, object properties, and the reflection coefficient. Finally, the image is rendered with color.

Ray tracing
Ray tracing

The use cases of ray tracing can be decided based on various factors. Ray tracing is highly computationally intensive; it requires a lot of computation to trace the path of light rays. However, ray tracing generates high-quality and realistic images. This is as a result of taking reflections, refraction, shadows, and accurate lighting into account. We can decide when to use ray tracing based on these advantages and disadvantages.

Radiosity

This rendering technique also aims to handle the interaction of light rays with the polygons in the three-dimensional space. This technique is not usually used as a rendering technique but rather to calculate the passage of light rays and render them in conjunction with one of the other three techniques (though it can be used on its own as well). Radiosity breaks down the scene into patchesSmaller surfaces or elements, and the light values of each of these patches are then calculated. Once these light values are calculated, they are used as input for the final rendering process. Finally, the image is rendered with color.

Radiosity
Radiosity

We can decide when to use radiosity based on certain factors. Compared with ray tracing, radiosity focuses more on diffuse reflectionsDiffuse reflections is when light hits a surface and is reflected at many angles. rather than specular reflectionsSpecular reflection is when light is reflected from a mirror-like surface at one angle.. As a result, radiosity can still produce realistic, high-quality images. These images have more natural lighting compared to images produced by ray tracing. However, radiosity is still computationally intensive, especially for complex scenes with many surfaces. We can use these factors to evaluate when radiosity is best for rendering a scene or when to use it with another rendering technique.

Conclusion

Rendering is a process that generates two-dimensional images or frames (for videos) from a three-dimensional scene. Rendering can be done in real-time to generate on-demand images or frames, or it can be done ahead of time. There are various rendering techniques, each with its advantages and disadvantages, that define the most optimal use case for any particular one of them. These techniques include: scanline, ray casting, ray tracing, and radiosity.

Copyright ©2024 Educative, Inc. All rights reserved