La Shader is Shading
the best is yet to come
Turn any image into GLSL fragment shader code through a self-improving agentic loop.
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.
How it works
A vision model + code-editing LLM iteratively improve a shader to match a target image.
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.
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.
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.
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.
Traced with Weave