← All resources

Functions: Mix

Auto-discovered

Blog Intermediate

Xor

Visit resource ↗

Description

Functions: Mix is a GM Shaders Mini tutorial by Xor on the shader mix function, covering the math behind linear interpolation and less obvious uses beyond blending two colors.

It explains mix as x+(y-x)*a, behavior outside the 0-1 range for extrapolation, saturation via grayscale mixes, brightness and contrast control, animating positions, radial blur and chromatic aberration by mixing UVs toward a focus, texture-page UV remapping, a remap helper that maps one range into another, and why OkLab mixes can look more natural than RGB blends.

It is aimed at intermediate shader writers who already call mix for colors and want clearer math plus unusual tricks. Comfort with float and vector types in GLSL-style shading is assumed.

The piece is a free article with short formulas and code snippets, plus pointers to a related OkLab write-up and a SimonDev blending video.

It is useful as a compact reference when mix should drive materials, motion, or post effects rather than only lerp colors.