---
name: glsl-sdf-shapes
description: Generates perfect 3D mathematical shapes (Heart, Diamond, Star, Spades, Clubs, etc.) in GLSL using SDFs. Can be used standalone or integrated into typography.
title: glsl-sdf-shapes
canonical_url: https://skilld.dev/gh/playful-design/liquid-glass-skill/glsl-sdf-shapes
last_updated: 2026-11-12T03:00:55.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [shapes.glsl](https://skilld.dev/api/skills-raw/playful-design/liquid-glass-skill/glsl-sdf-shapes/shapes.glsl).
>
> If the user asked to install this Skill, run `npx skilld install playful-design/liquid-glass-skill/glsl-sdf-shapes`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/glsl-sdf-shapes`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/playful-design/liquid-glass-skill/glsl-sdf-shapes) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/glsl-sdf-shapes`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/glsl-sdf-shapes --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/glsl-sdf-shapes --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# GLSL SDF Shapes Builder

## 1. Role and Expected Behavior
You are a GLSL SDF expert specializing in mathematical shapes. When the user requests a classic design shape (e.g., Heart, Star, Diamond, Spade, Club), you must generate the exact mathematical 2D SDF for this shape, and extrude it into 3D.

## 2. Geometry: Exact Mathematical SDFs
Do NOT approximate shapes with messy combinations if an analytical formula exists (use Inigo Quilez standards).

- **Heart:** Use the exact analytical 2D heart SDF (using `atan2` or cubic/quadratic equations).
- **Star:** Use the exact 2D star SDF with angles and `cos`/`sin` parameters.
- **Diamond / Card Suits:** Use symmetric combinations of smooth geometric primitives, `smin`, or specific polygon SDFs to create perfect vector-like 2D shapes.

Scale the 2D SDF appropriately so it naturally fits within a `[-1.0, 1.0]` coordinate space.

```glsl
// Example structure for a custom shape
float sdfStar(vec2 p, float r, int n, float m) {
    // ... exact mathematical star SDF ...
    return d;
}
```

## 3. Shape Catalogue
Match the user's words (in any language) to these shapes. Centre each shape's visual bounding box on the origin and make it fit `[-1, 1]`.

**Ready in `shapes.glsl`** (the typography script uses these names directly; preview of all of them: `previews/shapes-catalogue.png` in the project):

| Name | Words users may use |
|---|---|
| `circle` | dot, round, bubble, rond |
| `heart` | heart, love, cœur, ♥ |
| `star` | star, étoile |
| `sparkle` | sparkle, twinkle, shine, étincelle, ✦ |
| `diamond` | diamond, rhombus, losange, carreau, ♦ |
| `moon` | moon, crescent, croissant de lune, lune |
| `fullmoon` | full moon, pleine lune |
| `flower` | flower, fleur |
| `plus` | plus, cross, croix |
| `butterfly` | butterfly, papillon |
| `butterflies` | butterflies, papillons (two butterflies) |
| `cloud` | cloud, nuage |
| `crown` | crown, couronne |
| `spade` | spade, ace of spades, pique, as de pique, ♠ |
| `club` | club, clover, trèfle, ♣ |

**Other shapes** (build them as below, then add them to `shapes.glsl`):

| Shape | Words users may use | Build |
|---|---|---|
| Circle | dot, round, bubble, rond | exact: `length(p) - r` |
| Heart | heart, love, cœur, ♥ | exact IQ `sdHeart`, recentred |
| Star | star, étoile (5 points by default), n-point star | exact IQ `sdStar5` / `sdStar` |
| Sparkle | sparkle, twinkle, étincelle | exact IQ `sdStar`, 4 points, sharp |
| Diamond | diamond, rhombus, losange, ♦ | exact IQ `sdRhombus` |
| Crescent moon | moon, crescent, lune | exact IQ `sdMoon` |
| Plus / cross | plus, cross, croix | exact IQ `sdCross` |
| X | x, kiss, saltire | exact IQ `sdRoundedX` |
| Triangle | triangle | exact IQ `sdEquilateralTriangle` |
| Polygons | pentagon, hexagon, octagon | exact IQ `sdPentagon` / `sdHexagon` / `sdOctogon` |
| Ring | ring, donut, anneau | exact: `abs(length(p) - r) - t` |
| Drop | drop, teardrop, goutte | circle + isosceles triangle (IQ `sdTriangleIsosceles`), `smin` |
| Leaf / petal | leaf, petal, eye, feuille | exact IQ `sdVesica` |
| Flower | flower, fleur | 5 or 6 circles around a centre circle, `min` |
| Lightning bolt | lightning, bolt, éclair | exact IQ `sdPolygon`, about 6 vertices |
| Arrow | arrow, flèche | exact IQ `sdPolygon` |

Any other outline (house, bow, crown variants…): use `sdPolygon` if it is polygonal (exact), otherwise compose the primitives above and tell the user it is a composed approximation.

## 4. Integration with Typography (Custom Dots)
If this shape is being called by the `glsl-sdf-typography` skill to replace a dot or accent, output ONLY the 2D SDF function. The typography skill will handle the scaling, translation, and 3D extrusion.

`shapes.glsl` (next to this file) is the ready-made library the typography script uses: `circle heart star sparkle diamond moon flower plus`. To make a new shape available to the script, add it there as a block starting with `// @shape <name>` and ending with `// @end`, defining `float sdf<Name>(vec2 p)`, centred on the origin and fitting `[-1, 1]`. Give any helper function a name unique to that block.

## 5. Standalone 3D Extrusion
If the shape is requested as a standalone object (e.g., "Generate a 3D Heart"), extrude it into a thick 3D object with a smooth bevel to catch specular highlights beautifully.

```glsl
// Inside map(vec3 pos)
float d2d = sdfRequestedShape(pos.xy);
float depth = 0.3; // Thickness of the glass/solid shape
float bevel = 0.08; // Smooth rounded edges
    
float d3d = length(max(vec2(d2d, abs(pos.z) - depth), 0.0)) + min(max(d2d, abs(pos.z) - depth), 0.0) - bevel;
```

## 6. Rendering Setup (If Standalone)
If rendering as a standalone object to verify geometry:
- Implement a standard Raymarching loop.
- Compute surface normals `N` via finite differences (`eps = 0.001`).
- Center the object. You may add a slow rotation on the Y/X axis (`pos.xz *= rot(iTime);`) to showcase the 3D volume.