npx skills add https://github.com/minimax-ai/skills --skill shader-dev一个涵盖 36 种 GLSL 着色器技术(兼容 ShaderToy)的统一技能,用于实现实时视觉效果。
/shader-dev <request>
$ARGUMENTS 包含用户的请求(例如,"创建带有柔和阴影的光线步进 SDF 场景")。
shader-dev/
├── SKILL.md # 核心技能(本文件)
├── techniques/ # 实现指南(根据路由表读取)
│ ├── ray-marching.md # 使用 SDF 进行球体追踪
│ ├── sdf-3d.md # 3D 有符号距离函数
│ ├── lighting-model.md # PBR、Phong、卡通着色
│ ├── procedural-noise.md # Perlin、Simplex、FBM
│ └── ... # 其他 34 个技术文件
└── reference/ # 详细指南(按需读取)
├── ray-marching.md # 数学推导与高级模式
├── sdf-3d.md # 扩展 SDF 理论
├── lighting-model.md # 光照数学深度解析
├── procedural-noise.md # 噪声函数理论
└── ... # 其他 34 个参考文件
techniques/ 目录读取相关文件——每个文件都包含核心原理、实现步骤和完整的代码模板广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
reference/ 目录| 用户想要创建... | 主要技术 | 结合使用 |
|---|---|---|
| 基于数学的 3D 对象/场景 | ray-marching + sdf-3d | lighting-model, shadow-techniques |
| 复杂的 3D 形状(布尔运算、混合) | csg-boolean-operations | sdf-3d, ray-marching |
| 3D 中的无限重复图案 | domain-repetition | sdf-3d, ray-marching |
| 有机/扭曲的形状 | domain-warping | procedural-noise |
| 流体/烟雾/墨水效果 | fluid-simulation | multipass-buffer |
| 粒子效果(火焰、火花、雪) | particle-system | procedural-noise, color-palette |
| 基于物理的模拟 | simulation-physics | multipass-buffer |
| 生命游戏/反应-扩散 | cellular-automata | multipass-buffer, color-palette |
| 海洋/水面 | water-ocean | atmospheric-scattering, lighting-model |
| 地形/景观 | terrain-rendering | atmospheric-scattering, procedural-noise |
| 云/雾/体积火焰 | volumetric-rendering | procedural-noise, atmospheric-scattering |
| 天空/日落/大气 | atmospheric-scattering | volumetric-rendering |
| 真实感光照(PBR、Phong) | lighting-model | shadow-techniques, ambient-occlusion |
| 阴影(软/硬) | shadow-techniques | lighting-model |
| 环境光遮蔽 | ambient-occlusion | lighting-model, normal-estimation |
| 路径追踪/全局光照 | path-tracing-gi | analytic-ray-tracing, multipass-buffer |
| 精确的光线-几何体相交 | analytic-ray-tracing | lighting-model |
| 体素世界(Minecraft 风格) | voxel-rendering | lighting-model, shadow-techniques |
| 噪声/FBM 纹理 | procedural-noise | domain-warping |
| 平铺的 2D 图案 | procedural-2d-pattern | polar-uv-manipulation |
| Voronoi/细胞图案 | voronoi-cellular-noise | color-palette |
| 分形(Mandelbrot、Julia、3D) | fractal-rendering | color-palette, polar-uv-manipulation |
| 色彩分级/调色板 | color-palette | — |
| 辉光/色调映射/故障效果 | post-processing | multipass-buffer |
| 多通道乒乓缓冲区 | multipass-buffer | — |
| 纹理/采样技术 | texture-sampling | — |
| 相机/矩阵变换 | matrix-transform | — |
| 表面法线 | normal-estimation | — |
| 极坐标/万花筒 | polar-uv-manipulation | procedural-2d-pattern |
| 基于 SDF 的 2D 形状/UI | sdf-2d | color-palette |
| 程序化音频/音乐 | sound-synthesis | — |
| SDF 技巧/优化 | sdf-tricks | sdf-3d, ray-marching |
| 抗锯齿渲染 | anti-aliasing | sdf-2d, post-processing |
| 景深/运动模糊/镜头效果 | camera-effects | post-processing, multipass-buffer |
| 高级纹理映射/无缝纹理 | texture-mapping-advanced | terrain-rendering, texture-sampling |
| WebGL2 着色器错误/调试 | webgl-pitfalls | — |
fragCoord、main() 包装器、函数顺序、宏限制、uniform 为 null所有技术文件都使用 ShaderToy GLSL 风格。生成独立的 HTML 页面时,应用以下适配:
canvas.getContext("webgl2")#version 300 es,片段着色器添加 precision highp float;out vec4 fragColor;attribute → in,varying → outvarying → in,gl_FragColor → fragColor,texture2D() → texture()使用 gl_FragCoord.xy 而不是 fragCoord(WebGL2 没有内置的 fragCoord)
// 错误 vec2 uv = (2.0 * fragCoord - iResolution.xy) / iResolution.y; // 正确 vec2 uv = (2.0 * gl_FragCoord.xy - iResolution.xy) / iResolution.y;
ShaderToy 使用 void mainImage(out vec4 fragColor, in vec2 fragCoord)
WebGL2 需要标准的 void main() 入口点——始终包装 mainImage:
void mainImage(out vec4 fragColor, in vec2 fragCoord) { // 着色器代码... fragColor = vec4(col, 1.0); }
void main() { mainImage(fragColor, gl_FragCoord.xy); }
GLSL 要求函数在使用前声明——要么在使用前声明,要么重新排序:
// 错误 — getAtmosphere() 在 getSunDirection() 定义之前调用它 vec3 getAtmosphere(vec3 dir) { return getSunDirection(); } // 错误! vec3 getSunDirection() { return normalize(vec3(1.0)); }
// 正确 — 先定义被调用者 vec3 getSunDirection() { return normalize(vec3(1.0)); } vec3 getAtmosphere(vec3 dir) { return getSunDirection(); } // 正常
#define 不能使用函数调用——改用 const:
// 错误 #define SUN_DIR normalize(vec3(0.8, 0.4, -0.6))
// 正确 const vec3 SUN_DIR = vec3(0.756, 0.378, -0.567); // 预计算归一化值
从 <script> 标签提取着色器源代码时,确保 #version 是 第一个字符——使用 .trim():
const fs = document.getElementById('fs').text.trim();
gl.getUniformLocation() 返回 null——始终以编译器无法优化的方式使用 uniform#define 宏terrainM(vec2) 这样的函数需要 XZ 分量——使用 terrainM(pos.xz + offset) 而不是 terrainM(pos + offset)生成独立的 HTML 页面时:
body { margin: 0; overflow: hidden; background: #000; }iTime、iResolution、iMouse、iFramelet/const 变量必须在 <script> 块的 顶部 声明,在任何引用它们的函数之前:
// 1. 状态变量 FIRST
let frameCount = 0;
let startTime = Date.now();
// 2. Canvas/GL 初始化、着色器编译、FBO 创建
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl2');
// ...
// 3. 函数和事件绑定 LAST
function resize() { /* 现在可以安全地引用 frameCount */ }
function render() { /* ... */ }
window.addEventListener('resize', resize);
原因:let/const 存在暂时性死区——在声明之前引用它们会抛出 ReferenceError,导致白屏。
float fbm(vec3 p),则不能使用 vec2 调用 fbm(uv)patch、cast、sample、filter、input、output、common、partition、activevec3 x = 1.0 是非法的——使用 vec3 x = vec3(1.0);不能使用 .z 访问 vec2if/else部署环境可能使用无头软件渲染,GPU 能力有限。请保持在以下限制内:
常见效果组合——由技术模块组装而成的完整渲染管线。
可视化调试方法——临时替换你的输出来诊断问题。
| 检查内容 | 代码 | 观察目标 |
|---|---|---|
| 表面法线 | col = nor * 0.5 + 0.5; | 平滑渐变 = 法线正确;带状 = epsilon 太大 |
| 光线步进步数 | col = vec3(float(steps) / float(MAX_STEPS)); | 红色热点 = 性能瓶颈;均匀 = 浪费迭代 |
| 深度/距离 | col = vec3(t / MAX_DIST); | 验证正确的命中距离 |
| UV 坐标 | col = vec3(uv, 0.0); | 检查坐标映射 |
| SDF 距离场 | col = (d > 0.0 ? vec3(0.9,0.6,0.3) : vec3(0.4,0.7,0.85)) * (0.8 + 0.2*cos(150.0*d)); | 可视化 SDF 带和零交叉 |
| 棋盘格图案(UV) | col = vec3(mod(floor(uv.x*10.)+floor(uv.y*10.), 2.0)); | 验证 UV 扭曲、接缝 |
| 仅光照 | col = vec3(shadow); 或 col = vec3(ao); | 隔离阴影/环境光遮蔽贡献 |
| 材质 ID | col = palette(matId / maxMatId); | 验证材质分配 |
每周安装量
165
代码仓库
GitHub 星标
4.4K
首次出现
8 天前
安全审计
安装于
opencode162
codex161
cursor160
gemini-cli159
github-copilot159
kimi-cli158
A unified skill covering 36 GLSL shader techniques (ShaderToy-compatible) for real-time visual effects.
/shader-dev <request>
$ARGUMENTS contains the user's request (e.g. "create a raymarched SDF scene with soft shadows").
shader-dev/
├── SKILL.md # Core skill (this file)
├── techniques/ # Implementation guides (read per routing table)
│ ├── ray-marching.md # Sphere tracing with SDF
│ ├── sdf-3d.md # 3D signed distance functions
│ ├── lighting-model.md # PBR, Phong, toon shading
│ ├── procedural-noise.md # Perlin, Simplex, FBM
│ └── ... # 34 more technique files
└── reference/ # Detailed guides (read as needed)
├── ray-marching.md # Math derivations & advanced patterns
├── sdf-3d.md # Extended SDF theory
├── lighting-model.md # Lighting math deep-dive
├── procedural-noise.md # Noise function theory
└── ... # 34 more reference files
techniques/ — each file contains core principles, implementation steps, and complete code templatesreference/| User wants to create... | Primary technique | Combine with |
|---|---|---|
| 3D objects / scenes from math | ray-marching + sdf-3d | lighting-model, shadow-techniques |
| Complex 3D shapes (booleans, blends) | csg-boolean-operations | sdf-3d, ray-marching |
| Infinite repeating patterns in 3D | domain-repetition | sdf-3d, ray-marching |
| Organic / warped shapes | domain-warping | procedural-noise |
| Fluid / smoke / ink effects | fluid-simulation | multipass-buffer |
fragCoord, main() wrapper, function order, macro limitations, uniform nullAll technique files use ShaderToy GLSL style. When generating standalone HTML pages, apply these adaptations:
canvas.getContext("webgl2")#version 300 es, fragment shader adds precision highp float;out vec4 fragColor;attribute → in, varying → outvarying → in, gl_FragColor → , → Usegl_FragCoord.xy instead of fragCoord (WebGL2 does not have fragCoord built-in)
// WRONG vec2 uv = (2.0 * fragCoord - iResolution.xy) / iResolution.y; // CORRECT vec2 uv = (2.0 * gl_FragCoord.xy - iResolution.xy) / iResolution.y;
ShaderToy uses void mainImage(out vec4 fragColor, in vec2 fragCoord)
WebGL2 requires standard void main() entry point — always wrap mainImage:
void mainImage(out vec4 fragColor, in vec2 fragCoord) { // shader code... fragColor = vec4(col, 1.0); }
void main() { mainImage(fragColor, gl_FragCoord.xy); }
GLSL requires functions to be declared before use — either declare before use or reorder:
// WRONG — getAtmosphere() calls getSunDirection() before it's defined vec3 getAtmosphere(vec3 dir) { return getSunDirection(); } // Error! vec3 getSunDirection() { return normalize(vec3(1.0)); }
// CORRECT — define callee first vec3 getSunDirection() { return normalize(vec3(1.0)); } vec3 getAtmosphere(vec3 dir) { return getSunDirection(); } // Works
#define cannot use function calls — use const instead:
// WRONG #define SUN_DIR normalize(vec3(0.8, 0.4, -0.6))
// CORRECT const vec3 SUN_DIR = vec3(0.756, 0.378, -0.567); // Pre-computed normalized value
When extracting shader source from <script> tags, ensure #version is the first character — use .trim():
const fs = document.getElementById('fs').text.trim();
gl.getUniformLocation() to return null — always use uniforms in a way the compiler cannot optimize out#define macros in some ES versionsterrainM(vec2) need XZ components — use terrainM(pos.xz + offset) not terrainM(pos + offset)When generating a standalone HTML page:
body { margin: 0; overflow: hidden; background: #000; }iTime, iResolution, iMouse, iFramelet/const variables must be declared at the top of the <script> block, before any function that references them:
// 1. State variables FIRST
let frameCount = 0;
let startTime = Date.now();
// 2. Canvas/GL init, shader compile, FBO creation
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl2');
// ...
// 3. Functions and event bindings LAST
function resize() { /* can now safely reference frameCount */ }
function render() { /* ... */ }
window.addEventListener('resize', resize);
Reason: let/const have a Temporal Dead Zone — referencing them before declaration throws ReferenceError, causing a white screen.
float fbm(vec3 p), cannot call fbm(uv) with a vec2patch, cast, sample, filter, input, output, common, partition, Deployment environments may use headless software rendering with limited GPU power. Stay within these limits:
Common effect combinations — complete rendering pipelines assembled from technique modules.
Visual debugging methods — temporarily replace your output to diagnose issues.
| What to check | Code | What to look for |
|---|---|---|
| Surface normals | col = nor * 0.5 + 0.5; | Smooth gradients = correct normals; banding = epsilon too large |
| Ray march step count | col = vec3(float(steps) / float(MAX_STEPS)); | Red hotspots = performance bottleneck; uniform = wasted iterations |
| Depth / distance | col = vec3(t / MAX_DIST); | Verify correct hit distances |
| UV coordinates | col = vec3(uv, 0.0); | Check coordinate mapping |
| SDF distance field | col = (d > 0.0 ? vec3(0.9,0.6,0.3) : vec3(0.4,0.7,0.85)) * (0.8 + 0.2*cos(150.0*d)); |
Weekly Installs
165
Repository
GitHub Stars
4.4K
First Seen
8 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode162
codex161
cursor160
gemini-cli159
github-copilot159
kimi-cli158
React Three Fiber (R3F) 完全指南:Three.js React渲染器,声明式3D开发
229 周安装
资深Terraform工程师技能:AWS/Azure/GCP基础设施即代码、模块化设计与状态管理
1,300 周安装
Pandas Pro 高效数据操作指南 - 生产级性能优化与代码模式
1,300 周安装
监控专家技能:全面可观测性、性能监控与告警系统实施指南
1,400 周安装
.NET Core 专家技能:现代C#开发、整洁架构与云原生实践指南
1,300 周安装
资深C#开发者技能:精通.NET 8+、ASP.NET Core API、Entity Framework与高性能优化
1,400 周安装
代码文档生成器 - 自动生成内联文档、API规范、开发者指南的AI工具
1,300 周安装
| Particle effects (fire, sparks, snow) | particle-system | procedural-noise, color-palette |
| Physically-based simulations | simulation-physics | multipass-buffer |
| Game of Life / reaction-diffusion | cellular-automata | multipass-buffer, color-palette |
| Ocean / water surface | water-ocean | atmospheric-scattering, lighting-model |
| Terrain / landscape | terrain-rendering | atmospheric-scattering, procedural-noise |
| Clouds / fog / volumetric fire | volumetric-rendering | procedural-noise, atmospheric-scattering |
| Sky / sunset / atmosphere | atmospheric-scattering | volumetric-rendering |
| Realistic lighting (PBR, Phong) | lighting-model | shadow-techniques, ambient-occlusion |
| Shadows (soft / hard) | shadow-techniques | lighting-model |
| Ambient occlusion | ambient-occlusion | lighting-model, normal-estimation |
| Path tracing / global illumination | path-tracing-gi | analytic-ray-tracing, multipass-buffer |
| Precise ray-geometry intersections | analytic-ray-tracing | lighting-model |
| Voxel worlds (Minecraft-style) | voxel-rendering | lighting-model, shadow-techniques |
| Noise / FBM textures | procedural-noise | domain-warping |
| Tiled 2D patterns | procedural-2d-pattern | polar-uv-manipulation |
| Voronoi / cell patterns | voronoi-cellular-noise | color-palette |
| Fractals (Mandelbrot, Julia, 3D) | fractal-rendering | color-palette, polar-uv-manipulation |
| Color grading / palettes | color-palette | — |
| Bloom / tone mapping / glitch | post-processing | multipass-buffer |
| Multi-pass ping-pong buffers | multipass-buffer | — |
| Texture / sampling techniques | texture-sampling | — |
| Camera / matrix transforms | matrix-transform | — |
| Surface normals | normal-estimation | — |
| Polar coords / kaleidoscope | polar-uv-manipulation | procedural-2d-pattern |
| 2D shapes / UI from SDF | sdf-2d | color-palette |
| Procedural audio / music | sound-synthesis | — |
| SDF tricks / optimization | sdf-tricks | sdf-3d, ray-marching |
| Anti-aliased rendering | anti-aliasing | sdf-2d, post-processing |
| Depth of field / motion blur / lens effects | camera-effects | post-processing, multipass-buffer |
| Advanced texture mapping / no-tile textures | texture-mapping-advanced | terrain-rendering, texture-sampling |
| WebGL2 shader errors / debugging | webgl-pitfalls | — |
fragColortexture2D()texture()activevec3 x = 1.0 is illegal — use vec3 x = vec3(1.0); cannot use .z to access a vec2if/else instead| Visualize SDF bands and zero-crossing |
| Checker pattern (UV) | col = vec3(mod(floor(uv.x*10.)+floor(uv.y*10.), 2.0)); | Verify UV distortion, seams |
| Lighting only | col = vec3(shadow); or col = vec3(ao); | Isolate shadow/AO contributions |
| Material ID | col = palette(matId / maxMatId); | Verify material assignment |