From e80c4dc2d24b68587584a865ea60dc7778e9732d Mon Sep 17 00:00:00 2001 From: bvanroll Date: Mon, 27 May 2024 20:53:31 +0200 Subject: [PATCH] oki --- learning/shaping/dot.frag | 25 +++++++++++++++++++++++++ learning/shaping/dotgrid.frag | 32 ++++++++++++++++++++++++++++++++ template.frag | 2 +- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 learning/shaping/dot.frag create mode 100644 learning/shaping/dotgrid.frag diff --git a/learning/shaping/dot.frag b/learning/shaping/dot.frag new file mode 100644 index 0000000..5fffb5f --- /dev/null +++ b/learning/shaping/dot.frag @@ -0,0 +1,25 @@ +#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + + +// original test used 4. for test. It's also responsible for changing the radius, it seems anything under 1 is larger than the screen when using a radius of .9 +float circle(in vec2 _st, in float _radius, in float test){ + vec2 dist = _st-vec2(0.5); + return 1.-smoothstep(_radius-(_radius*.01),_radius+(_radius*.01), + dot(dist,dist)*test); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + color = vec3(circle(st,0.001, 4.0)); + gl_FragColor = vec4(color, 1.0); + +} diff --git a/learning/shaping/dotgrid.frag b/learning/shaping/dotgrid.frag new file mode 100644 index 0000000..3d9145f --- /dev/null +++ b/learning/shaping/dotgrid.frag @@ -0,0 +1,32 @@ +#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + + +float circle_grid(in vec2 _st, in float _radius, in float amount, in float speed, in float xdir, in float ydir){ + vec2 dist = (_st*5.)+((u_time*speed)*vec2(xdir,ydir)); + dist = fract(dist); + dist = dist-vec2(0.5); + return 1.-smoothstep(_radius-(_radius*.01),_radius+(_radius*.01), + dot(dist,dist)*4.); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + vec2 stm = (u_mouse/u_resolution)-vec2(.5); + color.r = circle_grid(st,(sin(u_time*5.)+1.)/2., 8., 2.,stm.x*-1., stm.y*-1.); + color.g = circle_grid(st,(sin(u_time*20.)+1.)/4., 8., 2.,stm.x*-1., stm.y*-1.); + color.b = circle_grid(st,(sin(u_time*30.)+1.)/8., 8., 2.,stm.x*-1., stm.y*-1.); + //color.g = circle_grid(st,1.,2.*(sin(u_time)+1.), 2.,stm.x*-1., stm.y*-1.); + //float b = circle_grid(st,1.,3.*(sin(u_time)+1.), 2.,stm.x*-1., stm.y*-1.); + //color = vec3(r,g,b); + gl_FragColor = vec4(color, circle_grid(st,1., 8., 2.,stm.x*-1., stm.y*-1.)); + +} diff --git a/template.frag b/template.frag index 9c94eba..e947173 100644 --- a/template.frag +++ b/template.frag @@ -10,6 +10,6 @@ uniform float u_time; void main() { vec2 st = gl_FragCoord.xy/u_resolution; - vec3 color = vec3(0.0,0.0,0.0) + vec3 color = vec3(0.0,0.0,0.0); gl_FragColor = vec4(color, 1.0); }