Created
May 23, 2020 00:07
-
-
Save ikekou/7ff9df4b2da936432aea814a9cd4543f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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