La Shader is Shading

the best is yet to come

Turn any image into GLSL fragment shader code through a self-improving agentic loop.

Discovery analysis and iteration grid showing LPIPS scores improving

Why this is hard

Artists don't want to be copied. The question is: how do you use generative AI as a shader-making tool rather than a replacement?

Shader code is notoriously difficult to vibe-code. The gap between a visual idea and the GLSL math that produces it is enormous. Fragment shaders run per-pixel in parallel on the GPU -- there's no memory between pixels, no iteration history, and no way to "look at the whole image."

Current AI models fail at direct image-to-GLSL generation. The output bears little resemblance to the target.

Claude attempting to generate a shader from an image directly
Direct LLM shader generation: the output doesn't match the target.

How it works

A vision model + code-editing LLM iteratively improve a shader to match a target image.

Phase A: Discovery
Reference Text Anchor shader
+
Target Image User upload
→
Gap Analysis GPT-4.1-mini
→
Tailored Prompts SIMILAR | DIFFERENT | BRIDGE
↓
Phase B: Iteration Loop
Generate / Edit Shader GPT-4.1-mini
→
Render Frames ModernGL
↓
Score LPIPS / AlexNet
+
Critique GPT-4o-mini (Vision)
↓
Log & Trace Weave / W&B
↑ repeat N iterations · feedback drives the next edit ↓
↓
Best Output Lowest LPIPS score

MVP walkthrough

Upload a target, ground with a reference

Provide any image as the visual target. Optionally pair it with a reference shader (e.g. a ShaderToy effect) as a starting point. The Discovery phase analyzes what techniques to borrow, what to change, and what to adapt.

App input section with target image

Discovery + Iteration

The agent runs gap analysis, classifying techniques as SIMILAR, DIFFERENT, or BRIDGE NEEDED. Then it iterates: generate GLSL, render frames via ModernGL, score with LPIPS, critique with GPT-4 Vision, and feed back. Watch the LPIPS scores converge.

Iterations grid showing LPIPS scores improving across iterations

VLM Critique

Like a studio critique: the vision model identifies COLOR DELTA, WHAT'S WORKING, and WHAT NEEDS TO CHANGE. Color matching is always the #1 priority. This structured feedback drives the next edit.

Critique modal showing structured VLM analysis

Evaluation with LPIPS

LPIPS (Learned Perceptual Image Patch Similarity) uses a pre-trained AlexNet to measure perceptual distance -- how different two images look to a human, not how different they are pixel-by-pixel. Lower is better.

LPIPS perceptual similarity paper

Traced with Weave

Weave dashboard showing traced edit_shader calls across iterations
Full Trace Every LLM call -- discovery, generation, editing, repair -- is traced end-to-end.
Error Recovery Compile errors are caught, diagnosed, and auto-repaired. The agent consults learned GLSL rules before every generation.
Visibility Full observability into the agent's decision-making at every iteration: prompts, responses, scores, and critique.

GLSL compile rules the agent learned

GLSL COMPILE RULES -- check these before outputting any shader: 1. VECTOR CONSTRUCTORS: exact component count required. vec3(vec2, float) OK | vec3(vec2, vec2) WRONG (4 into 3) 2. MATRIX MULTIPLY: matrix on LEFT only. mat2*vec2 OK | vec2*mat2 WRONG 3. MISSING FUNCTIONS: every function call needs a definition above the call site. 4. CASCADING ERRORS: fix the FIRST error only. COMMON ERRORS: "Incompatible types in initialization" → wrong component count "'*' does not operate on 'vecN' and 'matN'" → put matrix on LEFT "undeclared identifier 'X'" → add missing function definition

Check it out