Shaders

The Shaders toolbox turns a Function graph into a GPU kernel: a graph that runs once for every pixel (or every element of a field), on the graphics card, all at once. Inside a kernel you read where you are (UV, Element), read input fields and images at that point or near it (Sample, Sample Offset, Sample Image), and build the result from shader nodes: shapes, coordinate tricks such as Kaleidoscope, noise, colors and glows.

Use it when the same small calculation has to run over millions of pixels: generated patterns, image filters, masks over a heightmap.

  • Included in: Divooka Compute Standard only. Start a document from the Computer Graphics workload, or add the GPU Kernels reference with Add reference (Ctrl+Shift+L).
  • Maturity: Preview · Support: Tier 2 (proposed) · what these mean
  • Open it: node library (Ctrl+Shift+Space) → Shaders, or search for a node with Ctrl+Space.
  • Examples and reference: Ctrl+Shift+E → GPU Kernels (5 examples, Divooka Compute) · node reference

New to graphs? Start with Your first program.

Main ideas

A kernel is called like any Function. Another graph calls it with whole images or fields and gets whole images or fields back.

The GPU works in single precision. Results agree with the same calculation on the processor to about seven significant digits.

No GPU, no problem. On a computer without a usable GPU, the kernel runs on the processor.

Example: a kaleidoscope picture

Open GPU Kernels > Kaleidoscope (Ctrl+Shift+E):

  1. Pattern is a Function graph of a point. Circular Inversion turns the plane inside out, Grid repeats it in cells, Zoom magnifies it and Kaleidoscope folds it into mirrored wedges. A Disk with an Outline and a Glow is drawn there.
  2. Picture is the kernel. It reads each pixel's position with UV, sums Pattern at finer and finer scales with Fractal Noise, and colors the sum with Color Ramp, HSL Adjustments and Brightness.
  3. Main calls Picture at 1024 by 1024.

Run it with F5 and select the call to see the picture in the Active Preview. Change a value on Pattern or Picture and it draws again.

More examples to open

Example What it shows
GPU Kernels > Height Band A heightmap mask as a kernel, checked against the processor
GPU Kernels > Blur Reading neighbors with Sample Offset, three passes on the GPU
GPU Kernels > Animated Rings A pattern that moves with Time
GPU Kernels > Relief Map A shaded relief from a heightmap

Tips and limits

  • Chained kernels stay on the GPU. When one kernel's output feeds another, the data stays on the graphics card until the last one returns.
  • Kernel nodes only work inside a kernel. Element, Sample, UV, Time and the rest of the GPU Kernel category are offered only inside a GPU kernel graph.
  • Not in Divooka Explore. A document with a kernel opens there as ordinary Function graphs.

What is in the toolbox

Category Some of its nodes
GPU Kernel Element, Sample, Sample Image, Sample Image Offset and 3 more
Color Brightness, Color From Values, Color Ramp, Grey and 2 more
Coordinates Circular Inversion, Grid, Kaleidoscope, Zoom
Noise Maximum Octaves, Fractal Noise, Value Noise
Vector Make Vector2, Split Vector2, Vector Length
Shape Modifiers Glow, Outline
Shapes Disk

See also