Ollin

Raymarching

This group covers the 3D SDF combinators: distance fields that merge, sphere-traced beside the meshes.

SketchWhat it shows
RaymarchedSDFThe 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.
RaymarchedShapesThe raymarched primitive catalog beyond the first four (rounded box, cylinder, cone, octahedron, ellipsoid). Each is a field traced into the shared depth buffer.
RaymarchedSculptThe scoped block form. Inside smoothUnion(k:) { … }, bare mesh calls (drawSphere, drawCapsule, drawCone, …) are captured as fields and melt into one traced surface.
RaymarchedDomainDomain 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.
RaymarchedRadialPolar repetition. repeatedRadially folds one wedge into an evenly spaced rosette around an axis, with no draw cost per copy.
RaymarchedPlaneThe infinite plane leaf. An unbounded ground is merged into the field and marched to the far plane, and it catches the shapes' soft shadows.
RaymarchedStretchPer-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.
RaymarchedGradientGradient paint on a merged field. A gradient fill paints the whole sphere-traced surface, sampled at each hit's projected screen position.
RaymarchedEnvironmentRaymarched fields lit by an environment. They get the same image-based lighting and traced reflections the meshes get.
RaymarchedShadowA field shadowing itself under castShadows(). A soft penumbra is marched toward the light and evaluated as part of the surface shading.
RaymarchedCastShadowA 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.
RaymarchedReceiveShadowA 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.
RaymarchedClayThe sculpt block. The combine mode and melt amount are held as state, so a form reads top to bottom like working clay.
RaymarchedJoineryMachined joints and hardware: chamfered and stepped unions, a hanging chain, a capped-torus hook.
RaymarchedDetailingThe detailing ops: fluted seams, engraved rings, grooved bands, beading, and a pipe bead left hanging where two bodies crossed.
RaymarchedDistortThe sculpting distortions: twisted, bent, displaced, and roughened, one plinth each.
RaymarchedFractalsThe 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.

↑↓ move ↩ open