shader-art-coding
Writes, debugs, and art-directs procedural GLSL fragment shaders (Shadertoy mainImage, WebGL2 / GLSL ES 3.00): SDF raymarching, procedural buildings/cities, 2D distance-field graphics, noise / fBm / domain warping, terrain, ocean/coastal water optics, clouds and other volumes, PBR lighting, color and tonemapping. Ships a verified GLSL building-block library with a bundler and checker. Use when the user asks for a shader, Shadertoy, GLSL/.frag/.glsl code, a raymarcher, an SDF scene, a procedural texture or generative visual, or wants a shader fixed, optimized, ported or explained. Not for HLSL/Unity ShaderLab or non-graphics GPU compute.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- shader-art-coding
- license
- MIT
- metadata
- { "hermes": { "tags": [ "shader", "glsl", "shadertoy", "procedural-art", "raymarching", "sdf" ], "category": "development" } }
- description
- Writes, debugs, and art-directs procedural GLSL fragment shaders (Shadertoy mainImage, WebGL2 / GLSL ES 3.00): SDF raymarching, procedural buildings/cities, 2D distance-field graphics, noise / fBm / domain warping, terrain, ocean/coastal water optics, clouds and other volumes, PBR lighting, color and tonemapping. Ships a verified GLSL building-block library with a bundler and checker. Use when the user asks for a shader, Shadertoy, GLSL/.frag/.glsl code, a raymarcher, an SDF scene, a procedural texture or generative visual, or wants a shader fixed, optimized, ported or explained. Not for HLSL/Unity ShaderLab or non-graphics GPU compute.
02 资源文件 49
- 参考文档agents/openai.yaml298 B
- 参考文档CREDITS.md6.3 KB
- 其他glsl/architecture.glsl1.8 KB
- 其他glsl/atmosphere.glsl4.6 KB
- 其他glsl/camera.glsl2.1 KB
- 其他glsl/color.glsl4.7 KB
- 其他glsl/common.glsl2.7 KB
- 其他glsl/debug.glsl1.4 KB
- 其他glsl/domain.glsl4.8 KB
- 其他glsl/hash.glsl4.1 KB
- 其他glsl/intersect.glsl1.7 KB
- 其他glsl/noise.glsl21.3 KB
- 其他glsl/operators.glsl5.3 KB
- 其他glsl/pattern.glsl3.1 KB
- 其他glsl/post.glsl2.6 KB
- 其他glsl/raymarch.glsl4.0 KB
- 其他glsl/sdf2d.glsl11.7 KB
- 其他glsl/sdf3d.glsl10.0 KB
- 其他glsl/shading.glsl4.6 KB
- 其他glsl/tonemap.glsl4.8 KB
- 其他glsl/volume.glsl3.4 KB
- 其他glsl/water.glsl3.1 KB
- 许可证LICENSE1.0 KB
- 参考文档references/composition-and-debugging.md5.2 KB
- 参考文档references/formula-code-couples-materials.md15.5 KB
- 参考文档references/formula-code-couples-sdf.md20.5 KB
- 参考文档references/formula-code-couples-terrain.md17.1 KB
- 参考文档references/formula-cookbook.md19.0 KB
- 参考文档references/library-index.md56.2 KB
- 参考文档references/noise-use-cases.md17.1 KB
- 参考文档references/procedural-buildings.md7.5 KB
- 参考文档references/rendering-pipeline.md8.4 KB
- 参考文档references/sdf-library-guide.md10.4 KB
- 参考文档references/shader-workflow.md3.5 KB
- 参考文档references/subject-routing.md9.7 KB
- 参考文档references/terrain-production.md7.3 KB
- 参考文档references/water-quality.md10.6 KB
- 脚本scripts/glsl_tools.py29.4 KB
- 其他templates/alpine-valley.glsl3.9 KB
- 其他templates/coastal-water.glsl7.6 KB
- 其他templates/noise-progression.glsl2.3 KB
- 其他templates/noise-terrain-map.glsl2.2 KB
- 其他templates/ocean.glsl13.1 KB
- 其他templates/pattern-swatches.glsl3.6 KB
- 其他templates/procedural-city.glsl4.5 KB
- 其他templates/raymarch-sdf.glsl5.3 KB
- 其他templates/sdf-2d-poster.glsl3.7 KB
- 其他templates/terrain.glsl4.7 KB
- 其他templates/volumetric-clouds.glsl3.9 KB
03 SKILL.md 正文
Shader Art Coding
Treat shader work as visual engineering: start from the intended image, choose the smallest mathematical model that can produce it, build it in inspectable stages, and verify each stage with a debug view.
Workflow
- Target. State the image: subject, camera and framing, dominant forms, materials, light, motion.
- Route. Pick the rendering model and starting template from
references/subject-routing.md: 2D distance fields (posters, icons, patterns), SDF raymarching (objects, characters), heightfield marching (landscapes), volume integration (clouds, smoke, fire). - Assemble from the library. Find building blocks with
python3 scripts/glsl_tools.py search <words>orreferences/library-index.md, and call them by name. Do not paste or re-derive library code; it is tested. - First image fast. Coordinates, background, one primitive, one light. Then add the debug views.
- Refine in order: proportions, composition, material separation, lighting, atmosphere, color, antialiasing, performance.
- Bundle and check.
python3 scripts/glsl_tools.py bundle shader.glsl -o out.glslinlines exactly the functions used.python3 scripts/glsl_tools.py check out.glsllints it and compiles it with glslangValidator when installed. Fix every error, then deliverout.glsl.
Run the scripts from this skill's directory. They need only Python 3.
Conventions
- Coordinates:
vec2 uv = (2.0 * fragCoord - iResolution.xy) / iResolution.y;, so one pixel is2.0 / iResolution.y. - Scene contract:
vec2 map(vec3 p)returnsvec2(distance, materialId).raymarch,calcNormal,softShadow,calcAOandsdfThicknessall use it. - Debug:
#define DEBUG_MODE 0with 0 final, 1 distance field, 2 normals, 3 ids, 4 steps, 5 masks, 6 lighting terms. - Color pipeline: light in linear and decode picked colors with
srgbToLinear. Then exposure, then the tonemap (tonemapAgXby default, per AA sample), then the average, thenlinearToSrgbonce, thenditherTPDF. - Distances: respect the
@exact/@bound/@approxtags. If a deformation pushes Lipschitz above 1, divide the distance or lower thestepScaleofraymarch.
Hard rules (these break Shadertoy/WebGL)
- No
#versionline, no custom uniforms, nogl_FragColor/texture2D/iGlobalTime. - No
?:on structs. Usevec2(distance, id)orif. - Write float literals:
2.0 * PI,clamp(x, 0.0, 1.0). - No
fract(sin(...) * 43758.5453)hashes. Usehash12/hash22/hash33(integer PCG). Replace them even when porting with "keep the look": the sine hash's exact pattern already differs between GPUs, and a PCG hash on the same integer cell ids gives the noise the same look.checkreports a sine hash as an error. - Guard NaN sources:
atan(0, 0),powof negatives,sqrtof negatives,normalize(vec3(0)). - Keep
dFdx/fwidthout of non-uniform branches and loops, or use an explicit pixel size.
Reference routing
Read only what the task needs:
| File | Read when |
|---|---|
references/subject-routing.md |
starting from a subject ("a jellyfish", "mountains"); maps formal names to subjects |
references/library-index.md |
choosing functions: every library function with signature, exactness and uses |
references/sdf-library-guide.md |
modeling: exactness tiers, blends, neighbor-checked repetition, deformation limits, WebGL pitfalls |
references/rendering-pipeline.md |
lighting rigs, shadows/AO, sky and fog, volumes, tonemapping, AA, performance |
references/noise-use-cases.md |
choosing Perlin/value/simplex/cellular noise, fBm/ridged/billow/warp/hybrid recipes, game use cases and primary-source code links |
references/procedural-buildings.md |
parcel IDs, building massing, setbacks/roofs, facade filtering, city repetition and game integration |
references/terrain-production.md |
terrain representations, designed valleys, slope/altitude materials, tracing limits, chunks and LOD |
references/water-quality.md |
high-quality ocean/coastal water, wave derivatives, Fresnel/refraction/absorption, foam, presets and engine-side upgrades |
references/shader-workflow.md |
planning a complex shader end to end; review checklist |
references/composition-and-debugging.md |
the image reads poorly, or something is visually wrong |
references/formula-cookbook.md |
multi-step recipes: modular cell lattices, terrain synthesis, organic composition |
references/formula-code-couples-sdf.md |
equation-to-code for organic and modular SDF features |
references/formula-code-couples-terrain.md |
heightfields, density fields, accumulation, atmosphere |
references/formula-code-couples-materials.md |
masks, palettes, lighting terms, polish, motion |
Templates in templates/ are complete, render-verified starting points (gallery in the repository README):
raymarch-sdf.glsl, terrain.glsl, ocean.glsl, volumetric-clouds.glsl, sdf-2d-poster.glsl,
pattern-swatches.glsl, noise-progression.glsl, noise-terrain-map.glsl, procedural-city.glsl,
alpine-valley.glsl, coastal-water.glsl.
Output expectations
When writing a shader:
- Deliver the bundled, paste-ready Shadertoy code with
mainImage(out vec4 fragColor, in vec2 fragCoord). - Avoid textures unless the user provides them.
- Include
DEBUG_MODEswitches and name the art controls as constants at the top. - End with a short tuning guide: which constants control scale, softness, color, light and motion.
- Say whether the shader was compile-checked, and how.
- For buildings/terrain/water, separate implemented features from engine-side upgrades. Do not call a heightfield a cave generator, a material window a modeled recess, or a procedural foam/caustic mask a fluid/light simulation.
- For quality requests, state the target and budget, expose presets/debug views, and inspect rendered output.
Annotate important template presets with
// @variant QUALITY=3(or another defined integer macro) so CI compiles and renders them. Preserve horizon/shore contact and temporal filtering before adding detail.
When improving an existing shader:
- Identify its rendering model and bottlenecks.
- Preserve its intent and interface.
- Fix correctness first, then readability, visual quality and speed.
- Call out risky changes (coordinate scale, material ids, loop counts).
04 同仓库更多 Skills
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
workflow-from-chats
Extract preferences from agent chats → skills, rules, workflow docs. For learning preferences, mining feedback, personalizing workflows.
winui3-csharp-app
WinUI 3 / Windows App SDK desktop apps in C#/XAML. MVVM, bindings, navigation, Mica/Acrylic, windowing, packaging, performance.
why
Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Discovers available MCPs and queries each evidence category (source control, issue tracker, long-form docs, real-time chat, infrastructure observability, error tracking, product analytics warehouse) in parallel, then returns a cited read on decisions and tradeoffs. Use how for runtime behavior.
what-did-i-get-done
Summarize authored commits over a user-specified time period into a concise status update.
weekly-review
Produce a short weekly synthesis of authored commits with highlights by bugfix, tech debt, and net-new work.