Vertex and Pixel Shaders
The two main GPU programs in every material
Also known as: Vertex shader · Fragment shader · Pixel shader · Shader basics · GPU shader · Compute shader
Definition
A shader is a small program that runs on the GPU. The vertex shader runs once for every vertex of a mesh and decides where it appears on the screen, so it handles transformations, skinning and effects like wind. The pixel shader, or fragment shader, runs for every pixel the mesh covers and decides its final color, using textures, lighting and material settings. Compute shaders run general calculations outside the drawing process.
In production
Material graphs in Unreal Engine, Shader Graph in Unity and the shader editor in Blender generate these programs, so artists build shaders without writing code. Costs split in two: vertex cost grows with triangles and effects such as World Position Offset, and pixel cost grows with the screen area covered, the number of texture samples and overdraw. Knowing which one a material stresses helps when optimizing.