LOBBY // 1F // WASD
[3D VIEW]
✦ Prismatica Language Reference

Overview

Prismatica is a J-inspired array language for shader programming. Evaluation is right-to-left with no precedence rules. Each program outputs a vec3 color (RGB 0–1). The last expression becomes the pixel color.

💡 No parenthesized calls. Write sin t not sin(t). Write d glow 0.05 not glow(d, 0.05). Parens are for grouping only.

Right-to-Left Evaluation

There is no operator precedence. Everything evaluates right-to-left:

3 + 4 * 5 NB. = 3 + (4 * 5) = 23, NOT 35 sin 2 * t NB. = sin (2 * t) a + b * c - d NB. = a + (b * (c - d))

Built-in Nouns

NameTypeDescription
pvec2Pixel position (0–1 each axis)
tscalarTime in seconds (animates)
mvec2Mouse position over canvas (0–1)
piscalarπ ≈ 3.14159
tauscalarτ = 2π ≈ 6.28318

Assignment

name =: expr — assign. Also accept and <-.

r =: 0.15 + 0.05 * sin 3 * t d =: p circle 0.5 0.5 r

Strand Arrays

Adjacent number literals form an array automatically — no brackets needed:

0.5 0.3 0.1 NB. → [0.5, 0.3, 0.1] _1 0 1 NB. → [-1, 0, 1] (_N is negative N) p.x , p.y , 0.5 NB. , appends: p.x , p.y , 0.5 → vec3

Primitive Verbs

VerbMonadic (one arg)Dyadic (two args)
+identityadd
-negatesubtract
*signum (−1/0/1)multiply
%reciprocal (1/y)divide
^exp (eʸ)power (xʸ)
|absmodulo
,ravel (flatten)append/concatenate
<.floormin
>.ceilmax
<:decrement (y−1)less-or-equal
>:increment (y+1)greater-or-equal
~:complement (1−y)not-equal
<less-than
>greater-than
=equal
{first elementindex: i { arr
#tally (count)scale (x * y)
i.iota: i. 4 → [0,1,2,3]

Named Verbs

NameMonadicDyadic x verb y
sin cos tantrig (component-wise)sin(x+y)
sqrt log exp fractcomponent-wise
wavesin(y·τ)·0.5+0.5
noise2D value noise → 0–1
polar[angle,radius] from center
mirror1−2·|y−0.5|
lengthEuclidean length
atan2atan2(y,0)atan2(x,y)
dot_dot(y,y)dot product x·y
glowglow(y, 0.05)d glow k = exp(−max(d,0)/k)
tiletile(y, 4)p tile n = fract(p·n)
rotatep rotate angle
hsvhsv from vec3 [h,s,v]h hsv s,v
hslhsl from vec3 [h,s,l]
circlecircle at centerp circle cx,cy,r
boxp box cx,cy,w,h
ringp ring cx,cy,r
stepstep(0.5, y)edge step x
smoothsmooth(0,1,y)lo,hi smooth x
mixt mix a,b = lerp(a,b,t)
clampclamp(y,0,1)x clamp lo,hi

Adverbs

Adverbs modify verbs. They are written after the verb:

AdverbNameExampleMeaning
/reduce+/ 0.3 0.3 0.3fold array with verb → 0.9
~reflexdot_~ vapply verb to (y, y) → self-dot
+/ 1 2 3 NB. = 1+2+3 = 6 */ 2 3 4 NB. = 2*3*4 = 24 dot_~ p - 0.5 NB. = dot(p-0.5, p-0.5) = squared distance

Conjunction @

f @ g creates a new verb meaning "apply g first, then f":

(sin @ *) t NB. = sin(signum(t)) (glow @ length) p - 0.5 NB. = glow(length(p - 0.5))

Component Access

Use .x .y .z or .r .g .b to extract components from a vector:

p.x NB. horizontal position q =: polar p q.x NB. angle component q.y NB. radius component

Ternary

condition ? then : else — condition > 0 is truthy.

p.x > 0.5 ? 1 0 0 : 0 0 1

Comments

NB. comment or ⍝ comment — rest of line ignored.

Full Example: Pulsing Glow

NB. Glowing circle — J-style, right-to-left r =: 0.15 + 0.05 * sin 3 * t d =: p circle 0.5 0.5 r g =: d glow 0.03 h =: fract 0.08 * t g * hsv h , 0.8 , 1