Understanding shaders
In graphics, a shader is a special program used to determine how a virtual object is drawn on the screen. It calculates the color of each pixel based on the geometry of an object, the color or texture of the object, and the light falling on the object’s surface. Shaders are written in a shading language. There are three general types of shaders—fragment, vertex, and geometry. These shaders allow graphics programmers to intercept the render pipeline shown in Figure 17.1:
Figure 17.1: The render pipeline
The process of rasterization is how 3D virtual objects get drawn onto the screen as pixels. It starts out as a 3D mesh or model with vertices, normals, UVs, and tangents. The vertex processor (1 in Figure 17.1) computes the normalized coordinate-space positions of the vertices and associated values, taking them from model coordinates and converting them into screen coordinates. The mathematics for this process was revealed...