Home

PixelShader

A pixel shader is a programmable stage in modern graphics pipelines that computes the final color and other per-pixel attributes for fragments produced by rasterization. It executes after the vertex shader and after texture coordinates and other interpolated data have been prepared, and before the final color is written to the framebuffer. Each pixel that overlaps a primitive is processed by the pixel shader.

Pixel shaders perform per-pixel lighting and shading, texture sampling, and various visual effects. They can implement

Common shading languages include HLSL for DirectX, GLSL for OpenGL and OpenGL ES, and Metal Shading Language

Historically, programmable pixel shading emerged to replace fixed-function pipelines, enabling more complex lighting and texturing. With

diffuse
and
specular
lighting,
normal
mapping,
parallax
mapping,
ambient
occlusion,
reflections,
refractions,
and
fog.
They
may
output
the
primary
color
and,
in
many
APIs,
additional
render
targets
or
data
used
by
later
stages.
for
Apple
platforms;
in
practice,
the
pixel
shader
is
the
fragment
shader
in
OpenGL
terminology.
The
concept
exists
across
APIs
such
as
DirectX,
OpenGL/Vulkan,
and
Metal,
with
differences
in
syntax
and
resource
binding
but
a
shared
role
of
per-fragment
computation.
modern
GPUs,
pixel
shaders
run
in
highly
parallel
fashion
on
many
shader
units
and
are
complemented
by
vertex
and
geometry
shaders
in
the
programmable
pipeline.
Optimization
considerations
include
branch
divergence,
texture
fetch
costs,
and
instruction
limits.