How a rendering engine works

A rendering engine needs a little knowledge of how GPU shaders work, and how Open GL works. Open GL works as the bridge or medium between receiving information from the CPU and the GPU. It is not so much a programming language, but more a set of data that is sent to the GPU. The data that is sent from the CPU takes a few data points:

Attributes: Used to assemble the shape and apply lighting

Uniforms: Holds the spatial data. Stored as matrices, it will hold one the model, the world space and the camera space.

Textures: A 2d image of the shape.

All three of these are sent to the GPU. From there, a shader manipulates the data on the GPU. Two different shaders process these. Attributes are only sent to a Vertex shader, the uniforms are sent to both vertex and fragment shaders, and textures are only sent to fragment shaders (Unity Technologies 2020).

Now that the data is received inside of the GPU, several stages are passed through to display the shape. A quick snapshot of it looks like this (Oakden 2020):

As stated before, the attributes are processed inside the vertex shader component. The system breaks the 3D co-ordinates that you give to it and changes it to a new co-ordinate system. Once three vertices have been created with the new co-ordinates, they are sent to the primitive assembly stage. The co-ordinates create the new primitive.

What follows is the rasterisation period. This was discussed in a previous blog post about how to scan the 3D space and test to see if the pixel contains an element in it or not. It does lead us to the fragment processing aspect, in which we take the textures or colours and apply them to the fragments.

While this does create an object for us to be able to see physically rendered onto the screen, light sources do not influence any part of the pipeline unless specified. It can be applied in both the vertex and the fragment shader, but better practice is to apply it to the fragment shader to make more realistic visuals of the object you are rendering.

References:

Unity Technologies 2020, Unity Manual Version: 2019.3, viewed 23 April 2020
https://docs.unity3d.com/2019.3/Documentation/Manual/index.html

Oakden, T 2020, Introduction to openGL, lecture slides, Computer Graphics 10702NAT, The Academy of Interactive Entertainment, delivered 16 March 2020.

Leave a comment