All posts

AI-assisted shader authoring

/ master’s thesis / KTH

My master’s thesis: AI-Assisted Real-Time Shader and Material Authoring in a Browser-Based Game Engine. I did it at Nilo, and the work became Nilo’s Shader Editor.

Read the full thesis (PDF)

Shader Editor with generated controls: colours, ring tilt, height, width, jaggedness, noise, flow, glow and roughness.
A generated material in the Shader Editor. Every slider on the left came out of the generated module.

The problem

Making a material for real-time 3D means turning an appearance in your head into a program that decides how a surface is rendered. You can describe that appearance in plain language and have a model write the code, but the code still has to fit the engine’s interfaces. It should also leave parameters you can keep tweaking after it’s generated.

What I built

The workflow generates TypeScript modules written in the Three.js Shading Language (TSL), inside a typed material-descriptor contract. Each generated module goes through source checks, type checking, execution and descriptor validation. If something fails, the diagnostics go back to the model for up to two repair attempts. Accepted properties show up as editable controls in the engine.

The same material in code view: TSL uniforms and a createShader function.
The same material as code. Uniforms at the top become the editable controls.

How I evaluated it

192 generation runs: four prompts, six models, and two conditions, with curated example bodies either included or left out. For each run I recorded the compilation outcome, repairs, latency, estimated cost and how many validated editable controls it exposed. Four hand-authored descriptors served as a baseline for the control count.

What came out

  • 174 of 192 runs succeeded on the first attempt, and 189 within three.
  • Successful descriptors exposed 4.18 controls on average with examples and 3.36 without.
  • Every prompt’s generated mean stayed below the hand-authored count, so my hypothesis that generation would expose more controls wasn’t supported.

So producing accepted, editable descriptors is feasible within this pipeline, and examples seem to influence which controls get exposed. The thesis doesn’t isolate what the constraints or repairs contribute, and it doesn’t show security isolation, visual correctness or usability. Those are the next questions.

Supervisors: Christopher Peters (KTH) and Nuno Leiria (Nilo). Examiner: Iolanda Leite. September 2026.

All posts