Skip to content

Instantly share code, notes, and snippets.

@heyomidk
heyomidk / sdDashedCircle.hlsl
Created December 9, 2021 06:24
SDF - Dashed Circle (HLSL), source: https://www.shadertoy.com/view/7tyGWw
float arcRadius = length(p);
// Compute the radial distance field coming out from the center of a torus
const float hw = (RadiusOuter-RadiusInner)*0.5; // half width from center of torus to edge
float radialDF = arcRadius - (RadiusOuter-hw); // creates a torus
radialDF = abs(radialDF)-hw; // give an inside and outside to the torus
// Compute the gradient along the length of the arc
float arcGradient = atan2(p.y,p.x)/6.283185;
arcGradient = frac(arcGradient*NumDashes);