Skip to content

Instantly share code, notes, and snippets.

@behreajj
Last active May 22, 2021 12:29
Show Gist options
  • Save behreajj/c742a9a0b10bedbc640efa3fd36755ba to your computer and use it in GitHub Desktop.
Save behreajj/c742a9a0b10bedbc640efa3fd36755ba to your computer and use it in GitHub Desktop.
Circle 0
shader circle0(
vector UV = vector(0.5, 0.5, 0.0),
vector Center = vector(0.5, 0.5, 0.0),
float Radius = 1.0,
float Blur = 0.0,
color Outside = color(1.0, 0.0, 0.0),
color Inside = 1.0,
output color Color = 0.8,
output float Fac = 0.5) {
vector diff = Center - UV;
float lenSq = dot(diff, diff);
float eval = 0.25 * Radius * Radius - lenSq;
float halfBlur = 0.5 * clamp(Blur, 0.0, 1.0);
Fac = smoothstep(-halfBlur, halfBlur, eval);
Color = mix(Outside, Inside, Fac);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment