GLSL shader example

Five-Point Star SDF

A ten-edge star polygon with alternating inner and outer radii, minimum edge distance and a ray-crossing inside sign.

Live example

Edit the code and the preview updates as you type.

What to observe

Five-Point Star SDF.

Mechanism

Join five outer and five inner vertices, compute minimum segment distance, and determine the sign by ray crossing.

The controlling code

// Build 10 alternating inner/outer vertices.
// Compute min distance to every edge; ray-crossing supplies the inside sign.

Experiment

Set u_parameter to 0 and then 1, changing inner=.15+.3*u_parameter from 0.15 to 0.45. The five valleys fill outward while the five outer tips remain at radius 0.7.

Debugging and cost

The loop measures ten line segments and uses ray crossings for the inside sign. Change both alternating outer radii .7 to .55 to shorten all tips together; leaving the ten-edge loop intact preserves the five-point topology.

Built-in functions used

Learn it step by step