glsl-sdf
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);
}
More from devallibus/shaderbase-skills
glsl-color
GLSL color space operations — HSV, cosine palettes, tonemapping, OKLab, sRGB. Use when working with color manipulation, gradients, palettes, or HDR rendering.
1glsl-noise
GLSL noise functions — hash, value, simplex, FBM, Voronoi, Worley. Use when generating procedural textures, terrain, organic patterns, or animated effects.
1glsl-math
GLSL math utilities — remap, smoothstep, easing, smoothmin, complex numbers, anti-aliasing helpers, constants. Use for interpolation, animation curves, or mathematical operations in shaders.
1glsl-coordinates
GLSL space transformations — rotation, polar/spherical, tiling, domain repetition. Use when manipulating coordinate spaces, creating patterns, or transforming geometry.
1shaderbase-manifest
Writing shader.json manifests for the ShaderBase registry — schema reference, capability profiles, uniforms, provenance tracking. Use when creating or editing ShaderBase shader packages.
1shaderbase-recipes
Writing Three.js and React Three Fiber integration recipes for ShaderBase shaders — factory functions, component patterns, placeholders, requirements. Use when creating shader integration code for the ShaderBase registry.
1