Core Image Kernel Language

Core Image Kernel Language is Apple’s shader language for writing custom Core Image image-processing kernels. It is a dialect of a supported subset of OpenGL Shading Language with Core Image-specific image-sampling functions.

A kernel is evaluated to produce output image pixels. Its usual structure is:

  1. obtain the current destination coordinate with destCoord();
  2. obtain a source coordinate with samplerCoord() or samplerTransform();
  3. fetch source pixels with sample(); and
  4. return a vec4 color value.

The language provides the sampler type for image inputs and supports scalar and vector types such as float, vec2, vec3, and vec4. It is not identical to desktop GLSL: Core Image defines its own coordinate and sampling functions, and the supported language subset has restrictions.

In the Alioscopy eight-view shader, the language is used to calculate an 8×8 repeating phase pattern, select one of eight image samplers for each color channel, and return the multiplexed RGB result for the current output pixel.

The main reference is Apple’s Core Image Kernel Language Reference. Apple’s CIKernel documentation also describes custom kernels as GPU-based image-processing routines and explains the relationship between samplers, coordinates, and output colors.