Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pixel Texture Builtins (tex_*)

tex_* functions write RGBA pixels directly to the framebuffer before the depth queue is flushed. They are drawn underneath all vtex_* geometry.

Performance warning: Each tex_* call iterates over every pixel in the destination rectangle. A full-screen 1920×1080 call costs ~2 million iterations. For smooth 60fps, keep tex_* calls to a small off-centre region or reduce window resolution.

All functions share the signature prefix:

tex_*(dst_x, dst_y, width, height,  ...params,  palette)

Palette names: "rainbow" · "fire" · "ocean" · "psychedelic" · "neon" · "forest"


tex_checkerboard · ลายตารางหมากรุก

tex_checkerboard(x, y, w, h,  tiles,  r1,g1,b1,  r2,g2,b2)

Two-colour checker pattern. tiles = number of tiles across the width.


tex_gradient · ลายไล่สี

tex_gradient(x, y, w, h,  angle_deg,  r1,g1,b1,  r2,g2,b2)

Linear gradient at angle_deg degrees.


tex_noise · ลายนอยส์

tex_noise(x, y, w, h,  scale, octaves, seed, palette)

Fractal Brownian Motion noise.

ParamDescription
scaleNoise frequency (higher = finer)
octavesFBM octave count (1–8)
seedRandomisation seed

tex_mandelbrot · ลายแมนเดลบรอต

tex_mandelbrot(x, y, w, h,  zoom, cx, cy, max_iter, palette)
ParamDescription
zoomZoom level (1.0 = full set)
cx, cyCentre of view in the complex plane
max_iterIteration cap (higher = more detail, slower)

tex_julia · ลายจูเลีย

tex_julia(x, y, w, h,  c_re, c_im, max_iter, palette)

Julia set with complex parameter c = c_re + i·c_im.


tex_voronoi · ลายโวโรนอย

tex_voronoi(x, y, w, h,  cells, seed, palette)

tex_ripple · ลายระลอก

tex_ripple(x, y, w, h,  freq, cx, cy, time, palette)

Concentric ripple emanating from (cx, cy) in normalised [0,1] coords.


tex_spiral · ลายเกลียวหมุน

tex_spiral(x, y, w, h,  freq, n_bands, time, palette)

tex_halftone · ลายฮาล์ฟโทน

tex_halftone(x, y, w, h,  dot_size, time, palette)

tex_freq_map · ลายความถี่

tex_freq_map(x, y, w, h,  time, speed, palette)

Audio-reactive frequency bar display. Reads from the last fft_bands() call. Call fft_push(samples) then fft_bands(n) each frame to keep it animated.


Palette reference

NameDescription
"rainbow"Full spectrum cycle
"fire"Red → orange → yellow
"ocean"Blue → cyan → white
"psychedelic"High-saturation cycling
"neon"Bright neon green/cyan/magenta
"forest"Earthy greens and browns