What Are Precision Qualifiers in GLSL ES?

In OpenGL ES Shading Language (GLSL ES), precision qualifiers such as lowp, mediump, and highp determine the numerical precision, bit depth, and dynamic range used to calculate and store floating-point and integer data on the GPU. These qualifiers allow developers to strike an optimal balance between visual fidelity, memory bandwidth, battery efficiency, and hardware performance, which is especially critical on mobile GPUs and embedded hardware architectures.

Why Precision Qualifiers Exist

Desktop GPUs typically execute all floating-point shader calculations at standard 32-bit single precision (FP32) or even 64-bit double precision (FP64), often ignoring precision qualifiers entirely. Mobile GPUs, however, are severely constrained by thermal limits, power consumption, and memory bus bandwidth.

To mitigate these constraints, mobile hardware includes dedicated Arithmetic Logic Units (ALUs) and registers capable of operating natively at reduced precision, such as 16-bit half precision (FP16) or 8-bit/10-bit integer formats. GLSL ES precision qualifiers act as explicit hints to the shader compiler, specifying the minimum accuracy required for a given variable.

The Three Precision Levels

GLSL ES defines three standard precision qualifiers:

Choosing the proper qualifier depends on the mathematical sensitivity and numerical range of the data being processed:

Setting Default Precision

Typing precision qualifiers on every variable declaration can clutter shader code. GLSL ES supports setting default precision values for entire types at the top of a shader module:

// Sets default precision for all float variables in this shader
precision mediump float;
precision highp int;

// Override the default for specific critical variables
attribute highp vec4 a_Position;
varying lowp vec4 v_Color;

In the vertex shader, GLSL ES defaults float and int to highp. In the fragment shader, however, there is no mandatory default float precision in GLSL ES 1.0/WebGL 1.0. Failing to define a default float precision in the fragment shader will result in a compilation error on compliant implementations.