glsl-sdf

Installation
SKILL.md

GLSL Signed Distance Fields

A signed distance field (SDF) returns the shortest distance from a point to a shape's surface. Negative = inside, positive = outside, zero = on the boundary.

2D Primitives

// Circle
float sdCircle(vec2 p, float r) {
  return length(p) - r;
}

// Box (centered at origin)
float sdBox(vec2 p, vec2 b) {
  vec2 d = abs(p) - b;
  return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
}
Related skills
Installs
1
GitHub Stars
2
First Seen
Apr 14, 2026