1实现原理 · 为什么它能做到
能力基础是「每像素算一次颜色」的 GPU 并行模型:先立这个前提,再把所有效果都写成 fragment shader(uniform 的纯函数)。
Write GPU fragment shaders for generative motion, gradients, transitions, and post-processing. Fragment shaders run once per pixel in parallel — the most performant way to do full-screen generative motion.
骨架固定为「归一化坐标 → 宽高比校正 → 颜色」,并把 IQ 余弦调色板作为最短路径给出(a + b*cos(2π(c*t+d)))。
The cosine-palette line above (Inigo Quilez palettes) is the fastest route to a good-looking animated gradient: `a + b*cos(2π*(c*t + d))` with tunable `a,b,c,d` vec3s.
四个基本积木构成全部配方:smoothstep+mix(配 fwidth 做一像素宽抗锯齿边)、无纹理 hash/值噪声与 fbm、SDF 形状、domain warping(噪声喂噪声)。
**smoothstep + mix** are the workhorses. `smoothstep(e0, e1, x)` gives a smooth 0→1 ramp; `mix(a, b, t)` linearly blends. Antialias an edge by the width of one pixel:
图像转场统一成「两张纹理 + 一个 u_progress」模型:噪声阈值溶解、按位移图推 UV、glitch(按行 hash 位移 + RGB 通道偏移)。
Sample two textures and blend per pixel by a progress uniform `u_progress` (0→1).
Three.js 接法给到可跑的完整骨架(uniforms + ShaderMaterial + 2×2 平面覆盖裁剪空间 + 无投影 camera),并区分「全屏 pass 直接输出 position」与「真实几何才需要 vUv」。
For a full-screen pass with a plain camera, write the vertex shader to output `position` directly and skip projection (as above). For shaders applied to real geometry, pass `vUv` from the vertex shader via `varying vec2 vUv;
移动端/性能规则是 GLSL ES 的硬约束而非风格建议:循环必须常量上界、octave ≤5–6、热路径避免分支、少 texture2D 与依赖式读取、按需 highp/mediump,并给出 ES 3.00 迁移要点。
Loops must have **constant bounds** in GLSL ES — no dynamic loop counts. Keep fbm octaves ≤ 5–6.
确定性来自「shader 是 uniform 的纯函数」:全部动画只经 u_time(转场再加 u_progress),shader 内随机本就来自确定性 hash(uv),无需逐帧播种。
The shader is a pure function of uniforms — drive everything from `u_time` (and `u_progress` for transitions). All animation flows through one uniform you can pin.
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| cli | npx playwright screenshot(验证回路:截 file:// 页面在 ?t=2.0 的冻结帧) |
| cli | 仓库根共享脚本 scripts/seek-shot.sh、scripts/contact-sheet.sh(截图与接触表拼图;不在 skill 目录内) |
| cli | ffmpeg / ffprobe(contact-sheet.sh 与 probe-mp4.sh) |
| network | 交付 HTML 经 importmap 从 CDN 取 three(产物期,浏览器端拉取) |
4风险提醒 风险提醒:蓝色 · 知晓即可
- 验证回路依赖 npx 远程获取 Playwright 与 Chromium — SKILL.md 内联 `npx playwright screenshot`(仓库根 seek-shot.sh 为 `npx -y playwright screenshot`):首次运行会安装远程包并下载浏览器二进制,版本由上游决定。
- GPU/无头渲染差异会造成「像 bug」的输出 — 无 GPU 时走 swiftshader 软件渲染:大 fbm/高分辨率下可能变慢或精度不同,banding/NaN 判读需区分「着色器写错」与「后端差异」。
- 产物期从 CDN 取 three、可能还有远端贴图,均未锁定版本 — 输出契约要求 importmap 指 CDN;转场用的 tex0/tex1/dispTex 若指向远端地址,长期在线的产物需自托管并固定版本,否则会出现 404 或静默变更。
- 仓库根脚本不在 skill 目录内 — scripts/seek-shot.sh、scripts/contact-sheet.sh 位于仓库根;只装 skills/shader-glsl 时引用悬空,需自行改用等价的 playwright/ffmpeg 命令。
5第二遍独立确认
- [ok] 「skill 目录内无脚本」是否成立(蓝档的关键前提) — 文件清单实证:skills/shader-glsl/ 下只有 SKILL.md、README.md(0 B)、references/glsl-cookbook.md。SKILL.md 引用的 `scripts/seek-shot.sh` 属仓库根资产,已在 reason/risks 记录为「单装 skill 目录会悬空」。
- [ok] 凭证/环境变量读取是否存在 — 本仓(webgl-animation-skills)全仓 `process.env|API_KEY|TOKEN|SECRET|Authorization` 零命中;本 skill 的 credential_reads 为空成立。
- [ok] 是否有更高的触发条件被漏掉(红档特征) — `sandbox|automationcontrolled|no-verify|stealth|bypass|ignoreHTTPSErrors|dangerously` 全仓零命中;无任意代码执行面(交付物是浏览器沙箱内的 GLSL/JS)。
- [ok] 「shader 是 uniform 的纯函数 → ?t=N 可复现」是否与 harness 代码相符 — harness 段在 `?t=N` 分支直接 `frame(parseFloat(t))`(同时把 u_progress 钉到 N),非冻结分支才用 clock + setAnimationLoop;与「只有一个时钟来源」的声明一致,无夸大。
- [ok] GLSL ES 限制类声明是否确实写在文档内(非推测) — 原文 'Loops must have **constant bounds** in GLSL ES — no dynamic loop counts. Keep fbm octaves ≤ 5–6.';移动端精度段(mediump/highp、pixelRatio 上限、低分辨率 RT 上采样)亦可逐条定位。
- [ok] reference 内容与 SKILL.md 描述是否一致 — glsl-cookbook.md 开篇 'Complete, copy-pasteable GLSL for noise, SDFs, palettes, domain warping, transitions, and Three.js wiring.',随后逐节给出 IQ 调色板、hash21/hash22/valueNoise、SDF 与 domain warping 实现,与 SKILL.md 末尾能力清单对得上。
6结论
b6013fd669696c7f…50697d659f