Documentation

Shader Lab

A sandbox playground for procedural 2D shaders.

Shader Lab

Availability: Divooka Explore Support Tier: Experimental Category: Graphics

Shader development is one of those subjects that looked so remote at first glance but once you get into it, you are hooked.

Welcome to the world of functional shaders! Enjoy the fascination and beauty of deterministic parallel compute if you are able to get in. We will try our best to share with you and get you onboard and appreciate what we have experienced.

Shader Lab GUI Interface

Overview

Shader Lab is a node-based and code-driven environment for building real-time GPU shaders inside Divooka. It allows you to design visual effects by either:

  • connecting nodes visually, or
  • writing GLSL fragment shaders directly

Shaders run entirely on the GPU, making them ideal for:

  • procedural visuals
  • animations
  • generative art
  • post-processing effects

Shader Lab is conceptually similar to tools like ShaderToy or node-based material editors in game engines, but tailored for rapid experimentation within Divooka. It's mostly suited for time-domain animation. Originally developed for 2D procedural effects - as it turns out, the general-purpose computing power of fragment shaders really shine when we remove all constraints and (3D rendering) pipeline stages and focus only on parallel computation (as in Applets section).

Usage

This example shows a simple shader graph producing a time-dependent concentric ring animated output.

Shader Lab usage typically involves:

  1. Defining inputs (uniforms like resolution and time)
  2. Building logic (via nodes or GLSL)
  3. Rendering to a canvas in real time

Key concepts:

  • Fragment shader: Computes color per pixel
  • UV coordinates: Normalized pixel positions (0–1)
  • Uniforms: External inputs (time, resolution, parameters)

Nodes

Playground

The playground allows direct experimentation with GLSL shaders.

You can test shaders directly using below web GL interface. Notice this playground uses u_ for uniforms while other platforms (e.g. ShaderType) might use iXXXX for uniforms.

Fragment Shader

Browse more at examples page.

Default Shader

precision mediump float;
uniform vec2 u_Resolution;
uniform float u_Time;

void main() {
    vec2 uv = gl_FragCoord.xy / u_Resolution;
    gl_FragColor = vec4(uv, abs(sin(u_Time)), 1.0);
}

What this does

  • Normalizes pixel coordinates (uv)
  • Maps them directly to color (gradient)
  • Animates blue channel using sin(time)

Try This

Tip: Try changing main() to below:

void main()
{
    vec2 p = (gl_FragCoord.xy * 2.0 - u_Resolution) / u_Resolution.y;
    float v = 0.5 + 0.5 * sin(10.0 * length(p) - u_Time * 3.0);
    vec3 col = 0.5 + 0.5 * cos(u_Time + vec3(0.0, 2.0, 4.0) + v * 4.0);
    gl_FragColor = vec4(col, 1.0);
}

What this demonstrates

  • Radial distance (length(p)) for circular patterns
  • Time-based animation
  • Color cycling using cosine offsets
  • Procedural pattern generation without textures

Examples

Below is a sample of what you can do. Browse more interesting examples at examples page.

Uniform Gradient

A basic shader mapping UV coordinates directly to color.

Concepts:

  • UV normalization
  • Direct color mapping
  • No animation

Concentric Rings

Creates repeating circular patterns using distance functions.

Concepts:

  • Distance from center (length)
  • Periodic functions (sin)
  • Pattern repetition

Applets

With a bit interactivities, shaders can be used to create much more dynamic outputs.

Mandelbrot

Interactive fractal rendering using iterative complex math.

Concepts:

  • Iterative computation
  • Escape-time algorithms
  • Complex number visualization

Signed Distance Editor

Tool for building shapes using signed distance fields (SDFs).

Concepts:

  • Distance fields
  • Shape composition (union, subtraction)

Raymarch Explorer

Divooka Shader Lab Raymarch Explorer of 3D Traced Scene in Fragment Shader

Typically fragment shader is invoked after rasterization of 3D scene obejcts, but if we encode the scene information and pass directly to the shader, we can effective implement ray tracer using fragment shader alone.

In this raymarch rxplorer example, we render 3D ray-traced scene directly in fragment shader. This is truly the perfect example of how rendering works and the parallel power of little computing kernels that are executing the shaders.

Concepts:

  • Ray marching
  • Rendering foundamentals

Resources