本文へ移動
cccskills
無料GitHub で公開

shader-dev

Build GLSL/WebGL/ShaderToy shaders and procedural visual effects such as SDF, ray marching, particles, and fluids.

インストール方法を見る

含まれるファイル(75)

  • SKILL.md18.4 KB
  • reference/ambient-occlusion.md14.5 KB
  • reference/analytic-ray-tracing.md24.1 KB
  • reference/anti-aliasing.md2.9 KB
  • reference/atmospheric-scattering.md27.5 KB
  • reference/camera-effects.md3.0 KB
  • reference/cellular-automata.md26.7 KB
  • reference/color-palette.md19.9 KB
  • reference/csg-boolean-operations.md17.5 KB
  • reference/domain-repetition.md17.7 KB
  • reference/domain-warping.md16.6 KB
  • reference/fluid-simulation.md18.5 KB
  • reference/fractal-rendering.md18.2 KB
  • reference/lighting-model.md29.4 KB
  • reference/matrix-transform.md18.5 KB
  • reference/multipass-buffer.md24.8 KB
  • reference/normal-estimation.md17.2 KB
  • reference/particle-system.md28.3 KB
  • reference/path-tracing-gi.md27.5 KB
  • reference/polar-uv-manipulation.md22.6 KB
  • reference/post-processing.md23.9 KB
  • reference/procedural-2d-pattern.md16.3 KB
  • reference/procedural-noise.md21.7 KB
  • reference/ray-marching.md15.5 KB
  • reference/sdf-2d.md27.5 KB
  • reference/sdf-3d.md26.8 KB
  • reference/sdf-tricks.md2.6 KB
  • reference/shadow-techniques.md21.0 KB
  • reference/simulation-physics.md27.6 KB
  • reference/sound-synthesis.md23.6 KB
  • reference/terrain-rendering.md32.2 KB
  • reference/texture-mapping-advanced.md3.3 KB
  • reference/texture-sampling.md25.6 KB
  • reference/volumetric-rendering.md28.1 KB
  • reference/voronoi-cellular-noise.md17.6 KB
  • reference/voxel-rendering.md29.2 KB
  • reference/water-ocean.md20.2 KB
  • reference/webgl-pitfalls.md1.9 KB
  • techniques/ambient-occlusion.md11.1 KB
  • techniques/analytic-ray-tracing.md18.8 KB
  • techniques/anti-aliasing.md4.5 KB
  • techniques/atmospheric-scattering.md18.2 KB
  • techniques/camera-effects.md3.4 KB
  • techniques/cellular-automata.md19.0 KB
  • techniques/color-palette.md12.8 KB
  • techniques/csg-boolean-operations.md15.0 KB
  • techniques/domain-repetition.md9.7 KB
  • techniques/domain-warping.md12.5 KB
  • techniques/fluid-simulation.md46.5 KB
  • techniques/fractal-rendering.md13.0 KB
  • techniques/lighting-model.md17.1 KB
  • techniques/matrix-transform.md12.4 KB
  • techniques/multipass-buffer.md33.5 KB
  • techniques/normal-estimation.md9.1 KB
  • techniques/particle-system.md44.6 KB
  • techniques/path-tracing-gi.md21.5 KB
  • techniques/polar-uv-manipulation.md13.2 KB
  • techniques/post-processing.md30.3 KB
  • techniques/procedural-2d-pattern.md10.7 KB
  • techniques/procedural-noise.md16.9 KB
  • techniques/ray-marching.md13.7 KB
  • techniques/sdf-2d.md21.2 KB
  • techniques/sdf-3d.md21.6 KB
  • techniques/sdf-tricks.md3.4 KB
  • techniques/shadow-techniques.md24.8 KB
  • techniques/simulation-physics.md56.2 KB
  • techniques/sound-synthesis.md17.2 KB
  • techniques/terrain-rendering.md14.3 KB
  • techniques/texture-mapping-advanced.md4.3 KB
  • techniques/texture-sampling.md13.0 KB
  • techniques/volumetric-rendering.md12.3 KB
  • techniques/voronoi-cellular-noise.md13.0 KB
  • techniques/voxel-rendering.md45.2 KB
  • techniques/water-ocean.md17.8 KB
  • techniques/webgl-pitfalls.md5.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Shader Craft

A unified skill covering 36 GLSL shader techniques (ShaderToy-compatible) for real-time visual effects.

Natural-Language Usage

Use this OpenCode skill when the user asks for shader work in natural language, such as "create a raymarched SDF scene with soft shadows".

Routing Boundary

Use this skill only for GLSL, WebGL shader code, ShaderToy-compatible effects, SDF/ray marching, procedural noise, particles, fluid/physics simulations, and shader post-processing. Do not use it for generic frontend animation, CSS transitions, Lottie, canvas UI, or motion design unless shader code is explicitly required; route those to frontend-dev or frontend-ui-engineering as appropriate.

Skill Structure

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

How to Use

  1. Read the Technique Routing Table below to identify which technique(s) match the user's request
  2. Read the relevant file(s) from techniques/ — each file contains core principles, implementation steps, and complete code templates
  3. If you need deeper understanding (math derivations, advanced patterns), follow the reference link at the bottom of each technique file to reference/
  4. Apply the WebGL2 Adaptation Rules below when generating standalone HTML pages

🔴 CHECKPOINT — Technique and performance budget: before writing shader code, state the chosen technique stack, target runtime (ShaderToy vs standalone WebGL2), resolution/performance target, maximum loop counts, and required interaction/audio/multipass buffers. If the visual target or perf budget is unclear, ask before implementing.

Technique Routing Table

User wants to create...Primary techniqueCombine with
3D objects / scenes from mathray-marching + sdf-3dlighting-model, shadow-techniques
Complex 3D shapes (booleans, blends)csg-boolean-operationssdf-3d, ray-marching
Infinite repeating patterns in 3Ddomain-repetitionsdf-3d, ray-marching
Organic / warped shapesdomain-warpingprocedural-noise
Fluid / smoke / ink effectsfluid-simulationmultipass-buffer
Particle effects (fire, sparks, snow)particle-systemprocedural-noise, color-palette
Physically-based simulationssimulation-physicsmultipass-buffer
Game of Life / reaction-diffusioncellular-automatamultipass-buffer, color-palette
Ocean / water surfacewater-oceanatmospheric-scattering, lighting-model
Terrain / landscapeterrain-renderingatmospheric-scattering, procedural-noise
Clouds / fog / volumetric firevolumetric-renderingprocedural-noise, atmospheric-scattering
Sky / sunset / atmosphereatmospheric-scatteringvolumetric-rendering
Realistic lighting (PBR, Phong)lighting-modelshadow-techniques, ambient-occlusion
Shadows (soft / hard)shadow-techniqueslighting-model
Ambient occlusionambient-occlusionlighting-model, normal-estimation
Path tracing / global illuminationpath-tracing-gianalytic-ray-tracing, multipass-buffer
Precise ray-geometry intersectionsanalytic-ray-tracinglighting-model
Voxel worlds (Minecraft-style)voxel-renderinglighting-model, shadow-techniques
Noise / FBM texturesprocedural-noisedomain-warping
Tiled 2D patternsprocedural-2d-patternpolar-uv-manipulation
Voronoi / cell patternsvoronoi-cellular-noisecolor-palette
Fractals (Mandelbrot, Julia, 3D)fractal-renderingcolor-palette, polar-uv-manipulation
Color grading / palettescolor-palette—
Bloom / tone mapping / glitchpost-processingmultipass-buffer
Multi-pass ping-pong buffersmultipass-buffer—
Texture / sampling techniquestexture-sampling—
Camera / matrix transformsmatrix-transform—
Surface normalsnormal-estimation—
Polar coords / kaleidoscopepolar-uv-manipulationprocedural-2d-pattern
2D shapes / UI from SDFsdf-2dcolor-palette
Procedural audio / musicsound-synthesis—
SDF tricks / optimizationsdf-trickssdf-3d, ray-marching
Anti-aliased renderinganti-aliasingsdf-2d, post-processing
Depth of field / motion blur / lens effectscamera-effectspost-processing, multipass-buffer
Advanced texture mapping / no-tile texturestexture-mapping-advancedterrain-rendering, texture-sampling
WebGL2 shader errors / debuggingwebgl-pitfalls—

Technique Index

Geometry & SDF

  • sdf-2d — 2D signed distance functions for shapes, UI, anti-aliased rendering
  • sdf-3d — 3D signed distance functions for real-time implicit surface modeling
  • csg-boolean-operations — Constructive solid geometry: union, subtraction, intersection with smooth blending
  • domain-repetition — Infinite space repetition, folding, and limited tiling
  • domain-warping — Distort domains with noise for organic, flowing shapes
  • sdf-tricks — SDF optimization, bounding volumes, binary search refinement, hollowing, layered edges, debug visualization

Ray Casting & Lighting

  • ray-marching — Sphere tracing with SDF for 3D scene rendering
  • analytic-ray-tracing — Closed-form ray-primitive intersections (sphere, plane, box, torus)
  • path-tracing-gi — Monte Carlo path tracing for photorealistic global illumination
  • lighting-model — Phong, Blinn-Phong, PBR (Cook-Torrance), and toon shading
  • shadow-techniques — Hard shadows, soft shadows (penumbra estimation), cascade shadows
  • ambient-occlusion — SDF-based AO, screen-space AO approximation
  • normal-estimation — Finite-difference normals, tetrahedron technique

Simulation & Physics

  • fluid-simulation — Navier-Stokes fluid solver with advection, diffusion, pressure projection
  • simulation-physics — GPU-based physics: springs, cloth, N-body gravity, collision
  • particle-system — Stateless and stateful particle systems (fire, rain, sparks, galaxies)
  • cellular-automata — Game of Life, reaction-diffusion (Turing patterns), sand simulation

Natural Phenomena

  • water-ocean — Gerstner waves, FFT ocean, caustics, underwater fog
  • terrain-rendering — Heightfield ray marching, FBM terrain, erosion
  • atmospheric-scattering — Rayleigh/Mie scattering, god rays, SSS approximation
  • volumetric-rendering — Volume ray marching for clouds, fog, fire, explosions

Procedural Generation

  • procedural-noise — Value noise, Perlin, Simplex, Worley, FBM, ridged noise
  • procedural-2d-pattern — Brick, hexagon, truchet, Islamic geometric patterns
  • voronoi-cellular-noise — Voronoi diagrams, Worley noise, cracked earth, crystal
  • fractal-rendering — Mandelbrot, Julia sets, 3D fractals (Mandelbox, Mandelbulb)
  • color-palette — Cosine palettes, HSL/HSV/Oklab, dynamic color mapping

Post-Processing & Infrastructure

  • post-processing — Bloom, tone mapping (ACES, Reinhard), vignette, chromatic aberration, glitch
  • multipass-buffer — Ping-pong FBO setup, state persistence across frames
  • texture-sampling — Bilinear, bicubic, mipmap, procedural texture lookup
  • matrix-transform — Camera look-at, projection, rotation, orbit controls
  • polar-uv-manipulation — Polar/log-polar coordinates, kaleidoscope, spiral mapping
  • anti-aliasing — SSAA, SDF analytical AA, temporal anti-aliasing (TAA), FXAA post-process
  • camera-effects — Depth of field (thin lens), motion blur, lens distortion, film grain, vignette
  • texture-mapping-advanced — Biplanar mapping, texture repetition avoidance, ray differential filtering

Audio

  • sound-synthesis — Procedural audio in GLSL: oscillators, envelopes, filters, FM synthesis

Debugging & Validation

  • webgl-pitfalls — Common WebGL2/GLSL errors: fragCoord, main() wrapper, function order, macro limitations, uniform null

WebGL2 Adaptation Rules

All technique files use ShaderToy GLSL style. When generating standalone HTML pages, apply these adaptations:

Shader Version & Output

  • Use canvas.getContext("webgl2")
  • Shader first line: #version 300 es, fragment shader adds precision highp float;
  • Fragment shader must declare: out vec4 fragColor;
  • Vertex shader: attribute → in, varying → out
  • Fragment shader: varying → in, gl_FragColor → fragColor, texture2D() → texture()

Fragment Coordinate

  • Use gl_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;

main() Wrapper for ShaderToy Templates

  • 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);
}

Function Declaration Order

  • 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

Macro Limitations

  • #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

Script Tag Extraction

  • When extracting shader source from <script> tags, ensure #version is the first character — use .trim():
const fs = document.getElementById('fs').text.trim();

Common Pitfalls

  • Unused uniforms: Compiler may optimize away unused uniforms, causing gl.getUniformLocation() to return null — always use uniforms in a way the compiler cannot optimize out
  • Loop indices: Use runtime constants in loops, not #define macros in some ES versions
  • Terrain functions: Functions like terrainM(vec2) need XZ components — use terrainM(pos.xz + offset) not terrainM(pos + offset)

HTML Page Setup

When generating a standalone HTML page:

  • Canvas fills the entire viewport, auto-resizes on window resize
  • Page background black, no scrollbars: body { margin: 0; overflow: hidden; background: #000; }
  • Implement ShaderToy-compatible uniforms: iTime, iResolution, iMouse, iFrame
  • For multi-pass effects (Buffer A/B), use WebGL2 framebuffer + ping-pong (see multipass-buffer technique)

Common Pitfalls

JS Variable Declaration Order (TDZ — causes white screen crash)

let/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.

GLSL Compilation Errors (self-check after writing shaders)

  • Function signature mismatch: Call must exactly match definition in parameter count and types. If defined as float fbm(vec3 p), cannot call fbm(uv) with a vec2
  • Reserved words as variable names: Do not use: patch, cast, sample, filter, input, output, common, partition, active
  • Strict type matching: vec3 x = 1.0 is illegal — use vec3 x = vec3(1.0); cannot use .z to access a vec2
  • No ternary on structs: ESSL does not allow ternary operator on struct types — use if/else instead

Performance Budget

Deployment environments may use headless software rendering with limited GPU power. Stay within these limits:

  • Ray marching main loop: ≤ 128 steps
  • Volume sampling / lighting inner loops: ≤ 32 steps
  • FBM octaves: ≤ 6 layers
  • Total nested loop iterations per pixel: ≤ 1000 (exceeding this freezes the browser)

Compile and Visual Validation Loop

Run this loop after every shader draft:

  1. Compile vertex and fragment shaders; surface the exact compiler log if either fails.
  2. If compilation fails, fix only the named GLSL/JS issue first, then recompile.
  3. Render one frame and check for black/white screen, NaN-looking flashes, frozen animation, and missing uniforms.
  4. Use one visual debug output from Shader Debugging Techniques when geometry, normals, shadows, or UVs look wrong.
  5. Re-check the performance budget before adding another loop, FBM octave, ray-march step, or post-processing pass.
FailureFirst fixStill failing
Compile errorFix the exact line/signature/type/order issueReduce to a minimal shader, then re-add techniques one at a time
Black/white screenCheck WebGL2 context, shader link log, uniforms, and TDZ orderAdd solid-color output, then restore stages incrementally
Browser freezesCut ray steps/octaves/inner loops to budgetRemove the heaviest technique before adding new effects
Visual mismatchSwitch to normal/depth/UV/material debug outputAsk for target reference or simplify the scene description

🛑 STOP: do not stack more techniques to hide a broken shader; compile, render, and visually isolate the failing stage first.

Quick Recipes

Common effect combinations — complete rendering pipelines assembled from technique modules.

Photorealistic SDF Scene

  1. Geometry: sdf-3d (extended primitives) + csg-boolean-operations (cubic/quartic smin)
  2. Rendering: ray-marching + normal-estimation (tetrahedron method)
  3. Lighting: lighting-model (outdoor three-light model) + shadow-techniques (improved soft shadow) + ambient-occlusion
  4. Atmosphere: atmospheric-scattering (height-based fog with sun tint)
  5. Post: post-processing (ACES tone mapping) + anti-aliasing (2x SSAA) + camera-effects (vignette)

Organic / Biological Forms

  1. Geometry: sdf-3d (extended primitives + deformation operators: twist, bend) + csg-boolean (gradient-aware smin for material blending)
  2. Detail: procedural-noise (FBM with derivatives) + domain-warping
  3. Surface: lighting-model (subsurface scattering approximation via half-Lambert)

Procedural Landscape

  1. Terrain: terrain-rendering + procedural-noise (erosion FBM with derivatives)
  2. Texturing: texture-mapping-advanced (biplanar mapping + no-tile)
  3. Sky: atmospheric-scattering (Rayleigh/Mie + height fog)
  4. Water: water-ocean (Gerstner waves) + lighting-model (Fresnel reflections)

Stylized 2D Art

  1. Shapes: sdf-2d (extended library) + sdf-tricks (layered edges, hollowing)
  2. Color: color-palette (cosine palettes) + polar-uv-manipulation (kaleidoscope)
  3. Polish: anti-aliasing (SDF analytical AA) + post-processing (bloom, chromatic aberration)

Shader Debugging Techniques

Visual debugging methods — temporarily replace your output to diagnose issues.

What to checkCodeWhat to look for
Surface normalscol = nor * 0.5 + 0.5;Smooth gradients = correct normals; banding = epsilon too large
Ray march step countcol = vec3(float(steps) / float(MAX_STEPS));Red hotspots = performance bottleneck; uniform = wasted iterations
Depth / distancecol = vec3(t / MAX_DIST);Verify correct hit distances
UV coordinatescol = vec3(uv, 0.0);Check coordinate mapping
SDF distance fieldcol = (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));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 onlycol = vec3(shadow); or col = vec3(ao);Isolate shadow/AO contributions
Material IDcol = palette(matId / maxMatId);Verify material assignment

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Review a single academic paper, preprint, DOI, arXiv link, or user-provided PDF/text with source-grounded critique. Use for paper summaries, methodology review, novelty checks, reproducibility concerns, or "review this paper" requests; do not use for multi-paper surveys, systematic literature reviews, citation management, or implementation from a paper.

日本語の概要は準備中です。原文の説明を表示しています。

Rosetears520/aili-workflows22026年9月27日 更新

AI regression scouting routing. Use when agents, prompts, skills, model/tool routing, harness fixtures, or generated-output expectations change and need regression scenarios; do not use for ordinary product-code regressions.

日本語の概要は準備中です。原文の説明を表示しています。

Rosetears520/aili-workflows22026年9月27日 更新

Run the AILI delivery lifecycle from natural-language IDEATE, DEFINE, BUILD, and SHIP intent or the equivalent slash shortcuts; use for idea shaping, spec/test definition, bounded BUILD package queues, review-repair closeout, or adapter routing without exposing internal stage commands.

日本語の概要は準備中です。原文の説明を表示しています。

Rosetears520/aili-workflows22026年9月27日 更新

Android native Kotlin/Compose app development, Material 3 UI, accessibility, and Gradle builds.

日本語の概要は準備中です。原文の説明を表示しています。

Rosetears520/aili-workflows22026年9月27日 更新

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

日本語の概要は準備中です。原文の説明を表示しています。

Rosetears520/aili-workflows22026年9月27日 更新

Route an explicitly requested independent/delegated browser QA assignment or durable E2E evidence need; do not trigger for direct Playwright/DOM/console/network inspection, ordinary UI implementation, backend-only work, or production-mutating flows.

日本語の概要は準備中です。原文の説明を表示しています。

Rosetears520/aili-workflows22026年9月27日 更新

Rosetears520 のスキルをすべて見る

このスキルの問題を報告する