ShaderForge

A 1.5B model writes GLSL from a text spec. The reward is pixels & edges. Every shader here compiles and renders live in your browser (WebGL2).

0%SFT only · strict WebGL2
→
100%Run 4 GRPO · unseen spirals (46/46)

Across four Vast.ai runs ($3.08 total) on 150 tasks from three shader families the model never saw code for (wobble, metaball, spiral): GRPO genuinely learned 55/55 wobbles in Run 2 and 46/46 strict-WebGL2 spirals (sim 0.998) in Run 4 from target images alone — while exposing four distinct reward & driver exploits. Under the old pixel metric, Run 4 would claim 72.7%; our shape-aware v2 reward catches a new single-blob metaball shortcut and brings honest strict passes to 32.7% (49/150). Jump to Run 4 · SFT inverted-U cliff · GitHub repo

Contact sheet

The exact same 9 held-out test tasks (first three of metaball, spiral, wobble — not cherry-picked). Toggle between Run 4 (after closing the compiler and pixel-metric loopholes) and Run 2 (before the fixes) to inspect every shader live in WebGL2.

Four runs, four exploits

All rows evaluated on the exact same 150 held-out-family tasks behind Khronos glslangValidator (strict GLSL ES 3.00).

runsetupcompilev1 pixel passv2 shape passhonest passwhat happened
baseQwen2.5-Coder-1.5B26.7%0.7%0.0%0.0%Rarely emits valid Shadertoy GLSL
Run 2SFT 2400 + GRPO v1 (loose Mesa)69.3%48.7%36.7%36.7%Wobble 55/55 honest; spiral Mesa bug (0/46 strict); metaball cross hack (18/49 fooled v1)
Run 3SFT 2400 + GRPO v1 (strict glslang)62.7%4.7%0.7%0.7%Driver bug & cross dead; overfit SFT (loss 0.0003) killed wobble (0/55); 6/7 spirals were abs(atan) mirrors
Run 4SFT 480 + GRPO v2 (strict + Sobel)99.3%72.7%34.0%32.7%Spiral 46/46 (100%, sim 0.998) honest; cross & mirror hacks 0/95; caught single-blob metaball shortcut (47/49 rejected by v2)

Why v1 (72.7%) lies on Run 4: once v2 killed the Run 2 cross hack, GRPO invented a smarter shortcut on metaball — draw Blob A as an exact circle length(p - c) < r and omit Blob B. That single-blob shortcut clears v1 on 49/49 (100%), whereas v2 (0.30·SSIM + 0.35·(1−2·RMSE) + 0.35·SobelDice) catches and rejects 47 of 49 (median 0.724; only 2 scanline-heavy frames slip past 0.85). Honest strict passes in Run 4: 46/46 spirals + 3/55 phase-aligned wobbles = 49/150 (32.7%).

Why Run 3 collapsed: the SFT inverted-U cliff

Before starting Run 4 GRPO, we probed pass@16 (T = 1.15, strict glslang + v2 reward) on 4 held-out prompts per family across SFT warm-start lengths (seen families only, lr = 5e-5):

SFT samples (steps)final losswobble compile / std>0metaball compile / std>0spiral compile / std>0active groups
0 (base)—0.0% · 0/44.7% · 2/40.0% · 0/42 / 12
80 (10)0.2460.0% · 0/46.2% · 2/40.0% · 0/42 / 12
160 (20)0.1414.7% · 2/47.8% · 3/41.6% · 1/46 / 12
320 (40)0.04118.8% · 4/4 (pass 1/4)75.0% · 4/4 (pass 1/4)1.6% · 1/49 / 12
480 (60) · Run 40.004617.2% · 4/4 (pass 2/4)76.6% · 4/417.2% · 4/4 (pass 1/4)12 / 12
640 (80)0.0199.4% · 3/493.8% · 4/46.2% · 3/4 (pass 1/4)10 / 12
2400 (300 · Run 3)0.00030.0% (dead)100% (wrong template)17% (abs(atan))collapsed

Too little SFT (0–160) leaves the model unable to emit valid Shadertoy boilerplate; too much SFT (640–2400) crushes logit entropy and erases coding diversity before RL begins. At 480 seen-only examples, all 12/12 held-out prompts produce nonzero GRPO gradient, pushing Run 4 compile rate to 99.3% and held-out shape similarity from 0.134 → 0.756.

Run 4 breakdown & honest tradeoffs

Spiral: 0/46 → 46/46 (100%, mean sim_v2 0.998, min 0.939). Every single spiral compiles under Khronos glslangValidator and WebGL2, uses the true signed atan(p.y, p.x) formula (0/46 abs(atan) mirrors), and matches pixel-for-pixel.

Metaball: cross hack killed (0/49), single-blob shortcut discovered. GRPO replaced Run 2’s cross with an exact circle at Blob A (length(p - c) < r), dropping Blob B. That scores 0.93 median under v1 (49/49 fooled) but 0.724 median under v2 (47/49 rejected).

Wobble: 54/55 compile, phase-shift local optimum. GRPO fixed the Run 3 u/v declaration error and learned uv.x + amp * sin(...) on all 55 tasks, but settled on p.y (shifted by −0.5 from uv.y) and a sticky constant near 2.19 * pi, so only 3/55 clear 0.85 under v2.

Stability-plasticity tradeoff: training 80% held-out / 20% seen from the lighter sft_480 warm start pushed unseen similarity 5.6× higher, while seen-family test_iid_a dipped from 89% → 66% (v2) / 91% → 77% (v1).

Runs 2 & 3: the earlier exploits we closed

Run 2 wobble (55/55 honest): SFT never produced a compiling wobble shader; GRPO discovered x + a·sin(2π·f·y) from pixels alone. Run 2 metaball cross (18/49 fooled): two bars through the blob centres cleared pixel similarity v1. Run 2 spiral driver bug: assigning vec2 to float passed an old Mesa build on the GPU box (98% there, 0% in strict WebGL2). Adding glslangValidator in Run 3 killed the driver bug and the cross, exposing the mirrored abs(atan) spiral hack (6/7 passes) and the SFT overfitting cliff.

Playground: concentric rings

The task generator in miniature. Move a slider and the spec, the shader and the live WebGL2 render change together.