GLSL and Shadertoy shader skills for Claude Code, Codex, Cursor, Copilot and Gemini CLI. 186 functions, SDF raymarching, procedural terrain, water, clouds and generative art, with a bundler, checker and 11 examples.
Shader Workflow
Use this workflow when creating or revising procedural shaders.
Contents
- 1. Visual Contract
- 2. First Visible Pass
- 3. Layering Order
- 4. Debug Views
- 5. Refinement Strategy
- 6. Review Checklist
1. Visual Contract
Before coding, define the image in operational terms:
- Subject: what the viewer should recognize first.
- Camera: orthographic, perspective, low angle, portrait, macro, wide heightfield, flythrough.
- Spatial model: 2D masks, heightfield, SDF scene, volumetric field, post effect.
- Materials: matte, waxy, stone, subsurface, glass, metal, mist, density-field, painted ink.
- Composition: silhouette, foreground/midground/background, focal contrast, empty space.
- Motion: camera drift, object motion, environmental motion, loop duration.
If the user only gives a vague style, choose a small concrete scene and state it.
2. First Visible Pass
Make the shader visible before making it clever:
- Normalize coordinates with aspect preservation.
- Draw a background gradient or sky.
- Add one primitive, mask, SDF, or height profile.
- Add a single color ramp or diffuse light.
- Confirm orientation and scale with debug colors.
The first pass should answer: "Is this the right visual family?"
3. Layering Order
Build in layers that can be debugged independently:
- Domain and camera.
- Large forms.
- Repetition or variation IDs.
- Secondary forms and cuts.
- Material assignment.
- Lighting and shadows.
- Atmosphere and depth cues.
- Surface detail.
- Color grade and antialiasing.
For 3D SDF scenes, keep geometry and material ID decisions close together. For 2D drawings, keep masks named by visual role rather than math trick.
4. Debug Views
Add cheap debug modes while developing:
- Raw SDF distance as grayscale.
abs(d)contour bands for surface inspection.- Normal direction as
0.5 + 0.5*n. - Material ID as flat colors.
- Raymarch step count heatmap.
- Height/noise octave contribution.
- Masks for foreground, midground, atmosphere, and highlights.
Gate them behind #define DEBUG_MODE 0 using the pack's numbering (0 final, 1 distance, 2 normals, 3 ids,
4 steps, 5 masks, 6 lighting terms); see composition-and-debugging.md.
5. Refinement Strategy
Refine from global to local:
- Proportions before details.
- Silhouette before material texture.
- Value structure before hue variation.
- Lighting direction before shadow polish.
- One noise layer before many octaves.
- Performance after the visual target is clear.
Avoid adding noise to hide weak structure. Noise should express a material or natural process.
6. Review Checklist
Before finalizing:
- The code has a clear coordinate/camera section.
- Constants have visual names or comments where useful.
- Loops are bounded and have escape conditions.
- Main objects read in silhouette.
- Materials differ in value, roughness, or lighting response, not only hue.
- The shader has antialiasing for sharp masks or edges.
- Lighting happens in linear color; picked colors are decoded with
srgbToLinear. - The final color is exposed, tonemapped (per AA sample), then encoded once with
linearToSrgband dithered. - No sine hashes, no
?:on structs, no#version, no custom uniforms. - The bundled shader passes
python3 scripts/glsl_tools.py check(it compiles with glslangValidator when installed). - The response explains the knobs a user can tune.