Created
February 15, 2016 07:01
-
-
Save co3moz/9694cbaabd95db44b043 to your computer and use it in GitHub Desktop.
Simple math function drawer in glsl shader fragment
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
#define drawFunctionRGB(function, r, g, b) if(distance(position.y, (1. + function(position.x*10.))/2.) < 0.01) color = vec3(r, g, b) | |
#define drawFunctionRGB_shifted(function, shift, r, g, b) if(distance(position.y, (1. + function(position.x*10. + shift))/2.) < 0.01) color = vec3(r, g, b) | |
// use wisely |
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
precision mediump float; | |
uniform float time; | |
uniform vec2 mouse; | |
uniform vec2 resolution; | |
#define drawFunctionRGB(function, r, g, b) if(distance(position.y, (1. + function(position.x*10.))/2.) < 0.01) color = vec3(r, g, b) | |
float myFunction(float x) { | |
return sin(x*sin(time)); | |
} | |
void main() { | |
vec2 position = ( gl_FragCoord.xy / resolution.xy ); | |
vec3 color; | |
drawFunctionRGB(myFunction, 1, 1, 0); | |
gl_FragColor = vec4( color, 1.0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment