shaders

assortment of fragment shaders.
Log | Files | Refs | README | LICENSE

commit 7d0c03b6af58f17e430ca6d0f0a911328aef59b9
parent d608712bb19f4732d4b835a9c6623562c54b1d2a
Author: mpizzzle <m@michaelpercival.xyz>
Date:   Tue,  8 Sep 2020 11:38:39 +0100

???

Diffstat:
Acombo.frag | 43+++++++++++++++++++++++++++++++++++++++++++
Mmiyagi2.frag | 3---
2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/combo.frag b/combo.frag @@ -0,0 +1,43 @@ +#ifdef GL_ES +precision mediump float; +#endif + +#define PI 3.14159265359 + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +float quadraticBezier(float x, vec2 ab) { + float epsilon = 0.00001; + float a = max(0.0, min(1.0, ab.x)); + float b = max(0.0, min(1.0, ab.y)); + + if (a == 0.5) { + a += epsilon; + } + + // solve t from x (an inverse operation) + float om2a = 1.0 - 2.0 * a; + float t = (sqrt(a * a + om2a * x) - a) / om2a; + return (1.0 - 2.0 * b) * (t * t) + (2.0 * b) * t; +} + +void main() { + vec2 st = gl_FragCoord.xy / u_resolution; + + float y = quadraticBezier(st.x, u_mouse / u_resolution); + float yy = (sin(st.x * PI / 2.0 + (u_time * 1.5)) / 2.0) + 0.5; + vec3 color = vec3(y); + vec3 color2 = vec3(yy); + float thickness = 0.02; + + float plot = smoothstep(y - thickness, y, st.y) - smoothstep(y, y + thickness, st.y); + float plot2 = smoothstep(yy - thickness, yy, st.y) - smoothstep(yy, yy + thickness, st.y); + + color = (1.0 - plot) + plot * vec3(1.0, 0.0, 1.0); + color2 = (1.0 - plot2) + plot2 * vec3(0.0, 1.0, 0.0); + + gl_FragColor = vec4(color * color2, 1.0); +} + diff --git a/miyagi2.frag b/miyagi2.frag @@ -11,9 +11,6 @@ uniform float u_time; void main() { vec2 st = gl_FragCoord.xy / u_resolution; - //float y = (sin(st.x * PI / 2.0 + (u_time * 1.5)) / 2.0) + 0.5; - //float y = abs(sin(st.x * PI / 2.0 + (u_time * 1.5))); - //float y = fract(sin(st.x * PI / 2.0 + (u_time * 1.5))); float y = (sin(st.x * PI / 2.0 + (u_time * 1.5)) / 2.0) + 0.5; vec3 color = vec3(y);