Raymarching

















This group covers the 3D SDF combinators: distance fields that merge, sphere-traced beside the meshes.
| Sketch | What it shows |
|---|---|
| RaymarchedSDF | The 3D SDF combinators sphere-traced as one surface. Spheres melt together by smooth-union, and their colors blend through the seam. One sphere orbits, and a bite is carved out by subtraction. |
| RaymarchedShapes | The raymarched primitive catalog beyond the first four (rounded box, cylinder, cone, octahedron, ellipsoid). Each is a field traced into the shared depth buffer. |
| RaymarchedSculpt | The scoped block form. Inside smoothUnion(k:) { … }, bare mesh calls (drawSphere, drawCapsule, drawCone, …) are captured as fields and melt into one traced surface. |
| RaymarchedDomain | Domain operators. repeated(spacing:count:) tiles a unit cell into a finite lattice, and mirrored(x:y:z:) folds one built lobe into a symmetric form. The whole thing stays one surface. |
| RaymarchedRadial | Polar repetition. repeatedRadially folds one wedge into an evenly spaced rosette around an axis, with no draw cost per copy. |
| RaymarchedPlane | The infinite plane leaf. An unbounded ground is merged into the field and marched to the far plane, and it catches the shapes' soft shadows. |
| RaymarchedStretch | Per-axis sizing. stretched is exact elongation, so a sphere becomes a capsule. Beside it, scaled(x:y:z:) is a true non-uniform scale, marched conservatively. |
| RaymarchedGradient | Gradient paint on a merged field. A gradient fill paints the whole sphere-traced surface, sampled at each hit's projected screen position. |
| RaymarchedEnvironment | Raymarched fields lit by an environment. They get the same image-based lighting and traced reflections the meshes get. |
| RaymarchedShadow | A field shadowing itself under castShadows(). A soft penumbra is marched toward the light and evaluated as part of the surface shading. |
| RaymarchedCastShadow | A field casting a shadow onto meshes under a directional or point light (any key switches). Either the field renders into the 2D shadow map, or the lit mesh fragments march the field inline toward the light. |
| RaymarchedReceiveShadow | A field receiving a mesh's cast shadow under a directional or point light (any key switches). The traced surface samples the 2D map, the shadow cube, or the acceleration structure at its hit. |
| RaymarchedClay | The sculpt block. The combine mode and melt amount are held as state, so a form reads top to bottom like working clay. |
| RaymarchedJoinery | Machined joints and hardware: chamfered and stepped unions, a hanging chain, a capped-torus hook. |
| RaymarchedDetailing | The detailing ops: fluted seams, engraved rings, grooved bands, beading, and a pipe bead left hanging where two bodies crossed. |
| RaymarchedDistort | The sculpting distortions: twisted, bent, displaced, and roughened, one plinth each. |
| RaymarchedFractals | The fractal leaves: a Mandelbulb, a Menger sponge, and a Mandelbox. Each is a distance estimate that the same sphere tracer draws. A menu picks one, and the bulb's power, the sponge's depth, and the box's scale are each a parameter of their own. |
Run one with swift run Example-3D-Raymarching-<Name>, for example swift run Example-3D-Raymarching-RaymarchedSDF.