Game dev
Saved & recent

Shader

Related terms: vertex shader, fragment shader, pixel shader, GLSL, HLSL

A small program that runs on the GPU. The vertex shader runs once per vertex and outputs where that vertex lands on screen. The fragment shader (or pixel shader) runs once per covered pixel and outputs its color.

Lighting, water, outlines, dissolve effects: all of it is shader code. Shaders run in parallel for millions of pixels, so each one must be short and self-contained.

// fragment shader: basic lighting float light = max(dot(normal, lightDir), 0.0); color = texture(albedo, uv) * light;

Further reading
LearnOpenGL: shaders
model vertices vertex shader fragment shader texture normal light fragment sample
An illustrative opaque, single-sample orthographic pass: the vertex stage transforms one shield mesh, then the fragment stage computes color per fragment. UVs and normals are interpolated across the transformed triangles. The highlighted sample multiplies its texture color by a Lambert factor of 0.36.

View in the full Game dev collection