A quadratic Bezier SDF takes three control points and returns distance to the curve
A quadratic Bezier curve is defined by three 2D control points (A, B, C): the curve starts at A, ends at C, and is pulled toward B without reaching it. IQ’s sdBezier function computes the exact signed distance from any UV coordinate to this curve. Like the segment SDF, the result must have a small value subtracted to make the curve visible (the curve itself has zero width). The function depends on the utility dot2(v) = dot(v,v) from IQ’s 3D SDF page. Control points can be animated by driving them with time or mouse position, enabling fluid, dynamic curves. Subtracting multiple Bezier curves from a shape (via SDF subtraction) lets you carve decorative cuts into filled regions.
Examples
float dot2(vec2 v) { return dot(v,v); }
// IQ sdBezier with control points A, B, C:
float d = sdBezier(uv, vec2(-0.2, 0.0), vec2(0.0, 0.3), vec2(0.2, 0.0));
d -= 0.015;
float col = step(0.0, -d);
Assessment
Draw a quadratic Bezier curve with three control points of your choice. Then animate the middle control point using sin(iTime) and describe the resulting motion.