Skip to content

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.

Make glsl_tools check reject sine hashes

Gökay6573f2b3b44e
diff --git a/skills/shader-art-coding/SKILL.md b/skills/shader-art-coding/SKILL.md
index 2079a3a..276a881 100644
--- a/skills/shader-art-coding/SKILL.md
+++ b/skills/shader-art-coding/SKILL.md
@@ -61,7 +61,9 @@ Run the scripts from this skill's directory. They need only Python 3.
- No `#version` line, no custom uniforms, no `gl_FragColor` / `texture2D` / `iGlobalTime`.
- No `?:` on structs. Use `vec2(distance, id)` or `if`.
- Write float literals: `2.0 * PI`, `clamp(x, 0.0, 1.0)`.
-- No `fract(sin(...) * 43758.5453)` hashes. Use `hash12` / `hash22` / `hash33` (integer PCG).
+- No `fract(sin(...) * 43758.5453)` hashes. Use `hash12` / `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. `check` reports a sine hash as an error.
- Guard NaN sources: `atan(0, 0)`, `pow` of negatives, `sqrt` of negatives, `normalize(vec3(0))`.
- Keep `dFdx` / `fwidth` out of non-uniform branches and loops, or use an explicit pixel size.
diff --git a/skills/shader-art-coding/scripts/glsl_tools.py b/skills/shader-art-coding/scripts/glsl_tools.py
index 9de1aaf..f2a7005 100644
--- a/skills/shader-art-coding/scripts/glsl_tools.py
+++ b/skills/shader-art-coding/scripts/glsl_tools.py
@@ -318,8 +318,10 @@ SHADER_RULES = [
(r"\biGlobalTime\b", "error", "iGlobalTime was removed from Shadertoy; use iTime"),
(r"\biDebugMode\b", "error", "iDebugMode is not a Shadertoy uniform; use '#define DEBUG_MODE 0'"),
(r"^\s*#version\b", "error", "do not add #version; Shadertoy (and the bundler's prelude) provide it"),
- (r"fract\s*\(\s*sin\s*\(", "warning",
- "sine-based hash: platform-dependent and degrades at large inputs; use hash12/hash22 from glsl/hash.glsl"),
+ # fract(sin(..)), fract(1e4 * sin(..)), and the 43758.5453 constant wherever the multiply happens
+ (r"\bfract\s*\(\s*[-+]?\s*(?:[\d.]+(?:[eE][-+]?\d+)?\s*\*\s*)?sin\s*\(|43758\.5453", "error",
+ "sine hash: its pattern differs across GPUs and degrades at large inputs; use hash12/hash22/hash33 from "
+ "glsl/hash.glsl, also when porting (value noise keeps its look)"),
(r"\bround\s*\(", "warning", "round() is implementation-defined at .5 and may return -0.0; prefer floor(x + 0.5)"),
]