From 0004cddea65315ec5f39b89f942a2aa13b62e425 Mon Sep 17 00:00:00 2001 From: bvanroll Date: Sat, 1 Jun 2024 14:44:18 +0200 Subject: [PATCH] hmmm --- experiments/holo/holo.frag | 38 ++++--------------- experiments/holo/holo_old.frag | 54 +++++++++++++++++++++++++++ learning/PixelSpirit/hierophant.frag | 9 +++++ learning/PixelSpirit/hope.frag | 47 +++++++++++++++++++++++ learning/PixelSpirit/intuition.frag | 46 +++++++++++++++++++++++ learning/PixelSpirit/merge.frag | 47 +++++++++++++++++++++++ learning/PixelSpirit/the_diamond.frag | 49 ++++++++++++++++++++++++ learning/PixelSpirit/the_hermit.frag | 50 +++++++++++++++++++++++++ learning/PixelSpirit/the_summit.frag | 49 ++++++++++++++++++++++++ learning/PixelSpirit/the_temple.frag | 42 +++++++++++++++++++++ learning/PixelSpirit/the_tower.frag | 47 +++++++++++++++++++++++ 11 files changed, 447 insertions(+), 31 deletions(-) create mode 100644 experiments/holo/holo_old.frag create mode 100644 learning/PixelSpirit/hope.frag create mode 100644 learning/PixelSpirit/intuition.frag create mode 100644 learning/PixelSpirit/merge.frag create mode 100644 learning/PixelSpirit/the_diamond.frag create mode 100644 learning/PixelSpirit/the_hermit.frag create mode 100644 learning/PixelSpirit/the_summit.frag create mode 100644 learning/PixelSpirit/the_temple.frag create mode 100644 learning/PixelSpirit/the_tower.frag diff --git a/experiments/holo/holo.frag b/experiments/holo/holo.frag index f4a1f0c..bf53929 100644 --- a/experiments/holo/holo.frag +++ b/experiments/holo/holo.frag @@ -7,47 +7,23 @@ uniform float u_time; #define PI 3.14159265359 -const vec3 uAColor = vec3(.5); -const vec3 uBColor = vec3(.5); -const vec3 uCColor = vec3(1.); -const vec3 uDColor = vec3(.3,.2,.2); +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); //get colors from http://dev.thi.ng/gradients/ vec3 cosPalette(float t) { return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); } -float circleSDF(vec2 st) { - return length(st-.5)*2.; -} - -float fill(float x, float size) { - return 1.-step(size, x); -} void main() { vec2 st = gl_FragCoord.xy/u_resolution; - float col = 0.0; - vec2 l = vec2(.5,.5)-(u_mouse/u_resolution); - l = l*.1; + vec3 color = vec3(0.0,0.0,0.0); float alpha = 1.0; - float dots = 17.; - float dotsize = .7; - vec2 off = vec2(.1,.1); - float movemod = sin(u_time)/2.+1.; - for (int i = 0; i < 4; i++) { - vec2 off1 = off * vec2(-1,1); - vec2 off2 = off * vec2(1,-1); - vec2 off3 = off * vec2(1,1); - vec2 off4 = off * vec2(-1,-1); - col += fill(circleSDF(fract(st*dots)+off1+l+movemod),dotsize)/4.; - col += fill(circleSDF(fract(st*dots)+off2+l),dotsize)/4.; - col += fill(circleSDF(fract(st*dots)+off3+l),dotsize)/4.; - col += fill(circleSDF(fract(st*dots)+off4+l),dotsize)/4.; - //col += fill(circleSDF(fract(st*dots + l*.9+off)*.3), dotsize); - off += vec2(.1,.1); - } - vec3 color = cosPalette(col); + + gl_FragColor = vec4(color, alpha); } diff --git a/experiments/holo/holo_old.frag b/experiments/holo/holo_old.frag new file mode 100644 index 0000000..cfb4b18 --- /dev/null +++ b/experiments/holo/holo_old.frag @@ -0,0 +1,54 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5); +const vec3 uBColor = vec3(.5); +const vec3 uCColor = vec3(1.); +const vec3 uDColor = vec3(.3,.2,.2); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float circleSDF(vec2 st) { + return length(st-.5)*2.; +} + +float fill(float x, float size) { + return 1.-step(size, x); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + float col = 0.0; + vec2 l = vec2(.5,.5)-(u_mouse/u_resolution); + l = l*.1; + float alpha = 1.0; + float dots = 1.; + float dotsize = .7; + vec2 off = vec2(.1,.1); + float movemod = sin(u_time)/2.+1.; + col += fill(circleSDF(fract(st*dots)+l+movemod),dotsize)/4.; + for (int i = 0; i < 4; i++) { + vec2 off1 = off * vec2(-1,1); + vec2 off2 = off * vec2(1,-1); + vec2 off3 = off * vec2(1,1); + vec2 off4 = off * vec2(-1,-1); + col += fill(circleSDF(fract(st*dots)+off1+l+movemod),dotsize)/4.; + col += fill(circleSDF(fract(st*dots)+off2+l),dotsize)/4.; + col += fill(circleSDF(fract(st*dots)+off3+l),dotsize)/4.; + col += fill(circleSDF(fract(st*dots)+off4+l),dotsize)/4.; + //col += fill(circleSDF(fract(st*dots + l*.9+off)*.3), dotsize); + off += vec2(.1,.1); + } + vec3 color = cosPalette(col); + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/hierophant.frag b/learning/PixelSpirit/hierophant.frag index 4045a89..c17eda7 100644 --- a/learning/PixelSpirit/hierophant.frag +++ b/learning/PixelSpirit/hierophant.frag @@ -31,6 +31,11 @@ float fill(float x, float size) { return 1.-step(size, x); } +float stroke(in float x_coor, float s, float width){ + float d = step(s,x_coor+width*.5)-step(s,x_coor-width*.5); + return clamp(d, 0.,1.); +} + void main() { vec2 st = gl_FragCoord.xy/u_resolution; vec3 color = vec3(0.0,0.0,0.0); @@ -41,6 +46,10 @@ void main() { //i don't understand what happens here //it has to be fract causing this to look like that color *= step(.5,fract(cross*4.)); + color *= step(1.,cross); + color += fill(cross,.5); + color += stroke(rect,.65,.05); + color += stroke(rect,.75,.025); gl_FragColor = vec4(color, alpha); } diff --git a/learning/PixelSpirit/hope.frag b/learning/PixelSpirit/hope.frag new file mode 100644 index 0000000..9d6bee7 --- /dev/null +++ b/learning/PixelSpirit/hope.frag @@ -0,0 +1,47 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float circleSDF(vec2 st) { + return length(st-.5)*2.; +} + +float vesicaSDF(vec2 st, float w) { + vec2 offset = vec2(w*.5,.0); + return max(circleSDF(st-offset), circleSDF(st+offset)); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} + +float flip(float v, float pct) { + return mix(v, 1.-v, pct); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + float ves = fill(vesicaSDF(st, .5),.8); + float lower = step((st.x+st.y)/2.,.5); + color += flip(ves, lower); + + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/intuition.frag b/learning/PixelSpirit/intuition.frag new file mode 100644 index 0000000..ff20c52 --- /dev/null +++ b/learning/PixelSpirit/intuition.frag @@ -0,0 +1,46 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +vec2 rotate(vec2 st, float a) { + st = mat2(cos(a),-sin(a),sin(a),cos(a))*(st-.5); + return st+.5; +} + +float triSDF(vec2 st) { + st = (st*2.-1.)*2.; + return max(abs(st.x)*.866025+st.y*.5,-st.y*.5); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + + st = rotate(st, radians(-25.)); + float sdf = triSDF(st); + //why does dividing the triangle with a larger triangle create a smaller black triangle area at the bottom? + sdf /= triSDF(st+vec2(.0,.2)); + color += sdf; //fill(abs(sdf),.56); + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/merge.frag b/learning/PixelSpirit/merge.frag new file mode 100644 index 0000000..bd3474a --- /dev/null +++ b/learning/PixelSpirit/merge.frag @@ -0,0 +1,47 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float circleSDF(vec2 st) { + return length(st-.5)*2.; +} +float flip(float v, float pct) { + return mix(v, 1.-v, pct); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} + +float stroke(in float x_coor, float s, float width){ + float d = step(s,x_coor+width*.5)-step(s,x_coor-width*.5); + return clamp(d, 0.,1.); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + vec2 off = vec2(.15,0); + float right = fill(circleSDF(st-off),.525); + float left = stroke(circleSDF(st+off),.5,.05); + color += flip(right, left); + + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/the_diamond.frag b/learning/PixelSpirit/the_diamond.frag new file mode 100644 index 0000000..bf85d9e --- /dev/null +++ b/learning/PixelSpirit/the_diamond.frag @@ -0,0 +1,49 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +//starting to refactor these so i can use them as individual snippets without dependencies +float rhombSDF(vec2 st) { + vec2 st1 = (st*2.-1.)*2.; + vec2 st2 = (vec2(st.x,1.-st.y)*2.-1.)*2.; + float triangle1 = max(abs(st1.x)*.866025+st1.y*.5,-st1.y*.5); + float triangle2 = max(abs(st2.x)*.866025+st2.y*.5,-st2.y*.5); + return max(triangle1, triangle2); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} + +float stroke(in float x_coor, float s, float width){ + float d = step(s,x_coor+width*.5)-step(s,x_coor-width*.5); + return clamp(d, 0.,1.); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + float sdf = rhombSDF(st); + color += fill(sdf,.425); + color += stroke(sdf, .5,.05); + color += stroke(sdf, .6,.05); + + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/the_hermit.frag b/learning/PixelSpirit/the_hermit.frag new file mode 100644 index 0000000..78e2b57 --- /dev/null +++ b/learning/PixelSpirit/the_hermit.frag @@ -0,0 +1,50 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float triSDF(vec2 st) { + st = (st*2.-1.)*2.; + return max(abs(st.x)*.866025+st.y*.5,-st.y*.5); +} + +float rhombSDF(vec2 st) { + vec2 st1 = (st*2.-1.)*2.; + vec2 st2 = (vec2(st.x,1.-st.y)*2.-1.)*2.; + float triangle1 = max(abs(st1.x)*.866025+st1.y*.5,-st1.y*.5); + float triangle2 = max(abs(st2.x)*.866025+st2.y*.5,-st2.y*.5); + return max(triangle1, triangle2); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} + +float flip(float v, float pct) { + return mix(v, 1.-v, pct); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + + float tri = fill(triSDF(st),.5); + float rhomb = fill(rhombSDF(st),.4); + color += flip(rhomb,tri); + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/the_summit.frag b/learning/PixelSpirit/the_summit.frag new file mode 100644 index 0000000..7b20d5a --- /dev/null +++ b/learning/PixelSpirit/the_summit.frag @@ -0,0 +1,49 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float circleSDF(vec2 st) { + return length(st-.5)*2.; +} +float triSDF(vec2 st) { + st = (st*2.-1.)*2.; + return max(abs(st.x)*.866025+st.y*.5,-st.y*.5); +} +float stroke(in float x_coor, float s, float width){ + float d = step(s,x_coor+width*.5)-step(s,x_coor-width*.5); + return clamp(d, 0.,1.); +} +float fill(float x, float size) { + return 1.-step(size, x); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + float circle = circleSDF(st-vec2(.0,.1)); + float triangle = triSDF(st+vec2(.0,.1)); + color += stroke(circle,.45,.1); + //good way to disable colors in a space. since mult 1. gives the og value but mult .0 sets to 0 + color *= step(.55,triangle); + color += fill(triangle,.45); + + + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/the_temple.frag b/learning/PixelSpirit/the_temple.frag new file mode 100644 index 0000000..425d60c --- /dev/null +++ b/learning/PixelSpirit/the_temple.frag @@ -0,0 +1,42 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} +//wtf even +float triSDF(vec2 st) { + st = (st*2.-1.)*2.; + return max(abs(st.x)*.866025+st.y*.5,-st.y*.5); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + st.y = 1.-st.y; + vec2 ts = vec2(st.x,.82-st.y); + color += fill(triSDF(st), .7); + color -= fill(triSDF(ts), .36); + + + + + gl_FragColor = vec4(color, alpha); +} diff --git a/learning/PixelSpirit/the_tower.frag b/learning/PixelSpirit/the_tower.frag new file mode 100644 index 0000000..d913a8d --- /dev/null +++ b/learning/PixelSpirit/the_tower.frag @@ -0,0 +1,47 @@ +#ifdef GL_ES +precision mediump float; +#endif +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +#define PI 3.14159265359 + +const vec3 uAColor = vec3(.5,.5,.5); +const vec3 uBColor = vec3(.5,.5,.5); +const vec3 uCColor = vec3(1.,1.,1.); +const vec3 uDColor = vec3(.0,.33,.67); + +//get colors from http://dev.thi.ng/gradients/ +vec3 cosPalette(float t) { + return uAColor + uBColor*cos(6.28318*(uCColor*t+uDColor)); +} + +float flip(float v, float pct) { + return mix(v, 1.-v, pct); +} + +float fill(float x, float size) { + return 1.-step(size, x); +} +float stroke(in float x_coor, float s, float width){ + float d = step(s,x_coor+width*.5)-step(s,x_coor-width*.5); + return clamp(d, 0.,1.); +} + +float rectSDF(vec2 st, vec2 s) { + st = st*2.-1.; + return max(abs(st.x/s.x),abs(st.y/s.y)); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + vec3 color = vec3(0.0,0.0,0.0); + float alpha = 1.0; + float rect = rectSDF(st, vec2(.5,1.)); + float diag = (st.x+st.y)*.5; + color += flip(fill(rect,.6),stroke(diag,.5,.01)); + + + gl_FragColor = vec4(color, alpha); +}