An LLM-driven search proposes hundreds of faster shader variants. Most are approximations, and each must look right for every camera, time and light the app can produce — which can only be sampled.
Sample those conditions from a unit cube, render original and candidate, and stop a Bayesian test as soon as it is sure. Edits that resemble ones already proven safe may stop earlier.
Up to 2.19× faster Shadertoy shaders, 1.89× on MaterialX, 1.70× on a Godot render pass, with 47–85% fewer validation frames.
LLM-driven evolutionary search can propose many rendering-code optimizations, but each approximate candidate must still be validated across dynamic viewing, lighting, material, and temporal conditions. We use a backend-specific Primary Render Parameters Space (PRPS) to sample rendering conditions, and formulate candidate acceptance as a Bayesian sequential test over the rate at which FLIP error exceeds a user threshold. To reduce rendering work, the validator adapts an empirical SAFE decision threshold: globally from the observed distribution of rejected candidates, and per candidate from LLM-derived mutation embeddings compared with previously validated neighbors. Rendered evidence remains the acceptance basis; previous candidates only modulate how strict the sampled-evidence threshold must be before acceptance. Across Shadertoy shaders, MaterialX-generated GLSL materials, and two Godot shader settings, the pipeline finds 1.12×–2.28× speedups under stated error thresholds, while replay and live-pipeline studies reduce validation frames by 47–85% relative to conservative validation with few disagreements against conservative replay labels. The resulting contribution is an efficient sampled-validation mechanism for open-ended rendering optimizers, with guarantees defined over sampled PRPS evidence.
The search loop follows FunSearch and AlphaEvolve: an LLM proposes patches, and an island-based evolution keeps the fast ones. For rendering, correctness is perceptual, depends on viewing conditions, and can only be sampled. So we build the system around the validator.
Every dynamic input the application exposes (camera, time, lights, material inputs, environment) becomes one coordinate of a unit cube r ∈ [0,1]D. The validator samples the cube; a small adapter maps points to renderer state. D ranges from 1 to 34.
A frame is an exceedance if its FLIP error exceeds ε. With k exceedances in n frames, the rate p ~ Beta(1+k, 1+n−k). Accept when P(p < τ) ≥ γsafe, reject when it falls below 1−γhigh.
How much clean evidence acceptance needs is set per candidate. Mutations whose LLM embeddings resemble validated safe edits may stop early; risky ones stay at the conservative 99%. Rejection is never relaxed.
OriginalOurs|Error| ×20
Bad candidates are rejected within tens of frames. The expensive ones are the safe ones: under one fixed 99% threshold, each needs 916 renders before it can be accepted. Try it:
1Each square is one sampled condition, rendered by the original and the candidate: FLIP within ε or an exceedance
2Counts give a belief about the rate p:
3Stop once P(p < τ) crosses a threshold
Trust lowers that bar per candidate. An edit whose LLM description resembles edits already proven safe may stop after a few renders; unfamiliar or risky edits keep the full 99%:
At full trust, the learned thresholds accept a clean candidate after 34–140 renders instead of 916, depending on the session.
Renders needed to accept a clean candidate
Eleven Shadertoy shaders, three MaterialX materials compiled to GLSL, and two Godot workloads, one of them an engine-internal render pass. All results use τ = 1%.
(a) Speedup of the best accepted program
(b) Validation frames vs. conservative, session replay
(c) Validation samples per candidate, live runs


What the LLM actually changes
// stripe pattern around the lighthouse- cos(atan(pos.x, pos.z) * 6.0)+ float r_inv = inversesqrt(dot(pos.xz, pos.xz));+ float c = pos.z * r_inv, c2 = c*c, c4 = c2*c2;+ 32.*c4*c2 - 48.*c4 + 18.*c2 - 1.; // T_6(c)
Exact math, not an approximation: cos 6θ is the Chebyshev polynomial T6(cos θ), so atan and cos disappear.

// ocean ray-march+ if (ray.y >= 0.0) return 0.0; // looking up: no ocean- for (int i = 0; i < 100; i++) {- if (h < .01 || t > 100.0) break;+ for (int i = 0; i < 80; i++) {+ if (t > 40.0 || h < .01) break; // far ocean: stop at 40
Rays aimed at the sky skip the ocean march, and the march gives up past 40 units instead of 100. Only the far horizon can change, so the validator decides.

// path tracer: one bounce per iteration absorbMul *= 0.8; // every bounce absorbs some light+ if (absorbMul < 0.02) break; // under 2% left: stop bouncing rayStartPos += rayDir * h.rayLength; rayDir = normalize(reflect(rayDir, h.normal) + jitter * roughness);
Each bounce keeps 80% of the light, so after 18 bounces a path carries under 2% and stops, instead of running to 32. A classic path-tracing approximation, accepted only because sampled frames stay within ε.

// distance to the tentacles- float fb = fbm(vec3(10.1*x+offx, 10.1*y, 10.1*z));- if (fb > 0.0)- di = di + 0.00000003*fb;+ // a 3e-8 bump is below float precision here: skip the FBM return sqrt(di);
A noise call adds a bump of 3·10−8, far below what a pixel can show. Removing it changes nothing visible and saves about a third of the frame time.

// audio-reactive second stage- intersectStage(surface, pp,- rotateMat(angle.x, angle.y, angle.z) * rot, scale);+ if (beat >= 32.0) {+ intersectStage(surface, pp,+ rotateMat(angle.x, angle.y, angle.z) * rot, scale);+ }
The second stage is invisible before beat 32, so it is skipped there. Only a time-aware validator can accept this: it has to sample frames on both sides of the beat.

// samples per quality preset, 2 depth samples each- const int num_taps[5] = { 3, 5, 12, 0, 0 };+ const int num_taps[5] = { 2, 3, 6, 0, 0 }; // plus: merged max/clamp pairs, reciprocal multiplies
Approximate by design: half the samples per pixel in an engine render pass, kept because the error stays within the ε = 0.1 budget.
One run, as a search tree
Best accepted program per scene, with what the whole optimization session cost: LLM API calls and rented GPU time for rendering and validation.
We thank Johannes Schudeiske for taking part in the discussions that shaped this project, our student Ilia Bozhinov for the early studies, Kirill Bazhenov for his help in connecting us with industry, and Angelo Pesce, Brian Karis, Anton Kaplanyan, Max Strakhov and Harold Westlund for sharing their industry expertise and feedback.
We are especially grateful to Inigo Quilez, who kindly granted us permission to use his shaders in this work, and to all Shadertoy, Godot and MaterialX authors whose work we build on. All shaders remain the property of their authors; their licenses are listed below.
Shadertoy shaders without an explicit license fall under Shadertoy's default CC BY-NC-SA 3.0 Unported.