Threenix Developers
Get the Agent Skill

threenix-optimize-tsl

Optimize TSL code for performance

Review and refactor Three.js TSL code to reduce unnecessary shader work while preserving the rendered result.

Get the Agent Skill

What this skill does

  • Map expensive expressions to the vertex, fragment, or compute stage.
  • Reduce redundant expressions, texture samples, and unused nodes.
  • Compare a baseline and refactor when a faithful GPU benchmark fixture is available.

When to use it

Use it when a TSL material, postprocessing pass, or compute graph needs a focused performance review.

Agent skill

Run this skill

$threenix-optimize-tsl

To measure before and after an edit, use the threenix-benchmark-webgpu skill.

After invoking the skill, describe your task:

Review @Shader.ts and its material bindings. Preserve the visible result and report which improvements are measured.

Frequently asked questions

Which kinds of TSL code can this skill review?

It reviews TypeScript TSL graphs used in material slots, postprocessing passes, and compute work. Provide the graph and the code that binds it so the agent can identify the stage doing the work.

Will optimization change the appearance of my shader?

The goal is to preserve the visible result and compatible public interfaces. Any intentional approximation must be called out, and rendered comparisons are needed to check for regressions.

Do I need a GPU benchmark to use the skill?

A static review can run without one. When benchmarking is requested or a suitable local fixture exists, the workflow captures a baseline before editing and compares the same fixture afterward. A fixture that cannot run must be reported as a limitation.

How are measured improvements distinguished from estimates?

The output separates GPU pass timings from hypotheses about shader stages and estimated savings. Repeat comparisons establish measurement noise; pass timing alone does not prove which stage is limiting or predict application FPS.