Home

Shader

A shader is a small program that runs on the graphics processing unit (GPU) to determine how to render graphics. Shaders are part of a programmable graphics pipeline, replacing fixed-function stages with configurable code that can implement vertex transformations, lighting calculations, texture sampling, color output, and post-processing effects. They are designed to run in parallel across many lightweight threads to handle large numbers of vertices or pixels efficiently.

Common shader types include vertex shaders, fragment (pixel) shaders, geometry shaders, tessellation shaders, and compute shaders.

Shaders are written in shading languages such as GLSL (OpenGL Shading Language), HLSL (High-Level Shading Language

Historically, shaders emerged with programmable GPUs in the late 1990s, enabling more flexible and realistic rendering.

A
vertex
shader
processes
each
vertex,
outputting
its
position
in
clip
space
and
optionally
data
for
later
stages.
A
fragment
shader
computes
the
color
of
each
pixel
or
sample,
determining
the
final
image
color.
Geometry
shaders
can
generate
new
primitives
from
input
geometry,
while
tessellation
shaders
refine
geometry
for
smoother
surfaces.
Compute
shaders
perform
general-purpose
computations
not
directly
tied
to
a
specific
rendering
pass,
enabling
tasks
such
as
physics,
simulations,
and
image
processing.
for
DirectX),
and
Metal
Shading
Language
for
Apple
platforms.
These
are
compiled
by
graphics
drivers
into
GPU-specific
code
or
bytecode,
often
using
an
intermediate
representation
like
SPIR-V.
Modern
graphics
engines
use
shaders
to
implement
lighting
models,
including
physically
based
rendering
(PBR),
texture
mapping,
shadows,
and
various
post-processing
effects.
Today,
shader
programs
are
fundamental
to
real-time
rendering,
enabling
visually
rich,
dynamic,
and
scalable
graphics
across
platforms.