home/ atoms/ glsl-mediump-banding

GLSL `mediump` precision makes large `u_time` and fine gradients visibly step — use `highp`

mediump is roughly half-float precision, so large u_time values and fine gradients quantize into visible banding or stepping. For time and coordinate math prefer precision highp float;, or reduce the magnitude with mod(u_time, 100.0) / fract(u_time*speed). However highp is not guaranteed in the fragment stage on all ES1 devices, so guard it with #ifdef GL_FRAGMENT_PRECISION_HIGH and fall back to mediump.

Examples

#ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; #else precision mediump float; #endif

Assessment

A gradient shows visible bands and its animation steps over time under mediump. Explain the precision cause and write a portable precision block that prefers highp.

“`mediump` banding.** `mediump` (~half-float) makes large `u_time` and fine gradients visibly step. Use `precision highp float;` for time/coordinates, or reduce the magnitude”
context/ · L1-instruments/glsl/gotchas.md · chunk 1