Shape SDF 1.0.0 Scripts 4.2 Community
Submitted by user hena9704; MIT; 2026-11-26
Shape SDF answers "how far is this point from that collision shape?" It returns the signed distance (negative inside), the closest point on the surface and the outward surface normal, for Godot's own physics shapes in 2D and 3D.
Use it for gravity or magnet forces around capsule, box or torus shaped planets, to find the nearest surface to snap or teleport to, to measure how deep something is inside an area, for time to impact, or for ray marching against colliders.
It is plain GDScript with static functions in ShapeSDF3D and ShapeSDF2D, so there is nothing to enable. Query a shape with a transform, a CollisionShape node, or every shape of a body or area at once. Supported: Sphere, Box, Capsule, Cylinder and WorldBoundary shapes and tori in 3D; Circle, Rectangle, Capsule, ConvexPolygon, Segment and WorldBoundary shapes in 2D. ConvexPolygonShape3D, concave and heightmap shapes are not supported yet.
This add-on implements godot-proposals#5218. The distance formulas follow Inigo Quilez's distance functions. It was tested in Godot 4.2.2, 4.6.3 and 4.7.2 (also with Jolt in 4.6.3 and 4.7.2), including checks against the physics engine's own queries. Documentation, known limitations, demos and a Korean version are in the repository.
View files Download Submit an issue Recent Edits