Skip to content

Instantly share code, notes, and snippets.

@ikekou
Created May 23, 2020 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikekou/7ff9df4b2da936432aea814a9cd4543f to your computer and use it in GitHub Desktop.
Save ikekou/7ff9df4b2da936432aea814a9cd4543f to your computer and use it in GitHub Desktop.
// Draw Line https://www.shadertoy.com/view/4ljfRD
float drawLine (vec2 p1, vec2 p2, vec2 uv, float a)
{
float r = 0.;
float one_px = 1. / iResolution.x; //not really one px
// get dist between points
float d = distance(p1, p2);
// get dist between current pixel and p1
float duv = distance(p1, uv);
//if point is on line, according to dist, it should match current uv
r = 1.-floor(1.-(a*one_px)+distance (mix(p1, p2, clamp(duv/d, 0., 1.)), uv));
r = max(0.,r); // added ikekou
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment