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.
Python agent-skillsclaude-codecodexcomputer-graphicscursorgemini-cligenerative-artgithub-copilotglslnoiseprocedural-artprocedural-generationraymarchingshadersshadertoysigned-distance-functionsterrain-generationwebglwebgl2
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>shader-skills WebGL2 checks</title>
<style>
body { font: 12px/1.5 ui-monospace, Menlo, monospace; background: #101114; color: #d7d9de; margin: 16px; }
h2 { font-size: 13px; margin: 18px 0 6px; color: #fff; }
.ok { color: #7bd88f; } .bad { color: #ff7a7a; } .warn { color: #ffcf6b; }
pre { white-space: pre-wrap; margin: 2px 0 8px 18px; color: #ffb38a; }
.renders { display: flex; flex-wrap: wrap; gap: 12px; }
.renders figure { margin: 0; } .renders img { width: 320px; border-radius: 4px; display: block; }
figcaption { color: #9aa0aa; }
</style>
</head>
<body>
<div id="summary">running...</div>
<div id="out"></div>
<script>
const DATA = /*__DATA__*/null;
const out = document.getElementById('out');
const results = { renderer: '', compile: [], tests: [], renders: [], lint: DATA.lint };
function line(cls, text, detail) {
const d = document.createElement('div'); d.className = cls; d.textContent = text; out.appendChild(d);
if (detail) { const p = document.createElement('pre'); p.textContent = detail; out.appendChild(p); }
}
function section(t) { const h = document.createElement('h2'); h.textContent = t; out.appendChild(h); }
const canvas = document.createElement('canvas');
const gl = canvas.getContext('webgl2', { preserveDrawingBuffer: true, antialias: false });
const VS = `#version 300 es
in vec2 pos; void main() { gl_Position = vec4(pos, 0.0, 1.0); }`;
function shader(type, src) {
const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s);
return { s, ok: gl.getShaderParameter(s, gl.COMPILE_STATUS), log: gl.getShaderInfoLog(s) || '' };
}
let vs, quad;
function program(fsSrc) {
const fs = shader(gl.FRAGMENT_SHADER, fsSrc);
if (!fs.ok) return { ok: false, log: fs.log };
const p = gl.createProgram(); gl.attachShader(p, vs.s); gl.attachShader(p, fs.s);
gl.bindAttribLocation(p, 0, 'pos'); gl.linkProgram(p);
if (!gl.getProgramParameter(p, gl.LINK_STATUS)) return { ok: false, log: gl.getProgramInfoLog(p) };
return { ok: true, p };
}
function target(w, h, float) {
const tex = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, float ? gl.RGBA32F : gl.RGBA8, w, h, 0, gl.RGBA, float ? gl.FLOAT : gl.UNSIGNED_BYTE, null);
const fb = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
return { fb, tex };
}
function draw(p, w, h, uniforms) {
gl.useProgram(p); gl.viewport(0, 0, w, h);
for (const [k, v] of Object.entries(uniforms || {})) {
const loc = gl.getUniformLocation(p, k); if (!loc) continue;
if (k === 'iFrame') gl.uniform1i(loc, v);
else if (Array.isArray(v)) gl['uniform' + v.length + 'f'](loc, ...v); else gl.uniform1f(loc, v);
}
gl.drawArrays(gl.TRIANGLES, 0, 3);
}
const sleep = () => new Promise(r => setTimeout(r, 0));
async function main() {
if (!gl) { document.getElementById('summary').textContent = 'WebGL2 unavailable'; results.fatal = 'no webgl2'; return finish(); }
const dbg = gl.getExtension('WEBGL_debug_renderer_info');
results.renderer = dbg ? gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER);
const floatOK = !!gl.getExtension('EXT_color_buffer_float');
vs = shader(gl.VERTEX_SHADER, VS);
quad = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, quad);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
section('Compile (' + Object.keys(DATA.units).length + ' units)');
for (const [where, src] of Object.entries(DATA.units)) {
const r = shader(gl.FRAGMENT_SHADER, src);
results.compile.push({ where, ok: r.ok, log: r.ok ? '' : r.log });
if (!r.ok) line('bad', 'FAIL ' + where, r.log);
await sleep();
}
const compileFails = results.compile.filter(r => !r.ok).length;
line(compileFails ? 'bad' : 'ok', `${results.compile.length - compileFails}/${results.compile.length} compiled`);
section('Property tests (' + DATA.tests.length + ', 16384 samples each)');
const N = 128; const tgt = target(N, N, false); const px = new Uint8Array(N * N * 4);
for (const t of DATA.tests) {
const pr = program(t.code);
if (!pr.ok) { results.tests.push({ name: t.name, ok: false, error: pr.log }); line('bad', 'COMPILE ' + t.name, pr.log); continue; }
gl.bindFramebuffer(gl.FRAMEBUFFER, tgt.fb); draw(pr.p, N, N, { iResolution: [N, N, 1], iFrame: 0 });
gl.readPixels(0, 0, N, N, gl.RGBA, gl.UNSIGNED_BYTE, px);
const counts = {};
for (let i = 0; i < px.length; i += 4) for (let bit = 1; bit <= 128; bit <<= 1) if (px[i] & bit) counts[bit] = (counts[bit] || 0) + 1;
const rates = {}; let ok = true; const notes = [];
for (const [bit, c] of Object.entries(counts)) {
const rate = c / (N * N); rates[bit] = rate;
const allowed = (t.allow && t.allow[bit]) || 0;
if (rate > allowed) { ok = false; notes.push(`bit ${bit}: ${(rate * 100).toFixed(3)}% > ${(allowed * 100).toFixed(2)}%`); }
else notes.push(`bit ${bit}: ${(rate * 100).toFixed(3)}% (allowed)`);
}
results.tests.push({ name: t.name, ok, rates });
line(ok ? 'ok' : 'bad', (ok ? 'PASS ' : 'FAIL ') + t.name + (notes.length ? ' [' + notes.join(', ') + ']' : ''));
await sleep();
}
section('Renders (' + DATA.renders.length + ')');
const div = document.createElement('div'); div.className = 'renders'; out.appendChild(div);
const params = new URLSearchParams(location.search);
const W = +(params.get('w') || 640), H = +(params.get('h') || 360);
for (const r of DATA.renders) {
const pr = program(r.code);
if (!pr.ok) { results.renders.push({ name: r.name, ok: false, error: pr.log }); line('bad', 'COMPILE ' + r.name, pr.log); continue; }
const t0 = performance.now();
const ft = target(W, H, floatOK); gl.bindFramebuffer(gl.FRAMEBUFFER, ft.fb);
draw(pr.p, W, H, { iResolution: [W, H, 1], iTime: r.time, iFrame: 0, iMouse: [0, 0, 0, 0] });
const data = floatOK ? new Float32Array(W * H * 4) : new Uint8Array(W * H * 4);
gl.readPixels(0, 0, W, H, gl.RGBA, floatOK ? gl.FLOAT : gl.UNSIGNED_BYTE, data);
const ms = performance.now() - t0;
let nan = 0, black = 0, sum = 0, over = 0; const scale = floatOK ? 1 : 1 / 255;
for (let i = 0; i < data.length; i += 4) {
const a = data[i] * scale, b = data[i + 1] * scale, c = data[i + 2] * scale;
if (!isFinite(a) || !isFinite(b) || !isFinite(c)) { nan++; continue; }
const l = (a + b + c) / 3; sum += l; if (l < 0.004) black++; if (a > 1.001 || b > 1.001 || c > 1.001) over++;
}
const n = W * H; const stats = { nanPct: 100 * nan / n, blackPct: 100 * black / n, mean: sum / n, overPct: 100 * over / n, ms };
const ok = nan === 0 && stats.blackPct < 95 && stats.mean > 0.02;
// visible PNG
canvas.width = W; canvas.height = H; gl.bindFramebuffer(gl.FRAMEBUFFER, null);
draw(pr.p, W, H, { iResolution: [W, H, 1], iTime: r.time, iFrame: 0, iMouse: [0, 0, 0, 0] });
const url = canvas.toDataURL('image/png');
const fig = document.createElement('figure'); fig.innerHTML = `<img src="${url}"><figcaption>${r.name} · ${ms.toFixed(0)} ms · mean ${stats.mean.toFixed(3)}</figcaption>`;
div.appendChild(fig);
if (DATA.save && !r.diagnostic) await fetch('/save?path=gallery/' + r.name + '.png', { method: 'POST', body: url });
results.renders.push({ name: r.name, ok, stats });
line(ok ? 'ok' : 'bad', `${ok ? 'PASS' : 'FAIL'} ${r.name} nan=${stats.nanPct.toFixed(2)}% black=${stats.blackPct.toFixed(1)}% mean=${stats.mean.toFixed(3)} >1=${stats.overPct.toFixed(2)}%`);
await sleep();
}
finish();
}
async function finish() {
const bad = results.compile.filter(r => !r.ok).length + results.tests.filter(r => !r.ok).length + results.renders.filter(r => !r.ok).length;
results.failures = bad;
document.getElementById('summary').innerHTML =
`<b class="${bad ? 'bad' : 'ok'}">${bad ? bad + ' failure(s)' : 'all checks passed'}</b> · ${results.renderer}`;
window.RESULTS = results;
try { await fetch('/results', { method: 'POST', body: JSON.stringify(results) }); } catch (e) {}
window.DONE = true;
}
main();
</script>
</body>
</html>