Shader Properties and How They Work

At a glance, shaders look like just any other program. However, their task is much more specific. Things like inputs and outputs to the shader program don’t necessarily always need to be explicitly defined, as we can see in the example. Shaders have their own programming language similar to GLSL. Because of how GPUs are built, the shader language is optimised for mathematical functions such as matrix multiplication, which is why they are able to perform vertex transformations easily.

Every “object” in the scene has a vertex shader and a fragment shader attached to it. At run time, every vertex will go through the vertex shader corresponding to its parent object. The vertex shader will then output a gl_Position result that is a 4D vector homogenous to screen space. This is then used to generate fragments, which are then run through the respective fragment shader in order to determine a colour output. These fragment colours will then be passed through to the frame buffer where they are then displayed.