Skip to content

Source: shader.h

shader

The small set of operations every per-pixel shader is written out of, in fixed point.

A shader is one function that runs per pixel and returns a color, given that pixel's position and the time.

More info

A shared vocabulary

What makes shader code portable is the standard names, so an effect reads the same wherever it came from. This header holds the 2D operations a shader composes into a gradient, a pattern, a warped field or a set of shapes. Marching rays to render 3D is a technique built on top of it, and lives beside it.

Everything is 16-bit fixed point

A value is a fraction of one, a distance is in sub-pixel units, and a color index is a byte because palettes are. The 8-bit forms stay for genuinely 8-bit domains.

Prior art

The GLSL built-in function set, deliberately under the standard names, and IƱigo Quilez's articles on distance functions and their operators.