shader-port
Skill4 starsChanged 8 months agoMITView on GitHub
Use when the task is to translate standalone shader source such as Shadertoy, GLSL, WGSL, fullscreen post code, or a legacy WebGL shader demo into a current Three.js implementation path.
In this repository4 other files it gives its agents.
- repo-reviewSkill
- material-labSkill
- perf-doctorSkill
- replicatorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 15 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Use shader-port when the user has a standalone shader source (Shadertoy, raw GLSL, WGSL snippet, fullscreen post fragment, legacy WebGL …
- Distinctive: line 34
Start by classifying the source correctly: single-pass fragment, material logic, multipass post, raymarcher, feedback chain, or …
- Distinctive: line 35
Prefer one honest TSL path first.
- Very specific: line 39
Do not claim a WebGPU path supports raw custom materials.
- Very specific: line 40
Do not claim automatic WGSL-to-TSL conversion.
- Distinctive: line 41
If a port cannot be kept correct and maintainable, say so explicitly and give the narrowest fallback that still works.
- Distinctive: line 45
Keep these three fields separate in every shader-port report:
- Distinctive: line 51
Use one source classification in the final report:
- Distinctive: line 62
Use one status label in the final report:
- Distinctive: line 108
Use this when the shader is mostly math, shading, UV warping, moderate raymarching, or post logic that maps cleanly to the current TSL …
- Distinctive: line 113
no storage buffers or compute requirement
- Distinctive: line 114
no dependency on undocumented driver-specific behavior
- Distinctive: line 119
Use this when most of the port is still readable in TSL but one local function is better kept as native code.
- Distinctive: line 123
Keep the boundary small and named.
- Distinctive: line 124
Prefer one small math or noise helper, not an entire hidden fragment program.
- Very specific: line 125
Treat single-language native helpers as backend-specific unless an equivalent exists for the other backend.
- Very specific: line 129
Use this when correctness depends on resources or execution models that are effectively WebGPU-only in current Three.js, such as compute or …
- Distinctive: line 131
Do not promise WebGL2 parity here unless you have implemented and verified a separate non-compute approximation.
- Very specific: line 135
Use this only when the correct effect depends on raw GLSL and current Three.js does not offer a clean TSL route.
- Distinctive: line 145
Use this when the source or target contract makes an honest port impossible right now.
- Very specific: line 178
Use the references under references/ as the porting decision layer:
- Distinctive: line 200
When that happens, always give one concrete fallback:
- Very specific: line 216
Keep explanations sharp and focused.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Three.js Shader Port
Purpose
Use shader-port when the user has a standalone shader source (Shadertoy, raw GLSL, WGSL snippet, fullscreen post fragment, legacy WebGL demo) and needs:
- a clear source contract before implementation,
- a TSL-first port into current Three.js,
- an honest statement of what cannot be ported cleanly,
- a renderer-aware fallback plan, and
- verification notes that show the result is actually correct rather than merely compiling.
Repository baseline for this skill:
- Three.js
0.180.0 WebGPURendererimported fromthree/webgpu- TSL symbols imported from
three/tsl
Non-Negotiables
- Start by classifying the source correctly: single-pass fragment, material logic, multipass post, raymarcher, feedback chain, or compute/storage-heavy pipeline.
- Prefer one honest TSL path first. Only widen into backend-specific escape hatches when the source actually requires them.
- Distinguish two different fallback types:
TSL-on-WebGL2-backend: still a node and TSL path, typically throughWebGPURendererwithforceWebGL.legacy-WebGL-raw:WebGLRendererplusShaderMaterial,RawShaderMaterial, orShaderPass.
- Do not claim a WebGPU path supports raw custom materials. Current official Three.js docs say
ShaderMaterial,RawShaderMaterial, andonBeforeCompile()are not supported inWebGPURenderer. - Do not claim automatic WGSL-to-TSL conversion. Current official
Transpilersupport isGLSL -> TSLonly. - If a port cannot be kept correct and maintainable, say so explicitly and give the narrowest fallback that still works.
Contract Fields
Keep these three fields separate in every shader-port report:
classification: what the source actually is at intake timeauthoring_route: which implementation path the port usesstatus_label: the final outcome after route choice, fallback, and verification
Use one source classification in the final report:
single-pass-fragmentmaterial-logicfullscreen-postmultipass-postfeedback-chaincompute-storage-pipeline
Status Labels
Use one status label in the final report:
ported-cleanly: pure TSL, same behavior class, no backend-specific escape hatchported-with-scoped-interop: mostly TSL, one or more tightly scoped native code helperswebgpu-only: correct result depends on WebGPU-only resources or compute/storage featureslegacy-webgl-fallback: correct result requires a raw GLSL path onWebGLRendererblocked: missing source information, unsupported feature contract, or no honest maintainable route
Route To Status Mapping
The checked-in fixture corpus and report validator treat these mappings as the allowed default contract:
| Authoring route | Default status label |
pure-tsl | ported-cleanly |
tsl-plus-interop | ported-with-scoped-interop |
tsl-webgpu-only | webgpu-only |
legacy-webgl-raw | legacy-webgl-fallback |
blocked | blocked |
Workflow
- Source contract – record the source URI or files, pass topology, required inputs, coordinate space, precision assumptions, and whether the source is authoritative enough to verify against.
- Classification – write down the source classification explicitly before choosing a port path:
single-pass-fragmentmaterial-logicfullscreen-postmultipass-postfeedback-chaincompute-storage-pipeline
- TSL fit – map each module into one of these routes:
pure-tsltsl-plus-interoptsl-webgpu-onlylegacy-webgl-rawblocked
- Port plan – define the uniform and texture mapping, screen and viewport mapping, pass ordering, history/depth dependencies, and the exact renderer contract.
- Implementation – prefer direct TSL primitives such as
Fn,uniform,varying,If,Loop,screenUV,screenCoordinate,pass, andmrt. UseglslFnorwgslFnonly as narrow escape hatches for isolated helpers. - Fallback decision – if the preferred path stalls, choose the smallest honest fallback: stay TSL but WebGPU-only, stay TSL and use the WebGL2 backend, or drop to a raw WebGL path.
- Verification – confirm compile status on every promised path, verify visual parity against the authoritative source, and record exactly what was preserved, simplified, or dropped.
- Final status – choose the final
status_labelonly after the route and verification notes are stable.
Authoring Route Rules
pure-tsl
Use this when the shader is mostly math, shading, UV warping, moderate raymarching, or post logic that maps cleanly to the current TSL surface.
Good signals:
- single-pass or modest multipass
- no storage buffers or compute requirement
- no dependency on undocumented driver-specific behavior
- the same logic should run on WebGPU and WebGL2 backend paths
tsl-plus-interop
Use this when most of the port is still readable in TSL but one local function is better kept as native code.
Hard rules:
- Keep the boundary small and named.
- Prefer one small math or noise helper, not an entire hidden fragment program.
- Treat single-language native helpers as backend-specific unless an equivalent exists for the other backend. That is a reasoned inference from the official
FunctionNodeAPI exposing explicitwgslandglsllanguage modes.
tsl-webgpu-only
Use this when correctness depends on resources or execution models that are effectively WebGPU-only in current Three.js, such as compute or storage-texture driven pipelines.
Do not promise WebGL2 parity here unless you have implemented and verified a separate non-compute approximation.
legacy-webgl-raw
Use this only when the correct effect depends on raw GLSL and current Three.js does not offer a clean TSL route.
Be explicit:
- this route uses
WebGLRenderer - this route is not supported by
WebGPURenderer - this route is a compatibility or fidelity fallback, not the preferred architecture
blocked
Use this when the source or target contract makes an honest port impossible right now.
Typical blockers:
- missing multipass source buffers or hidden textures
- compute/storage/atomics/subgroup behavior with a required WebGL2 target
- dependence on raw custom material control in a
WebGPUroute - the only possible solution is a large opaque native shader blob that defeats the maintainability goal
Deliverables
- A short report that includes:
- the source classification
- the status label
- the source contract
- the chosen authoring route
- the renderer and backend contract
- the fallback plan
- verification notes
- A minimal runnable Three.js snippet using the chosen route.
- A resource and pass mapping table.
- An explicit unsupported-case note whenever parity is not exact.
- Optional tuning or degradation notes when the shader is expensive.
For checked-in examples under fixtures/, use:
- the fixed report template at
assets/report-template.md - the enum and route contract at
assets/fixture-schema.json - the fixture layout described in
fixtures/README.md - the contract validator in
../../scripts/validate_shader_port_fixtures.py
Reference Pack
Use the references under references/ as the porting decision layer:
references/README.mdfor the default port sequencereferences/source-intake.mdto classify shader inputs and pass topologyreferences/tsl-mapping.mdfor the current TSL landing surfacereferences/coordinate-mapping.mdforfragCoord, UV, ray, and camera translationreferences/resource-mapping.mdfor uniforms, textures, buffers, and multipass routingreferences/porting-notes.mdfor authoring-path decisions, official constraints, and fallback rulesreferences/verification-checklist.mdto validate the final port cleanlyassets/report-template.mdfor the fixed report shape used by the fixture corpusassets/fixture-schema.jsonfor the canonical fixture enums and route contractfixtures/README.mdfor route archetypes and the minimal checked-in fixture contract
When To Call Out Cannot Port Cleanly
Say the port cannot be done cleanly when any of these is true:
- the requested backend contract and the source requirements conflict
- the authoritative source artifact is incomplete or missing critical passes
- the only correct implementation would be backend-specific native code across most of the material
- the fallback would materially change the effect and the user has not accepted an approximation
When that happens, always give one concrete fallback:
WebGPU-only TSLTSL with WebGL2 backendraw WebGL GLSLapproximation with disclosed visual trade-offsblocked pending missing assets or user decision
When Not to Use
- Reference-driven full effect replication that needs the entire
replicatorworkflow. - Pure performance diagnosis or profiling work unrelated to shader translation.
- Pure material-look exploration with no shader source to translate.
Tone
Keep explanations sharp and focused. Prefer small decision tables over prose when comparing routes. Whenever compatibility is discussed, mention the current Three.js baseline and separate documented facts from reasoned inference.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

