web-shaders

A set of rules for writing and debugging web shaders, which are small programs that control how graphics are drawn in a browser.

In plain words
What is it for?
Use it when working with GLSL or WGSL, WebGL, WebGPU, Three.js, or React Three Fiber shaders.
Why use it?
It helps choose the right shader language and framework setup while avoiding common rendering and color mistakes.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/owenob1/web-shaders-agent-kit/web-shaders
Clone the repo
git clone --depth 1 https://github.com/owenob1/web-shaders-agent-kit
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 678 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00678
Opus 5 $0.00000 $0.00339
Sonnet 5 $0.00000 $0.00136
Haiku 4.5 $0.00000 $0.00068

Measured yesterday against content hash 557dd9ecbe55, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

web-shaders scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/cursor/web-shaders.mdc · 32 lines

What it actually says

Web shader rules

Before writing a shader, establish the target — the boilerplate and language differ:

  • Raw WebGL 2 → GLSL ES 3.00 (#version 300 es, in/out, texture(), custom out vec4).
  • Three.js ShaderMaterial → GLSL ES 1.00 by default; position, normal, uv, modelViewMatrix, projectionMatrix, normalMatrix, cameraPosition, and precision are already injected — don't redeclare them. Use glslVersion: THREE.GLSL3 for GLSL 3.
  • Three.js RawShaderMaterial → you write the full header, including precision highp float;.
  • Three.js WebGPURenderer → prefer TSL (JS nodes) over raw WGSL; it cross-compiles to WGSL and GLSL.
  • React Three Fiber → use drei shaderMaterial + extend; drive uniforms from a useFrame ref, not React state.

Correctness checklist:

  • Aspect-correct UVs (uv.x *= resolution.x / resolution.y) or circles become ellipses.
  • Do color math in linear space; sample color textures as sRGB, data textures (normal/roughness) as linear. Mind renderer.toneMapping.
  • Flip vUv.y when a texture is upside down (GL origin is bottom-left; render targets have flipY = false).
  • No dynamic array indexing / non-constant loops in WebGL 1 GLSL. Integer division truncates — write 1.0/3.0.
  • pow(negative, y) and mod of negatives are footguns; guard normalize() against zero vectors.
  • Prefer mix/step/smoothstep over branching; both branches of a divergent if may run.
  • WGSL has no implicit numeric conversions (1 is i32, 1.0 is f32); pad vec3 to 16 bytes in uniform structs.

Pull ready functions (noise, SDF, easing, color) from Lygia (https://lygia.xyz) instead of reimplementing.

Debug by outputting intermediates to color (gl_FragColor = vec4(vec3(d), 1.0)), reading the console for compile errors, and confirming uniform names match exactly between JS and the shader (mismatches fail silently). Inspect with Spector.js (WebGL) or the WebGPU Inspector.

When unsure of an API, consult https://threejs.org/docs/llms.txt, https://webgl2fundamentals.org, https://webgpufundamentals.org, https://www.w3.org/TR/WGSL/, and https://iquilezles.org/articles/ rather than guessing.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 32 lines · 678 tokens per session scan A 557dd9ecbe55

Subscribe to this mod's changes

web-shaders is a cursor rule published in the GitHub repository owenob1/web-shaders-agent-kit (2 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 678 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.