Shader
Also known as: shaders, fragment shader, vertex shader
A small program that runs on the GPU to compute how geometry and pixels are drawn — controlling position, color, lighting, and effects — executed in parallel across millions of elements.
- Primary domain
- Graphics & Media
- Sub-category
- Animation & Rendering
In simple terms
A shader is a small program you write that runs on the GPU to decide how something is drawn. Despite the name, shaders do far more than shading: they compute where each vertex of a 3D model ends up on screen, what color each pixel becomes, how light reflects, and every visual effect from water ripples to motion blur. The magic is scale — a shader runs simultaneously across millions of pixels or vertices, which is exactly what the GPU’s thousands of parallel cores are built for.
More detail
In the graphics pipeline, different shader stages handle different jobs:
- Vertex shader — runs once per vertex, transforming 3D model coordinates into screen positions.
- Fragment (pixel) shader — runs once per pixel-sized fragment, computing its final color, including texture lookups and lighting.
- Geometry / tessellation shaders — optionally create or subdivide geometry on the fly.
- Compute shaders — general-purpose GPU programs not tied to drawing at all (physics, simulation, image processing, and a gateway to GPGPU computing).
Shaders are written in specialized languages — GLSL (OpenGL/Vulkan), HLSL (DirectX), WGSL (WebGPU), or Apple’s Metal Shading Language — and compiled to run on the GPU. They’re written to be data-parallel: the same shader code runs on every element with different inputs, mirroring the GPU’s SIMD-style architecture.
Their flexibility is what made modern real-time graphics possible: instead of a fixed set of built-in effects, developers and artists can program arbitrary visual behavior. Both rasterization and ray tracing pipelines rely on shaders to compute final appearance.
Why it matters
Shaders are where the look of modern games, real-time 3D, and visual effects actually comes from. The shift to programmable shaders (early 2000s) transformed graphics from a fixed menu of effects into an open canvas, enabling everything from realistic materials to stylized art. And because compute shaders let the GPU run general parallel programs, the same mechanism became a foundation for GPU computing far beyond graphics — including the matrix math behind machine learning.
Real-world examples
- A water surface in a game with realistic reflections and ripples is a fragment shader doing per-pixel lighting math.
- ShaderToy is a popular site where people create entire animated scenes in a single fragment shader.
- A compute shader running a particle simulation or image filter entirely on the GPU, with no drawing involved.
Common misconceptions
- “Shaders only do shading/color.” They control vertex positions, geometry, lighting, post-processing, and general computation — “shader” is a historical name for what are really general GPU programs.
- “Shaders are just for games.” Compute shaders do physics, simulation, video processing, and scientific computing; the programmable GPU is a general parallel processor.
Learn next
Shaders run on the GPU within both the rasterization and ray-tracing pipelines.
Read this in a learning path
All paths →This topic is part of a learning path. Start in context to keep prev/next and progress tracking.
Relationships
- Requires
- Related
Neighborhood
A visual companion to the relationships above. Click any node to visit that topic.