Created
March 13, 2016 11:08
-
-
Save co3moz/08a1923f7ef586e13cd0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
co3moz | |
github.com/co3moz | |
draw => for y-finite solutions | |
drawYInfinite => for y-infinite solutions | |
press left button of mouse and move for move. | |
press right button of mouse and move for scale. | |
press shift and left button of mouse, move a little bit will reset to default position. | |
*/ | |
precision highp float; | |
uniform float time; | |
uniform vec2 mouse; | |
uniform vec2 resolution; | |
varying vec2 surfacePosition; | |
#define draw(function, r, g, b) if(distance(function(p.x - c.x), p.y - c.y) < 0.01) color = vec3(r, g, b) | |
#define drawYInfinite(function, r, g, b) if(distance(function(p.x - c.x), p.y - c.y) < abs(function(p.x - c.x) - function(p.x - c.x - 0.01))) color = vec3(r, g, b) | |
#define mouseTrack(function) if(distance(mouse.x * aspect.x, p.x) < 0.003 && function(p.x - c.x) - p.y + c.y > 0.0 && sin((c.y - p.y) * 200.0) < 0.1) color = vec3(0.5, 0.5, 0.5) | |
float y1(float x) { | |
return x; | |
} | |
float y2(float x) { | |
return sin(x); | |
} | |
float y3(float x) { | |
return sin(x + time); | |
} | |
void main(void) { | |
vec2 aspect = resolution.xy / min(resolution.x, resolution.y); | |
vec2 c = vec2(0.5) * aspect - surfacePosition * 1.5; | |
vec2 p = gl_FragCoord.xy / min(resolution.x, resolution.y); | |
vec3 color = vec3(0.0); | |
draw(y1, 1.0, 1.0, 1.0); // y1 | |
draw(y2, 0.0, 0.0, 1.0); // y2 | |
draw(y3, 0.0, 1.0, 1.0); // y3 | |
mouseTrack(y3); // mouse tracking | |
if(distance(p.y, c.y) < 0.005 && sin((c.x - p.x) * 200.0) < 0.1) color = vec3(0.0, 1.0, 0.0); // horizontal | |
if(distance(p.x, c.x) < 0.005 && sin((c.y - p.y) * 200.0) < 0.1) color = vec3(1.0, 0.0, 1.0); // vertical | |
gl_FragColor = vec4(color, 1.0); | |
} |
Author
co3moz
commented
Mar 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment