compiling-wgsl
Installation
SKILL.md
Compiling WGSL
scripts/forge is a pure-Python WGSL toolchain (numpy is the only dependency): a parser
that follows the spec's template-list rules, a minifier, a shape compiler, and a GLSL
front end that rewrites WebGL and Shadertoy GLSL for naga (and glslang) to translate. It came
from oaustegard/experiments/wgsl-forge, whose RESULTS.md holds the measurements quoted
here. Set SKILL=/mnt/skills/user/compiling-wgsl (or this directory) and run every
command with PYTHONPATH=$SKILL/scripts.
When NOT to use this skill
| Situation | Use instead |
|---|---|
| A raster image (photo, PNG) should become vector shapes | image-to-svg, then this skill on its SVG |
| The output is a PNG, PDF or SVG file rather than a shader | drawing-with-pycairo |
| Charts or dashboards | charting, charting-vega-lite |
| HLSL or Metal | not covered; naga reads SPIR-V (naga in.spv out.wgsl), so HLSL can go through DXC to SPIR-V first |
GLSL for desktop OpenGL with #version 330 or older, or code using iChannel buffers (multi-pass Shadertoy) |
converts, but the multi-pass plumbing (render targets, feedback) is host code you write |
| A shader whose host reads names back by reflection (a binding library that matches struct member or function names) | run with --keep name1,name2, or do not rename |