What is a Shader?

There are two kinds of shaders – one for the vertex processing stage and one for the fragment processing stage (referred to as both vertex shaders and fragment shaders respectively). The two processes aren’t linked, but due to both working alongside one another to produce a result, they are often referred to together in discussions. The first and arguably most important shader is the vertex shader, which deals with the transformations of vertices – how and where they appear on screen. It achieves this through utilizing various pieces of data, including the actual shape of the polygon being displayed and the location of the vertices making up the polygon, as well as the normals of the vertices. This data helps the shader figure out how light is supposed to fall and reflect off the shape, for example. There is also the mapping data, which places the vertex onto a flat image to figure out what colour it should be.

The second shader is the fragment shader, which takes all this information and converts it into fragments that it sends to the monitor to be displayed.

There are two types of graphics cores that use shaders in specific ways. Programmable graphics cores are more common, and these will use vertex and fragment shaders that are defined and programmed by developers to behave and manage the data in a specific way.

There are also fixed function cores that only perform a specific task in a specific way. Because the hardware is defined to perform that one task, it is usually efficient. Both can be used together in an application. In the following slides, we’ll look specifically at the programmable cores and the shaders that will run on them.