diff --git a/wip/Version 1.0/BookFlip.frag b/wip/Version 1.0/BookFlip.frag new file mode 100644 index 0000000..5c8e37f --- /dev/null +++ b/wip/Version 1.0/BookFlip.frag @@ -0,0 +1,46 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BookFlip.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; + +uniform float progress; + +vec2 skewRight(vec2 p) { + float skewX = (p.x - progress)/(0.5 - progress) * 0.5; + float skewY = (p.y - 0.5)/(0.5 + progress * (p.x - 0.5) / 0.5)* 0.5 + 0.5; + return vec2(skewX, skewY); +} + +vec2 skewLeft(vec2 p) { + float skewX = (p.x - 0.5)/(progress - 0.5) * 0.5 + 0.5; + float skewY = (p.y - 0.5) / (0.5 + (1.0 - progress ) * (0.5 - p.x) / 0.5) * 0.5 + 0.5; + return vec2(skewX, skewY); +} + +vec4 addShade() { + float shadeVal = max(0.7, abs(progress - 0.5) * 2.0); + return vec4(vec3(shadeVal ), 1.0); +} + +vec4 transition (vec2 p) { + float pr = step(1.0 - progress, p.x); + + if (p.x < 0.5) { + return mix(texture2D(texture,p), vec4(1.0)* addShade(), pr); + } else { + return mix(texture2D(texture,skewRight(p)) * addShade(), vec4(0.0), pr); + } +} + +void main(void) +{ + + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/BookFlip.gre b/wip/Version 1.0/BookFlip.gre new file mode 100644 index 0000000..d405eef --- /dev/null +++ b/wip/Version 1.0/BookFlip.gre @@ -0,0 +1,8 @@ + + + + + + diff --git a/wip/Version 1.0/DoomScreenTransition.frag b/wip/Version 1.0/DoomScreenTransition.frag new file mode 100644 index 0000000..151e0b9 --- /dev/null +++ b/wip/Version 1.0/DoomScreenTransition.frag @@ -0,0 +1,80 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DoomScreenTransition.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float progress;// = 0.01; +// Transition parameters -------- + +// Number of total bars/columns +uniform int bars; // = 30; // + +// Multiplier for speed ratio. 0 = no variation when going down, higher = some elements go much faster +uniform float amplitude ; // = 2.0; // + +// Further variations in speed. 0 = no noise, 1 = super noisy (ignore frequency) + uniform float noise ; // = 0.1; // + +// Speed variation horizontally. the bigger the value, the shorter the waves +uniform float frequency; // = 0.5; // + +// How much the bars seem to "run" from the middle of the screen first (sticking to the sides). 0 = no drip, 1 = curved drip +uniform float dripScale; // = 0.5; // + + +// The code proper -------- + +float rand(int num) { + return fract(mod(float(num) * 67123.313, 12.0) * sin(float(num) * 10.3) * cos(float(num))); +} + +float wave(int num) { + float fn = float(num) * frequency * 0.1 * float(bars); + return cos(fn * 0.5) * cos(fn * 0.13) * sin((fn+10.0) * 0.3) / 2.0 + 0.5; +} + +float drip(int num) { + return sin(float(num) / float(bars - 1) * 3.141592) * dripScale; +} + +float pos(int num) { + return (noise == 0.0 ? wave(num) : mix(wave(num), rand(num), noise)) + (dripScale == 0.0 ? 0.0 : drip(num)); +} + +vec4 transition(vec2 uv) { + int bar = int(uv.x * (float(bars))); + float scale = 1.0 + pos(bar) * amplitude; + float phase = progress * scale; + float posY = uv.y / vec2(1.0).y; + vec2 p; + vec4 c; + if (phase + posY < 1.0) { + p = vec2(uv.x, uv.y + mix(0.0, vec2(1.0).y, phase)) / vec2(1.0).xy; + c = texture2D(texture,p); + } else { + p = uv.xy / vec2(1.0).xy; + c = vec4(0.0); // for future use + } + + // Finally, apply the color + return c; +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = gl_FragCoord.xy/resolution.xy; + + + // Output to screen + fragColor = transition(uv); +} + diff --git a/wip/Version 1.0/DoomScreenTransition.gre b/wip/Version 1.0/DoomScreenTransition.gre new file mode 100644 index 0000000..2e16136 --- /dev/null +++ b/wip/Version 1.0/DoomScreenTransition.gre @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/wip/Version 1.0/HorizontalClose.frag b/wip/Version 1.0/HorizontalClose.frag new file mode 100644 index 0000000..f314e6c --- /dev/null +++ b/wip/Version 1.0/HorizontalClose.frag @@ -0,0 +1,27 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/HorizontalClose.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; + +uniform float progress; +uniform float feather; +vec4 transition (vec2 uv) { + + float s = 2.0 - abs((uv.y - 0.5) / (progress - 1.0)) - 2.0 * progress; + + return mix( + texture2D(texture,uv), + vec4(0.0), + smoothstep(feather, 0.0 , s) + ); +} +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/HorizontalClose.gre b/wip/Version 1.0/HorizontalClose.gre new file mode 100644 index 0000000..e875628 --- /dev/null +++ b/wip/Version 1.0/HorizontalClose.gre @@ -0,0 +1,9 @@ + + + + + + + diff --git a/wip/Version 1.0/LeftRight.frag b/wip/Version 1.0/LeftRight.frag new file mode 100644 index 0000000..7e80870 --- /dev/null +++ b/wip/Version 1.0/LeftRight.frag @@ -0,0 +1,39 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/LeftRight.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; + +uniform float progress; + +const vec4 black = vec4(0.0, 0.0, 0.0, 1.0); +const vec2 boundMin = vec2(0.0, 0.0); +const vec2 boundMax = vec2(1.0, 1.0); + +bool inBounds (vec2 p) { + return all(lessThan(boundMin, p)) && all(lessThan(p, boundMax)); +} + +vec4 transition (vec2 uv) { + vec2 spfr,spto = vec2(-1.); + + float size = mix(1.0, 3.0, progress*0.2); + spto = (uv + vec2(-0.5,-0.5))*vec2(size,size)+vec2(0.5,0.5); + spfr = (uv - vec2(1.-progress, 0.0)); + if(inBounds(spfr)){ + return vec4(0.0); + }else if(inBounds(spto)){ + return texture2D(texture,spto) * (1.0 - progress); + } else{ + return black; + } +} +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/LeftRight.gre b/wip/Version 1.0/LeftRight.gre new file mode 100644 index 0000000..a24a7bd --- /dev/null +++ b/wip/Version 1.0/LeftRight.gre @@ -0,0 +1,8 @@ + + + + + + diff --git a/wip/Version 1.0/PolkaDotsCurtain.frag b/wip/Version 1.0/PolkaDotsCurtain.frag new file mode 100644 index 0000000..8158614 --- /dev/null +++ b/wip/Version 1.0/PolkaDotsCurtain.frag @@ -0,0 +1,32 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/PolkaDotsCurtain.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; +uniform vec2 resolution; + +const float SQRT_2 = 1.414213562373; + +uniform float progress; +uniform float dots; +uniform vec2 center; + +vec4 transition(vec2 uv) { + float ar = resolution.x/resolution.y; + uv.x*=ar; + bool nextImage = distance(fract(uv * dots), vec2(0.5, 0.5)) < ( progress / distance(uv, center)); + uv.x/=ar; +// return nextImage ? vec4(0.0) : texture2D(texture,uv); +return nextImage ? texture2D(texture,uv) : vec4(0.0); +} + +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/PolkaDotsCurtain.gre b/wip/Version 1.0/PolkaDotsCurtain.gre new file mode 100644 index 0000000..ab668e2 --- /dev/null +++ b/wip/Version 1.0/PolkaDotsCurtain.gre @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/wip/Version 1.0/VHS.frag b/wip/Version 1.0/VHS.frag new file mode 100644 index 0000000..622d503 --- /dev/null +++ b/wip/Version 1.0/VHS.frag @@ -0,0 +1,91 @@ +/* Adapted from https://www.shadertoy.com/view/XtBXDt +Rebuilt for enve/friction by axiomgraph + Opengl version 3.3*/ + +#version 330 core +#define PI 3.14159265 + + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float time; + +vec3 tex2D( sampler2D texture, vec2 _p ){ + vec3 col = texture2D( texture, _p ).xyz; + if ( 0.5 < abs( _p.x - 0.5 ) ) { + col = vec3( 0.1 ); + } + return col; +} + +float hash( vec2 _v ){ + return fract( sin( dot( _v, vec2( 89.44, 19.36 ) ) ) * 22189.22 ); +} + +float iHash( vec2 _v, vec2 _r ){ + float h00 = hash( vec2( floor( _v * _r + vec2( 0.0, 0.0 ) ) / _r ) ); + float h10 = hash( vec2( floor( _v * _r + vec2( 1.0, 0.0 ) ) / _r ) ); + float h01 = hash( vec2( floor( _v * _r + vec2( 0.0, 1.0 ) ) / _r ) ); + float h11 = hash( vec2( floor( _v * _r + vec2( 1.0, 1.0 ) ) / _r ) ); + vec2 ip = vec2( smoothstep( vec2( 0.0, 0.0 ), vec2( 1.0, 1.0 ), mod( _v*_r, 1. ) ) ); + return ( h00 * ( 1. - ip.x ) + h10 * ip.x ) * ( 1. - ip.y ) + ( h01 * ( 1. - ip.x ) + h11 * ip.x ) * ip.y; +} + +float noise( vec2 _v ){ + float sum = 0.; + for( int i=1; i<9; i++ ) + { + sum += iHash( _v + vec2( i ), vec2( 2. * pow( 2., float( i ) ) ) ) / pow( 2., float( i ) ); + } + return sum; +} + +void main(void){ + vec2 uv = gl_FragCoord.xy / resolution; + vec2 uvn = uv; + vec3 col = vec3( 0.0 ); + + // tape wave + uvn.x += ( noise( vec2( uvn.y, time ) ) - 0.5 )* 0.005; + uvn.x += ( noise( vec2( uvn.y * 100.0, time * 10.0 ) ) - 0.5 ) * 0.01; + + // tape crease + float tcPhase = clamp( ( sin( uvn.y * 8.0 - time * PI * 1.2 ) - 0.92 ) * noise( vec2( time ) ), 0.0, 0.01 ) * 10.0; + float tcNoise = max( noise( vec2( uvn.y * 100.0, time * 10.0 ) ) - 0.5, 0.0 ); + uvn.x = uvn.x - tcNoise * tcPhase; + + // switching noise + float snPhase = smoothstep( 0.03, 0.0, uvn.y ); + uvn.y += snPhase * 0.3; + uvn.x += snPhase * ( ( noise( vec2( uv.y * 100.0, time * 10.0 ) ) - 0.5 ) * 0.2 ); + + col = tex2D( texture, uvn ); + col *= 1.0 - tcPhase; + col = mix( + col, + col.yzx, + snPhase + ); + + // bloom + for( float x = -4.0; x < 2.5; x += 1.0 ){ + col.xyz += vec3( + tex2D( texture, uvn + vec2( x - 0.0, 0.0 ) * 7E-3 ).x, + tex2D( texture, uvn + vec2( x - 2.0, 0.0 ) * 7E-3 ).y, + tex2D( texture, uvn + vec2( x - 4.0, 0.0 ) * 7E-3 ).z + ) * 0.1; + } + col *= 0.6; + + // ac beat + col *= 1.0 + clamp( noise( vec2( 0.0, uv.y + time * 0.2 ) ) * 0.6 - 0.25, 0.0, 0.1 ); + + fragColor = vec4( col, 1.0 ); +} + diff --git a/wip/Version 1.0/VHS.gre b/wip/Version 1.0/VHS.gre new file mode 100644 index 0000000..9b8ded1 --- /dev/null +++ b/wip/Version 1.0/VHS.gre @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/wip/Version 1.0/analogclock.frag b/wip/Version 1.0/analogclock.frag new file mode 100644 index 0000000..f3f0009 --- /dev/null +++ b/wip/Version 1.0/analogclock.frag @@ -0,0 +1,148 @@ +/* Adapted from https://www.shadertoy.com/view/DtScWV +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core +#define PI 3.14159 + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float hours; +uniform float minutes; +uniform float seconds; + +float deg2Rad(float degrees) +{ + return degrees * 0.0174533; +} + +vec2 rotate(vec2 vec, float angle) +{ + mat2 rotMat = mat2(cos(angle), -sin(angle), + sin(angle), cos(angle)); + + return vec * rotMat; +} + +float circleShape(vec2 center, vec2 uv, float radius) +{ + float dist = length(uv - center); + return 1.0 - smoothstep(radius - 0.0025, radius + 0.0025, dist); +} + +float rectShape(vec2 center, vec2 size, vec2 uv, float rotation) +{ + vec2 le = center - size / 2.0; + vec2 ue = center + size / 2.0; + + uv -= 0.5; + uv = rotate(uv, deg2Rad(rotation)); + uv.y += size.y / 2.0; + uv += 0.5; + + float smoothness = 0.0025; + + float rect = smoothstep(le.x - smoothness, le.x + smoothness, uv.x); + rect *= smoothstep(le.y - smoothness, le.y + smoothness, uv.y); + + rect *= 1.0 - smoothstep(ue.x - smoothness, ue.x + smoothness, uv.x); + rect *= 1.0 - smoothstep(ue.y - smoothness, ue.y + smoothness, uv.y); + + return rect; +} + +float angleCoords(vec2 uv, float rotation) +{ + uv -= 0.5; + uv = rotate(uv, deg2Rad(rotation)); + float angle = atan(uv.x, uv.y); + angle /= PI; + angle += 1.0; + angle /= 2.0; + return angle; +} + +float clockMarkings(vec2 uv, vec2 center, float count, float thickness, + float radius, float lngth, float smoothness) +{ + float seg = cos(angleCoords(uv, 0.0) * PI * 2.0 * count); + float ring = circleShape(vec2(0.5, 0.5), uv, radius); + ring -= circleShape(vec2(0.5, 0.5), uv, radius - lngth); + return smoothstep(1.0 - thickness, 1.0 + smoothness - thickness, seg) * ring; +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = gl_FragCoord.xy/resolution.xy; + + float scale = 0.9; + + uv -= 0.5; + uv *= 1.0 / scale; + uv.x *= resolution.x / resolution.y; + uv = rotate(uv, deg2Rad(180.0)); + uv += 0.5; + + vec2 center = vec2(0.5, 0.5); + + //Base color + float mask = circleShape(center, uv, 0.525); + vec3 col1 = mix(vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0), mask); + + //Minute markings + vec3 markColor = vec3(0.1, 0.1, 0.1); + float mark = clockMarkings(uv, center, 60.0, 0.1, 0.5, 0.02, 0.1); + vec3 col = mix(col1, markColor, mark); + + //5 minutes markings + vec3 mark1Color = vec3(0.0, 0.0, 0.0); + float mark1 = clockMarkings(uv, center, 12.0, 0.02, 0.5, 0.035, 0.01); + col = mix(col, mark1Color, mark1); + + + //Hours hand + vec3 hand1Color = vec3(0.0, 0.0, 0.0); + float hand1 = rectShape(center, vec2(0.025, 0.3), uv, hours * 360.0 / 12.0); + col = mix(col, hand1Color, hand1); + + //Circle + vec3 circleColor = vec3(0.0, 0.0, 0.0); + float circle = circleShape(center, uv, 0.03); + col = mix(col, circleColor, circle); + + //Minutes hand + vec3 hand2Color = vec3(0.2, 0.2, 0.2); + float hand2 = rectShape(center, vec2(0.02, 0.4), uv, minutes * 360.0 / 60.0); + col = mix(col, hand2Color, hand2); + + //Circle + circleColor = vec3(0.2, 0.2, 0.2); + circle = circleShape(center, uv, 0.025); + col = mix(col, circleColor, circle); + + //Seconds hand + vec3 hand3Color = vec3(1.0, 0.0, 0.0); + float hand3 = rectShape(center, vec2(0.01, 0.475), uv, seconds * 360.0 / 60.0); + col = mix(col, hand3Color, hand3); + + //Circle + circleColor = vec3(1.0, 0.0, 0.0); + circle = circleShape(center, uv, 0.02); + col = mix(col, circleColor, circle); + + //Circle + circleColor = vec3(1.0, 1.0, 1.0); + circle = circleShape(center, uv, 0.0125); + col = mix(col, circleColor, circle); + +vec3 alphacomb = col1*texture2D(texture,gl_FragCoord.xy/resolution.xy).a; + + // Output to screen + fragColor = vec4(col,alphacomb); +} diff --git a/wip/Version 1.0/analogclock.gre b/wip/Version 1.0/analogclock.gre new file mode 100644 index 0000000..3ce8aef --- /dev/null +++ b/wip/Version 1.0/analogclock.gre @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/wip/Version 1.0/butterflyWaveScrawler.frag b/wip/Version 1.0/butterflyWaveScrawler.frag new file mode 100644 index 0000000..6c49cc1 --- /dev/null +++ b/wip/Version 1.0/butterflyWaveScrawler.frag @@ -0,0 +1,47 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ButterflyWaveScrawler.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; + +uniform float progress; + +uniform float amplitude ; +uniform float waves; +uniform float colorSeparation; + +float PI = 3.14159265358979323846264; +float compute(vec2 p, float progress, vec2 center) { +vec2 o = p*sin(progress * amplitude)-center; +// horizontal vector +vec2 h = vec2(1., 0.); +// butterfly polar function (don't ask me why this one :)) +float theta = acos(dot(o, h)) * waves; +return (exp(cos(theta)) - 2.*cos(4.*theta) + pow(sin((2.*theta - PI) / 24.), 5.)) / 10.; +} +vec4 transition(vec2 uv) { + vec2 p = uv.xy / vec2(1.0).xy; + float inv = 1. - progress; + vec2 dir = p - vec2(.5); + float dist = length(dir); + float disp = compute(p, progress, vec2(0.5, 0.5)) ; + //vec4 texTo = getToColor(p + inv*disp); // for future use + vec4 texTo = vec4(0.0); + vec4 texFrom = vec4( + texture2D(texture,p + progress*disp*(1.0 - colorSeparation)).r, + texture2D(texture,p + progress*disp).g, +texture2D(texture,p + progress*disp*(1.0 + colorSeparation)).b, + 1.0); + return texTo*progress + texFrom*inv; +} +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/butterflyWaveScrawler.gre b/wip/Version 1.0/butterflyWaveScrawler.gre new file mode 100644 index 0000000..1e43ab7 --- /dev/null +++ b/wip/Version 1.0/butterflyWaveScrawler.gre @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/wip/Version 1.0/clockofclocks.frag b/wip/Version 1.0/clockofclocks.frag new file mode 100644 index 0000000..59bb40d --- /dev/null +++ b/wip/Version 1.0/clockofclocks.frag @@ -0,0 +1,364 @@ +/* Adapted from https://www.shadertoy.com/view/ws2XRd +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core + +#define PI 3.14159265359 +#define TAU 6.28318530718f + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float NumberOfAnimations; + +uniform float hours; +uniform float minutes; +uniform float seconds; + + +float date = (hours*3600.0)+(minutes*60.0)+seconds; + +const vec2 o[11] = vec2[11]( + vec2(359.9,180.), //vertical 0 + vec2(90.,270.), //horizontal 1 + vec2(359.9,90.), //bottomLeftCorner 2 + vec2(90.,180.), //topLeftCorner 3 + vec2(270.,180.), //topRightCorner 4 + vec2(359.9,270.), //bottomRightCorner 5 + vec2(135,135), //"hidden" 6 + vec2(359.9,359.9), //botStump 7 + vec2(180,180), //topStump 8 + vec2(90,90), //leftStump 9 + vec2(270,270) //rightStump 10 + ); + +const vec2 numbers[4*8*10] = vec2[4*8*10]( + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[3],o[1],o[1],o[4], + //ONE + o[6],o[6],o[2],o[5], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[2],o[4],o[0], + o[6],o[3],o[1],o[4], + //TWO + o[2],o[1],o[1],o[5], + o[0],o[2],o[1],o[4], + o[0],o[0],o[6],o[6], + o[0],o[3],o[1],o[5], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[1],o[4], + //THREE + o[2],o[1],o[1],o[5], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[1],o[4], + //FOUR + o[6],o[6],o[2],o[5], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[3],o[4],o[3],o[4], + //FIVE + o[2],o[1],o[1],o[5], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[0],o[2],o[1],o[4], + o[0],o[0],o[6],o[6], + o[0],o[3],o[1],o[5], + o[3],o[1],o[1],o[4], + //SIX + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[0],o[2],o[1],o[4], + o[0],o[0],o[6],o[6], + o[0],o[3],o[1],o[5], + o[3],o[1],o[1],o[4], + //SEVEN + o[6],o[6],o[2],o[5], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[1],o[4], + //EIGHT + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[3],o[1],o[1],o[4], + //NINE + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[3],o[4],o[0],o[0], + o[2],o[1],o[4],o[0], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[3],o[1],o[1],o[4] + ); + +//https://gist.github.com/itsmrpeck/be41d72e9d4c72d2236de687f6f53974 +float lerpRadians(float a, float b, float lerpFactor) // Lerps from angle a to b (both between 0.f and TAU), taking the shortest path +{ + float result; + float diff = b - a; + if (diff < -PI) // lerp upwards past TAU + { + b += TAU; + result = mix(a, b, lerpFactor); + if (result >= TAU) + { + result -= TAU; + } + } + else if (diff > PI) // lerp downwards past 0 + { + b -= TAU; + result = mix(a, b, lerpFactor); + if (result < 0.f) + { + result += TAU; + } + } + else // straight lerp + { + result = mix(a, b, lerpFactor); + } + + return result; +} + +float when_gt(float x, float y) { + return max(sign(x - y), 0.0); +} + +float when_lt(float x, float y) { + return max(sign(y - x), 0.0); +} + +vec2 getRotation(int x, int y, int n) { + return numbers[((4 * y) + x) + (n * 32)]; +} + +float distanceToSegment( in vec2 p, in vec2 a, in vec2 b ) +{ + //Iq's function (I use this for smooth lines) + vec2 pa = p-a; + vec2 ba = b-a; + float h = clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0); + return length( pa - ba*h ); +} + +int getNumber(int time, int digit) +{ + float d = mod(float(digit), 2.); + int t = int(mod(float(time),10.0) * (1.0 - d)); + t += (time / 10) * int(d); + + return t; +} + +vec2 displayTimeWithWave(in vec2 uv, in vec2 id,in float frac) +{ + id.x -= 10.; + id.y += 4.; + vec2 rotation = vec2(0,0); + vec2 nextRotation = vec2(0,0); + float time = date ; + float nextTime = time + 1.; + + float check = 0.; + + //digits + for(int i =0; i < 3; i++){ + for(int j = 0; j < 2; j++){ + check = when_gt(id.x, -1.0) * when_lt(id.x, 4.)* when_gt(id.y, -1.0) * when_lt(id.y,8.); + + rotation += getRotation(int(id.x), int(id.y), getNumber(int(mod(time, 60.)),j)) + * check; + + nextRotation += getRotation(int(id.x), int(id.y), getNumber(int(mod(nextTime, 60.)), j)) + * check; + + id.x += 4.; + } + id.x += 2.; + time = floor(time / 60.); + nextTime = floor(nextTime / 60.); + } + + //colons + id.x -=13.; + for(int i = 0; i < 2; i++) { + check = when_gt(id.x, 0.0) * when_lt(id.x, 3.)* when_gt(id.y, 1.0) * when_lt(id.y,6.); + rotation.x += (270. + 180. * id.x) * check; + nextRotation.x += (270. + 180. * id.x) * check; + rotation.y += (0. + 180. * id.y) * check; + nextRotation.y += (0. + 180. * id.y) * check; + id.x -=10.; + } + + //reset id for animation + id = floor(uv); + + //lerp between current time and next time(time+1) + float clockLerp = clamp(mod(date * 2.,2.),0.,1.); + float h = mix(rotation.x, nextRotation.x, clockLerp); + float m = mix(rotation.y, nextRotation.y, clockLerp); + + //animate the non clock part + float animLerp = mod(id.x * .035 + id.y * .035 + frac,2.); + h += (90. + id.x * 0. - animLerp * 360. ) * (1. - clamp(rotation.x,0.,1.)); + m += (270. + id.y * 0. + animLerp * 360. ) * (1. - clamp(rotation.y,0.,1.)); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 waveAnimation(in vec2 uv, in vec2 id, in float frac) +{ + float animLerp = mod(id.x * .035 + id.y * .035 + (frac - 1.0),2.); + float h = (90. + id.x * 0. - animLerp * 360. ); + float m = (-90. + id.y * 0. + animLerp * 360. ); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 boxAnimation(in vec2 uv, in vec2 id, in float frac) +{ + vec2 rotation = vec2(0,0); + + float h = (90. + id.x * 180. + frac * 360. ); + float m = (0. - id.y * 180. + frac * 360. ); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 boxAnimation2(in vec2 uv, in vec2 id, in float frac) +{ + vec2 rotation = vec2(0,0); + + float h = (90. + id.x * 180. + frac * 360. ); + float m = (0. - id.y * 180. - frac * 360. ); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 diamondAnimation(in vec2 uv, in vec2 id, in float frac) +{ + vec2 rotation = vec2(0,0); + + float h = 45. + clamp((frac*34.) - (abs(id.x)) - (abs(id.y)),0.,34.) * 11.25; + float m = -135. + clamp((frac*34.) - (abs(id.x)) - (abs(id.y)),0.,34.) * 11.25; + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +// Animation transition code +// Lifted from Klems, https://www.shadertoy.com/view/ll2SWW +vec2 getAnimation(int fx, vec2 uv, vec2 id, float frac) +{ + vec2 value = vec2(0,0); + fx = int(mod(float(fx), NumberOfAnimations)); + if(fx == 0) value = displayTimeWithWave(uv,id,frac); + else if(fx == 1) value = boxAnimation(uv,id,frac); + else if(fx == 2) value = boxAnimation2(uv,id,frac); + else if(fx == 3) value = diamondAnimation(uv,id,frac); + else value = waveAnimation(uv,id,frac); + + return value; +} + +vec2 getFinalRotation(in vec2 uv, in vec2 id) +{ + float animationTime = 5.; + float segue = .8; + int fx = int(date / animationTime); + float frac = mod(date, animationTime)/ animationTime; + + vec2 valueA = getAnimation(fx, uv, id, frac - segue); + vec2 valueB = getAnimation(fx - 1, uv, id, (1. - segue) + frac); + + return vec2(lerpRadians(valueB.x,valueA.x,smoothstep(segue,1.0,frac)), + lerpRadians(valueB.y,valueA.y,smoothstep(segue,1.0,frac))); +} + +void main(void) +{ + vec2 uv = (gl_FragCoord.xy -.5 * resolution.xy)/resolution.y; + uv*= 22.; + + float p = 20./min(resolution.x, resolution.y); + + //draw circles + vec2 gv = fract(uv) - 0.5; + float d = length(gv); + float outerCircle = smoothstep(0.485 + p, 0.485 - p, d); + float innerCircle = smoothstep(0.445 - p, 0.445 + p, d); + vec3 col = vec3(1,1,1); + + //Get rotation + vec2 id = floor(uv); + vec2 radian = getFinalRotation(uv,id); + + //draw clock hands + col -= smoothstep(1.0-p, 1.0+p,1. - ((distanceToSegment(gv, vec2(0.),vec2(sin(radian.x),cos(radian.x))*.4) - .04))); + col -= smoothstep(1.0-p, 1.0+p,1. - ((distanceToSegment(gv, vec2(0.),vec2(sin(radian.y),cos(radian.y))*.3) - .04))); + + col -= ((innerCircle * outerCircle) * .3); + //debug + //col = vec3(radian.x/(PI*2.),0,0); + + //white border and darken + col += 2. * (1. - (when_gt(id.x, -18.0) * when_lt(id.x, 17.)* when_gt(id.y, -8.0) * when_lt(id.y,7.))); + col = clamp(col,0.,1.); + col -= .1; + + fragColor = vec4(col,texture2D(texture,texCoord).a); +} diff --git a/wip/Version 1.0/clockofclocks.gre b/wip/Version 1.0/clockofclocks.gre new file mode 100644 index 0000000..c365c44 --- /dev/null +++ b/wip/Version 1.0/clockofclocks.gre @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/wip/Version 1.0/colorfullsignal.frag b/wip/Version 1.0/colorfullsignal.frag new file mode 100644 index 0000000..cb8a8e3 --- /dev/null +++ b/wip/Version 1.0/colorfullsignal.frag @@ -0,0 +1,42 @@ +/* Adapted from https://godotshaders.com/shader/colorful-signal-effect/ +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +#define PI 3.14159265359 +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; +uniform vec2 resolution; + +uniform vec4 color_signal; +uniform float time; +uniform float size; +uniform float zoom; +uniform float speed; +uniform int RainBow; + +void main(void){ + + vec2 UV= texCoord*2.0-1.0; + UV.x*= resolution.x/resolution.y; + float d = length(UV); + float t = pow(smoothstep(0.9,0.2,d),0.35); + + // For rainbow effect, keep this line : + vec3 rainbow = 0.5 + 0.5*cos(time+UV.xyx+vec3(0,2,4)); + vec4 color= vec4(rainbow.rgb,1.0); + + if (!bool(RainBow)) + { + color = vec4(color_signal.rgb,texture2D(texture,texCoord).a); + } + + d = sin(zoom*d - speed*time); + d = abs(d); + d = size/d; + color *= d*t; + fragColor = vec4(color.rgb,texture2D(texture,texCoord).a); + +} + diff --git a/wip/Version 1.0/colorfullsignal.gre b/wip/Version 1.0/colorfullsignal.gre new file mode 100644 index 0000000..a3ea870 --- /dev/null +++ b/wip/Version 1.0/colorfullsignal.gre @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/wip/Version 1.0/digitalclock.frag b/wip/Version 1.0/digitalclock.frag new file mode 100644 index 0000000..d6368ef --- /dev/null +++ b/wip/Version 1.0/digitalclock.frag @@ -0,0 +1,190 @@ +/* Credit : https://www.shadertoy.com/view/MdfGzf + Rebuilt for enve by axiomgraph*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + + +uniform int Hours;// = 15 //min 0 max 24 +uniform int Minutes;// =0; // min 0 max 60 +uniform int Seconds;// =0; // min 0 max 60 + +uniform int AMPM;// =1;// default 24 Hours +uniform int redgreen;//=0; // default color red +uniform int microwavestyle;//=1; // default 0 +uniform int showOffLed;//=0;// default 0 + +bool showMatrix = false; +bool showOff = false; +float iTime=0.0; + +float segment(vec2 uv, bool On) +{ + if (!On && !bool(showOffLed)) + return 0.0; + + float seg = (1.0-smoothstep(0.08,0.09+float(On)*0.02,abs(uv.x)))* + (1.0-smoothstep(0.46,0.47+float(On)*0.02,abs(uv.y)+abs(uv.x))); + + //Fiddle with lights and matrix + //uv.x += sin(iTime*60.0*6.26)/14.0; + //uv.y += cos(iTime*60.0*6.26)/14.0; + + //led like brightness + if (On) + seg *= (1.0-length(uv*vec2(3.8,0.9)));//-sin(iTime*25.0*6.26)*0.04; + else + seg *= -(0.05+length(uv*vec2(0.2,0.1))); + + return seg; +} + +float sevenSegment(vec2 uv,int num) +{ + float seg= 0.0; + seg += segment(uv.yx+vec2(-1.0, 0.0),num!=-1 && num!=1 && num!=4 ); + seg += segment(uv.xy+vec2(-0.5,-0.5),num!=-1 && num!=1 && num!=2 && num!=3 && num!=7); + seg += segment(uv.xy+vec2( 0.5,-0.5),num!=-1 && num!=5 && num!=6 ); + seg += segment(uv.yx+vec2( 0.0, 0.0),num!=-1 && num!=0 && num!=1 && num!=7 ); + seg += segment(uv.xy+vec2(-0.5, 0.5),num==0 || num==2 || num==6 || num==8 ); + seg += segment(uv.xy+vec2( 0.5, 0.5),num!=-1 && num!=2 ); + seg += segment(uv.yx+vec2( 1.0, 0.0),num!=-1 && num!=1 && num!=4 && num!=7 ); + + return seg; +} + +float showNum(vec2 uv,int nr, bool zeroTrim) +{ + //Speed optimization, leave if pixel is not in segment + if (abs(uv.x)>1.5 || abs(uv.y)>1.2) + return 0.0; + + float seg= 0.0; + if (uv.x>0.0) + { + nr /= 10; + if (nr==0 && zeroTrim) + nr = -1; + seg += sevenSegment(uv+vec2(-0.75,0.0),nr); + } + else + seg += sevenSegment(uv+vec2( 0.75,0.0),int(mod(float(nr),10.0))); + + return seg; +} + +float dots(vec2 uv) +{ + float seg = 0.0; + uv.y -= 0.5; + seg += (1.0-smoothstep(0.11,0.13,length(uv))) * (1.0-length(uv)*2.0); + uv.y += 1.0; + seg += (1.0-smoothstep(0.11,0.13,length(uv))) * (1.0-length(uv)*2.0); + return seg; +} + + +void main(void) +{ + + + + vec2 uv = (gl_FragCoord.xy-0.5*resolution.xy) / + min(resolution.x,resolution.y); + + float timeOffset = 0.0; + if (resolution.x>resolution.y) + { + uv *= 6.0; + } + else + { + //uv *= 12.0; + // Many clocks with different time + zoom in on the right one + uv *= 70.0+sin(iTime*0.0628)*58.0; + + uv += vec2(5.5,2.5); + vec2 offset = vec2(floor(uv.x/11.0), + floor(uv.y/5.0 )); + if (length(offset)>0.0) + timeOffset = (offset.y*163.13+offset.x*13.23)+mod(iTime,1.0); + else + timeOffset = 0.0; + + uv.x = mod(uv.x,11.0)-5.5; + uv.y = mod(uv.y, 5.0)-2.5; + } + + uv.x *= -1.0; + uv.x += uv.y/12.0; + //wobble + //uv.x += sin(uv.y*3.0+iTime*14.0)/25.0; // wobble clock + //uv.y += cos(uv.x*3.0+iTime*14.0)/25.0; + uv.x += 3.5; + float seg = 0.0; + + + float secon = float(Seconds); //time + float minut = float(Minutes*60); + float hour = float(Hours*3600); + + float timeSecs = hour+minut+secon+timeOffset; + + seg += showNum(uv,int(mod(timeSecs,60.0)),false); + + timeSecs = floor(timeSecs/60.0); + + uv.x -= 1.75; + + seg += dots(uv); + + uv.x -= 1.75; + + seg += showNum(uv,int(mod(timeSecs,60.0)),false); + + timeSecs = floor(timeSecs/60.0); + if (bool(AMPM)) + { + if (timeSecs>12.0) + timeSecs = mod(timeSecs,12.0); + } + + uv.x -= 1.75; + + seg += dots(uv); + + uv.x -= 1.75; + seg += showNum(uv,int(mod(timeSecs,60.0)),true); + + // matrix over segment + if (bool(microwavestyle)) + { + seg *= 0.8+0.2*smoothstep(0.02,0.04,mod(uv.y+uv.x,0.06025)); + //seg *= 0.8+0.2*smoothstep(0.02,0.04,mod(uv.y-uv.x,0.06025)); + } + + if (seg<0.0) + { + seg = -seg;; + fragColor = vec4(seg,seg,seg,texture2D(texture,texCoord).a*seg); + } + else + if (bool(microwavestyle)) + if (bool(redgreen)) + fragColor = vec4(0.0,seg,seg*0.5,texture2D(texture,texCoord).a*seg); + else + fragColor = vec4(0.0,seg*0.8,seg,texture2D(texture,texCoord).a*seg); + else + if (bool(redgreen)) + fragColor = vec4(0.0,seg,0.0,texture2D(texture,texCoord).a*seg); + else + fragColor = vec4(seg,0.0,0.0,texture2D(texture,texCoord).a*seg); + +} + + diff --git a/wip/Version 1.0/digitalclock.gre b/wip/Version 1.0/digitalclock.gre new file mode 100644 index 0000000..eaf18f6 --- /dev/null +++ b/wip/Version 1.0/digitalclock.gre @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/wip/Version 1.0/dotconnect.frag b/wip/Version 1.0/dotconnect.frag new file mode 100644 index 0000000..57cf4a3 --- /dev/null +++ b/wip/Version 1.0/dotconnect.frag @@ -0,0 +1,110 @@ +/* Credit : + Rebuilt for enve by axiomgraph*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float time; +uniform vec4 color; + +float N21(vec2 p) { + p = fract(p * vec2(2.15, 8.3)); + p += dot(p, p + 2.5); + return fract(p.x * p.y); +} + +vec2 N22(vec2 p) { + float n = N21(p); + return vec2(n, N21(p + n)); +} + +vec2 getPos(vec2 id, vec2 offset) { + vec2 n = N22(id + offset); + float x = cos(time * n.x); + float y = sin(time * n.y); + return vec2(x, y) * 0.4 + offset; +} + +float distanceToLine(vec2 p, vec2 a, vec2 b) { + vec2 pa = p - a; + vec2 ba = b - a; + float t = clamp(dot(pa, ba) / dot(ba, ba), 0., 1.); + return length(pa - t * ba); +} + +float getLine(vec2 p, vec2 a, vec2 b) { + float distance = distanceToLine(p, a, b); + float dx = 15./resolution.y; + return smoothstep(dx, 0., distance) * smoothstep(1.2, 0.3, length(a - b)); +} + +float layer(vec2 st) { + float m = 0.; + vec2 gv = fract(st) - 0.5; + vec2 id = floor(st); + // m = gv.x > 0.48 || gv.y > 0.48 ? 1. : 0.; + vec2 pointPos = getPos(id, vec2(0., 0.)); + m += smoothstep(0.05, 0.03, length(gv - pointPos)); + + float dx=15./resolution.y; + // m += smoothstep(-dx,0., abs(gv.x)-.5); + // m += smoothstep(-dx,0., abs(gv.y)-.5); + // m += smoothstep(dx, 0., length(gv - pointPos)-0.03); + + vec2 p[9]; + p[0] = getPos(id, vec2(-1., -1.)); + p[1] = getPos(id, vec2(-1., 0.)); + p[2] = getPos(id, vec2(-1., 1.)); + p[3] = getPos(id, vec2( 0., -1.)); + p[4] = getPos(id, vec2( 0., 0.)); + p[5] = getPos(id, vec2( 0., 1.)); + p[6] = getPos(id, vec2( 1., -1.)); + p[7] = getPos(id, vec2( 1., 0.)); + p[8] = getPos(id, vec2( 1., 1.)); + + for (int j = 0; j <=8 ; j++) { + m += getLine(gv, p[4], p[j]); + vec2 temp = (gv - p[j]) * 100.; + m += 1./dot(temp, temp) * (sin(10. * time + fract(p[j].x) * 20.) * 0.5 + 0.5); + + } + + m += getLine(gv, p[1], p[3]); + m += getLine(gv, p[1], p[5]); + m += getLine(gv, p[3], p[7]); + m += getLine(gv, p[5], p[7]); + + // m += smoothstep(0.05, 0.04, length(st - vec2(0., 0.))); + return m; +} + +void main(void) +{ + vec2 uv = (gl_FragCoord.xy - 0.5 * resolution.xy) / resolution.y; + + float m = 0.; + + float theta = time * 0.1; + mat2 rot = mat2(cos(theta), -sin(theta), sin(theta), cos(theta)); + vec2 gradient = uv; + uv = rot * uv; + + for (float i = 0.; i < 1.0 ; i += 0.25) { + float depth = fract(i + time * 0.1); + m += layer(uv * mix(10., 0.5, depth) + i * 20.) * smoothstep(0., 0.2, depth) * smoothstep(1., 0.8, depth); + } + + vec3 baseColor = color.rgb; + + vec3 col = (m - gradient.y) * baseColor; //disable gradient in future + // Output to screen + fragColor = vec4(col, texture2D(texture,texCoord).a); +} + + + diff --git a/wip/Version 1.0/dotconnect.gre b/wip/Version 1.0/dotconnect.gre new file mode 100644 index 0000000..ba6e26e --- /dev/null +++ b/wip/Version 1.0/dotconnect.gre @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/wip/Version 1.0/electroniclock.frag b/wip/Version 1.0/electroniclock.frag new file mode 100644 index 0000000..a06c096 --- /dev/null +++ b/wip/Version 1.0/electroniclock.frag @@ -0,0 +1,180 @@ +/* Adapted from https://www.shadertoy.com/view/ldVBDD +Rebuilt for enve/friction by axiomgraph + Opengl version 3.3*/ +#version 330 core +#define PI 3.14159 + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float hours; +uniform float minutes; +uniform float seconds; +uniform vec4 color; + +float d_seg(vec2 position, vec2 start_p, vec2 end_p, float R) +{ + vec2 AP = position - start_p; + vec2 AB = end_p - start_p; + float h = clamp(dot(AP, AB) / dot(AB, AB), 0.0, 1.0); + float seg = abs(length(AP - AB * h) - R); + return max(1.0 / seg - 1.0, 0.0); +} + +mat2 rot(float a) +{ + vec2 r = vec2(cos(a), sin(a)); + return mat2(r.x, r.y, -r.y, r.x); +} + +float get_ch_0(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + line += d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + return line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); +} + +float get_ch_1(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(2.0, 0.0), vec2(2.0, 2.0), R); + return line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 4.0), R); +} + +float get_ch_2(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_3(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_4(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_5(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_6(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_7(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + return line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); +} + +float get_ch_8(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_9(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float draw_num(vec2 pos, float R, int ch) +{ + float line = 0.0; + ch -= int(10.0 * floor(0.1 * float(ch))); + if (ch < 8) + if (ch < 4) + if (ch < 2) + if (ch < 1) line = get_ch_0(pos, R); + else line = get_ch_1(pos, R); + else + if (ch < 3) line = get_ch_2(pos, R); + else line = get_ch_3(pos, R); + else + if (ch < 6) + if (ch < 5) line = get_ch_4(pos, R); + else line = get_ch_5(pos, R); + else + if (ch < 7) line = get_ch_6(pos, R); + else line = get_ch_7(pos, R); + else + if (ch < 9) line = get_ch_8(pos, R); + else line = get_ch_9(pos, R); + return line; +} + +void main(void) +{ + //font size: + const float k = 0.1; + //font weight: + const float R = 0.03; + //shaking center: + const vec2 O = vec2(1.0, 2.0); + vec2 pos = (2.0 * gl_FragCoord.xy - resolution.xy ) / resolution.y; + float num[6], point[4], T[6], t[6], light = 0.0; + T[0] = 1.0; T[1] = 10.0; T[2] = 60.0; T[3] = 600.0; T[4] = 3600.0; T[5] = 36000.0; + t[0] = 10.0; t[1] = 6.0; t[2] = 10.0; t[3] = 6.0; t[4] = 24.0; t[5] = 2.4; + vec2 P[6]; + vec3 col = color.rgb * 0.1; // color + + float date = hours*3600.0+minutes*60.0+seconds; // time + + for(int i = 0; i < 6; i++) + { + P[i] = (pos - vec2(1.0 - 5.0*k * float(i), 0.0) - k*O) * rot(0.1 * sin(0.05 / (pow(0.5, float(i)) * T[i] * fract(date / T[i])) )) + k*O; + num[i] = draw_num(P[i] / k, R / k, int(mod(date / T[i], t[i]))); + light += num[i]; + } + for(int i = 0; i < 2; i++) + { + point[2*i] = max(1.0 / abs(length(pos - vec2(1.0 - (6.25 + 10.0 * float(i)) * k, 1.0 * k)) - R) - 1.0 / k, 0.0); + point[2*i+1] = max(1.0 / abs(length(pos - vec2(1.0 - (6.25 + 10.0 * float(i)) * k, 3.0 * k)) - R) - 1.0 / k, 0.0); + light += k * (point[2*i] + point[2*i+1]) * mod(floor(date), 2.0); + } + col *= light; + fragColor = vec4(col,col*texture2D(texture,texCoord).a); +} diff --git a/wip/Version 1.0/electroniclock.gre b/wip/Version 1.0/electroniclock.gre new file mode 100644 index 0000000..423df54 --- /dev/null +++ b/wip/Version 1.0/electroniclock.gre @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/wip/Version 1.0/hexmarching.frag b/wip/Version 1.0/hexmarching.frag new file mode 100644 index 0000000..bdb9920 --- /dev/null +++ b/wip/Version 1.0/hexmarching.frag @@ -0,0 +1,280 @@ +/* Credit : https://www.shadertoy.com/view/NdKyDw Hex Marching + Rebuilt for enve by axiomgraph*/ +#version 330 core + +#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a)) +#define PI 3.141592654 +#define TAU (2.0*PI) + + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; + +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float time; +uniform float BPM; +uniform float scale; + +const float planeDist = 1.0-0.2; + +// License: WTFPL, author: sam hocevar, found: https://stackoverflow.com/a/17897228/418488 +const vec4 hsv2rgb_K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); +vec3 hsv2rgb(vec3 c) { + vec3 p = abs(fract(c.xxx + hsv2rgb_K.xyz) * 6.0 - hsv2rgb_K.www); + return c.z * mix(hsv2rgb_K.xxx, clamp(p - hsv2rgb_K.xxx, 0.0, 1.0), c.y); +} +// License: WTFPL, author: sam hocevar, found: https://stackoverflow.com/a/17897228/418488 +// Macro version of above to enable compile-time constants +#define HSV2RGB(c) (c.z * mix(hsv2rgb_K.xxx, clamp(abs(fract(c.xxx + hsv2rgb_K.xyz) * 6.0 - hsv2rgb_K.www) - hsv2rgb_K.xxx, 0.0, 1.0), c.y)) + + +// License: Unknown, author: Unknown, found: don't remember +vec4 alphaBlend(vec4 back, vec4 front) { + float w = front.w + back.w*(1.0-front.w); + vec3 xyz = (front.xyz*front.w + back.xyz*back.w*(1.0-front.w))/w; + return w > 0.0 ? vec4(xyz, w) : vec4(0.0); +} + +// License: Unknown, author: Unknown, found: don't remember +vec3 alphaBlend(vec3 back, vec4 front) { + return mix(back, front.xyz, front.w); +} + +// License: Unknown, author: Unknown, found: don't remember +float tanh_approx(float x) { + // Found this somewhere on the interwebs + // return tanh(x); + float x2 = x*x; + return clamp(x*(27.0 + x2)/(27.0+9.0*x2), -1.0, 1.0); +} + +// License: Unknown, author: Unknown, found: don't remember +float hash(float co) { + return fract(sin(co*12.9898) * 13758.5453); +} + +vec3 offset(float z) { + float a = z; + vec2 p = -0.15*(vec2(cos(a), sin(a*sqrt(2.0))) + vec2(cos(a*sqrt(0.75)), sin(a*sqrt(0.5)))); + return vec3(p, z); +} + +vec3 doffset(float z) { + float eps = 0.05; + return 0.5*(offset(z + eps) - offset(z - eps))/(2.0*eps); +} + +vec3 ddoffset(float z) { + float eps = 0.05; + return 0.5*(doffset(z + eps) - doffset(z - eps))/(2.0*eps); +} + +// License: CC0, author: Mårten Rånge, found: https://github.com/mrange/glsl-snippets +vec2 toPolar(vec2 p) { + return vec2(length(p), atan(p.y, p.x)); +} + +// License: CC0, author: Mårten Rånge, found: https://github.com/mrange/glsl-snippets +vec2 toRect(vec2 p) { + return vec2(p.x*cos(p.y), p.x*sin(p.y)); +} + +// License: MIT OR CC-BY-NC-4.0, author: mercury, found: https://mercury.sexy/hg_sdf/ +float mod1(inout float p, float size) { + float halfsize = size*0.5; + float c = floor((p + halfsize)/size); + p = mod(p + halfsize, size) - halfsize; + return c; +} + +vec2 hextile(inout vec2 p) { + // See Art of Code: Hexagonal Tiling Explained! + // https://www.youtube.com/watch?v=VmrIDyYiJBA + const vec2 sz = vec2(1.0, sqrt(3.0)); + const vec2 hsz = 0.5*sz; + + vec2 p1 = mod(p, sz)-hsz; + vec2 p2 = mod(p - hsz, sz)-hsz; + vec2 p3 = dot(p1, p1) < dot(p2, p2) ? p1 : p2; + vec2 n = ((p3 - p + hsz)/sz); + p = p3; + + n -= vec2(0.5); + // Rounding to make hextile 0,0 well behaved + return round(n*2.0)*0.5; +} + +vec4 effect(vec2 p, float aa, float h) { + vec2 hhn = hextile(p); + const float w = 0.02; + vec2 pp = toPolar(p); + float a = pp.y; + float hn = mod1(pp.y, TAU/6.0); + vec2 hp = toRect(pp); + float hd = hp.x-(w*10.0); + + float x = hp.x-0.5*w; + float n = mod1(x, w); + float d = abs(x)-(0.5*w-aa); + + float h0 = hash(10.0*(hhn.x+hhn.y)+2.0*h+n); + float h1 = fract(8667.0*h0); + float cut = mix(-0.5, 0.999, 0.5+0.5*sin(time+TAU*h0)); + const float coln = 6.0; + float t = smoothstep(aa, -aa, d)*smoothstep(cut, cut-0.005, sin(a+2.0*(h1-0.5)*time+h1*TAU))*exp(-150.0*abs(x)); + vec3 col = hsv2rgb(vec3(floor(h0*coln)/coln, 0.8, 1.0))*t*1.75; + + t = mix(0.9, 1.0, t); + t *= smoothstep(aa, -aa, -hd); + if (hd < 0.0) { + col = vec3(0.0); + t = 15.*dot(p, p); + } + return vec4(col, t); +} + +vec4 plane(vec3 ro, vec3 rd, vec3 pp, vec3 npp, vec3 off, float n) { + float h0 = hash(n); + float h1 = fract(8667.0*h0); + + vec3 hn; + vec2 p = (pp-off*vec3(1.0, 1.0, 0.0)).xy; + p *= ROT(TAU*h0); + p.x -= 0.25*h1*(pp.z-ro.z); + const float z = 1.0; + p /= z; + float aa = distance(pp,npp)*sqrt(1.0/3.0)/z; + vec4 col = effect(p, aa, h1); + + return col; +} + +vec3 skyColor(vec3 ro, vec3 rd) { + return vec3(0.0); +} + +vec3 color(vec3 ww, vec3 uu, vec3 vv, vec3 ro, vec2 p) { + float lp = length(p); + vec2 np = p + 2.0/resolution.y; + float rdd = (scale-0.5*tanh_approx(lp)); // Playing around with rdd can give interesting distortions +// float rdd = 2.; + + vec3 rd = normalize(p.x*uu + p.y*vv + rdd*ww); + vec3 nrd = normalize(np.x*uu + np.y*vv + rdd*ww); + + const int furthest = 5; + const int fadeFrom = max(furthest-2, 0); + + const float fadeDist = planeDist*float(furthest - fadeFrom); + float nz = floor(ro.z / planeDist); + + vec3 skyCol = skyColor(ro, rd); + + + vec4 acol = vec4(0.0); + const float cutOff = 0.95; + bool cutOut = false; + + float maxpd = 0.0; + + // Steps from nearest to furthest plane and accumulates the color + for (int i = 1; i <= furthest; ++i) { + float pz = planeDist*nz + planeDist*float(i); + + float pd = (pz - ro.z)/rd.z; + + if (pd > 0.0 && acol.w < cutOff) { + vec3 pp = ro + rd*pd; + maxpd = pd; + vec3 npp = ro + nrd*pd; + + vec3 off = offset(pp.z); + + vec4 pcol = plane(ro, rd, pp, npp, off, nz+float(i)); + + float nz = pp.z-ro.z; + float fadeIn = smoothstep(planeDist*float(furthest), planeDist*float(fadeFrom), nz); + float fadeOut = smoothstep(0.0, planeDist*0.1, nz); +// pcol.xyz = mix(skyCol, pcol.xyz, fadeIn); + pcol.w *= fadeOut*fadeIn; + pcol = clamp(pcol, 0.0, 1.0); + + acol = alphaBlend(pcol, acol); + } else { + cutOut = true; + acol.w = acol.w > cutOff ? 1.0 : acol.w; + break; + } + + } + + vec3 col = alphaBlend(skyCol, acol); +// To debug cutouts due to transparency +// col += cutOut ? vec3(1.0, -1.0, 0.0) : vec3(0.0); + return col; +} + +vec3 effect(vec2 p, vec2 q) { + float tm = planeDist*time*BPM/60.0; + vec3 ro = offset(tm); + vec3 dro = doffset(tm); + vec3 ddro = ddoffset(tm); + + vec3 ww = normalize(dro); + vec3 uu = normalize(cross(normalize(vec3(0.0,1.0,0.0)+ddro), ww)); + vec3 vv = cross(ww, uu); + + vec3 col = color(ww, uu, vv, ro, p); + + return col; +} + + +const mat2 brot = ROT(2.399); +// simplyfied version of Dave Hoskins blur +vec3 dblur(vec2 q,float rad) { + vec3 acc=vec3(0); + const float m = 0.002; + vec2 pixel=vec2(m*resolution.y/resolution.x,m); + vec2 angle=vec2(0,rad); + rad=1.; + const int iter = 30; + for (int j=0; j + + + + + + + + + + diff --git a/wip/Version 1.0/octagrams.frag b/wip/Version 1.0/octagrams.frag new file mode 100644 index 0000000..43689ef --- /dev/null +++ b/wip/Version 1.0/octagrams.frag @@ -0,0 +1,104 @@ +/* Adapted from https://www.shadertoy.com/view/tlVGDt +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +#define PI 3.14159265359 +precision highp float; +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; +uniform vec2 resolution; + +uniform float time; + +float gTime = 0.; +const float REPEAT = 5.0; + +mat2 rot(float a) { + float c = cos(a), s = sin(a); + return mat2(c,s,-s,c); +} + +float sdBox( vec3 p, vec3 b ) +{ + vec3 q = abs(p) - b; + return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); +} + +float box(vec3 pos, float scale) { + pos *= scale; + float base = sdBox(pos, vec3(.4,.4,.1)) /1.5; + pos.xy *= 5.; + pos.y -= 3.5; + pos.xy *= rot(.75); + float result = -base; + return result; +} + +float box_set(vec3 pos, float time) { + vec3 pos_origin = pos; + pos = pos_origin; + pos .y += sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box1 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos .y -=sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box2 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos .x +=sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box3 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos .x -=sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box4 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos.xy *= rot(.8); + float box5 = box(pos,.5) * 6.; + pos = pos_origin; + float box6 = box(pos,.5) * 6.; + float result = max(max(max(max(max(box1,box2),box3),box4),box5),box6); + return result; +} + +float map(vec3 pos, float time) { + vec3 pos_origin = pos; + float box_set1 = box_set(pos, time); + + return box_set1; +} + + +void main(void) { + vec2 p = (gl_FragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y); + vec3 ro = vec3(0., -0.2 ,time * 4.); + vec3 ray = normalize(vec3(p, 1.5)); + ray.xy = ray.xy * rot(sin(time * .03) * 5.); + ray.yz = ray.yz * rot(sin(time * .05) * .2); + float t = 0.1; + vec3 col = vec3(0.); + float ac = 0.0; + + + for (int i = 0; i < 99; i++){ + vec3 pos = ro + ray * t; + pos = mod(pos-2., 4.) -2.; + gTime = time -float(i) * 0.01; + + float d = map(pos, time); + + d = max(abs(d), 0.01); + ac += exp(-d*23.); + + t += d* 0.55; + } + + col = vec3(ac * 0.02); + + col +=vec3(0.,0.2 * abs(sin(time)),0.5 + sin(time) * 0.2); + + + fragColor = vec4(col ,texture2D(texture,texCoord).a - t * (0.02 + 0.02 * sin (time))); +} diff --git a/wip/Version 1.0/octagrams.gre b/wip/Version 1.0/octagrams.gre new file mode 100644 index 0000000..ffea9ac --- /dev/null +++ b/wip/Version 1.0/octagrams.gre @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/wip/Version 1.0/perlintransition.frag b/wip/Version 1.0/perlintransition.frag new file mode 100644 index 0000000..565acd0 --- /dev/null +++ b/wip/Version 1.0/perlintransition.frag @@ -0,0 +1,84 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/perlin.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +#ifdef GL_ES +precision highp float; +#endif + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float progress; + +uniform float scale; +uniform float smoothness ; +uniform float seed ; + + // http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/ +float random(vec2 co) +{ + float a = seed; + float b = 78.233; + float c = 43758.5453; + float dt= dot(co.xy ,vec2(a,b)); + float sn= mod(dt,3.14); + return fract(sin(sn) * c); +} + +// 2D Noise based on Morgan McGuire @morgan3d +// https://www.shadertoy.com/view/4dS3Wd +float noise (in vec2 st) { + vec2 i = floor(st); + vec2 f = fract(st); + + // Four corners in 2D of a tile + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + + // Smooth Interpolation + + // Cubic Hermine Curve. Same as SmoothStep() + vec2 u = f*f*(3.0-2.0*f); + // u = smoothstep(0.,1.,f); + + // Mix 4 coorners porcentages + return mix(a, b, u.x) + + (c - a)* u.y * (1.0 - u.x) + + (d - b) * u.x * u.y; +} + +vec4 transition (vec2 uv) { + float ar = resolution.x/resolution.y; // aspect ratio + vec4 from = texture2D(texture,uv); + vec4 to = vec4(0.0); // for future use + uv.x*= ar ; // aspect ratio + float n = noise(uv * scale); + + float p = mix(-smoothness, 1.0 + smoothness, progress); + float lower = p - smoothness; + float higher = p + smoothness; + + float q = smoothstep(lower, higher, n); + + return mix( + from, + to, + 1.0 - q + ); +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + // vec2 uv = gl_FragCoord.xy/resolution.xy; + // Output to screen + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/perlintransition.gre b/wip/Version 1.0/perlintransition.gre new file mode 100644 index 0000000..fa87744 --- /dev/null +++ b/wip/Version 1.0/perlintransition.gre @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/wip/Version 1.0/radialwipe.frag b/wip/Version 1.0/radialwipe.frag new file mode 100644 index 0000000..ed3f3fb --- /dev/null +++ b/wip/Version 1.0/radialwipe.frag @@ -0,0 +1,34 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Radial.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; + +uniform vec2 resolution; + +uniform float progress; +uniform float feather; + +const float PI = 3.141592653589; + +vec4 transition(vec2 p, vec2 uv) { + float ar = resolution.x/resolution.y; + p.x*=ar; + vec2 rp = p ; + p.x/=ar; + return mix( + vec4(0.0), + texture2D(texture,uv), + smoothstep(0., feather, atan(rp.y ,rp.x) - (progress-.5) * PI * 2.5) + ); +} +void main(void) +{ +vec2 uv = texCoord; + fragColor = transition(texCoord *2.0-1.0, uv); +} + diff --git a/wip/Version 1.0/radialwipe.gre b/wip/Version 1.0/radialwipe.gre new file mode 100644 index 0000000..30a4b8f --- /dev/null +++ b/wip/Version 1.0/radialwipe.gre @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/wip/Version 1.0/simplergbwaveform.frag b/wip/Version 1.0/simplergbwaveform.frag new file mode 100644 index 0000000..2c62ec7 --- /dev/null +++ b/wip/Version 1.0/simplergbwaveform.frag @@ -0,0 +1,43 @@ +/* Adapted from https://www.shadertoy.com/view/4dK3Wc +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +//#define HIGH_QUALITY + +#ifndef HIGH_QUALITY +const int hres = 200; +const float intensity = 0.04; +const float thres = 0.004; +#else +const int hres = 800; +const float intensity = 0.03; +const float thres = 0.001; +#endif + +void main( void ) +{ + vec2 uv = gl_FragCoord.xy / resolution.xy; + vec3 col = vec3(0); + float s = uv.y*1.8 - 0.15; + float maxb = s+thres; + float minb = s-thres; + + for (int i = 0; i <= hres; i++) { + vec3 x = texture2D(texture, vec2(float(i)/float(hres), uv.x)).rgb; + col += vec3(intensity)*step(x, vec3(maxb))*step(vec3(minb), x); + + float l = dot(x, x); + col += vec3(intensity)*step(l, maxb*maxb)*step(minb*minb, l); + } + + fragColor = vec4(col,texture2D(texture,texCoord)); +} diff --git a/wip/Version 1.0/simplergbwaveform.gre b/wip/Version 1.0/simplergbwaveform.gre new file mode 100644 index 0000000..6abd15b --- /dev/null +++ b/wip/Version 1.0/simplergbwaveform.gre @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/wip/Version 1.0/synthwave.frag b/wip/Version 1.0/synthwave.frag new file mode 100644 index 0000000..942e574 --- /dev/null +++ b/wip/Version 1.0/synthwave.frag @@ -0,0 +1,259 @@ +/* credit : https://www.shadertoy.com/view/tsScRK + Rebuilt for enve by axiomgraph +*/ +#version 330 core + +//#define VAPORWAVE +//#define AA 2 +//#define stereo +//#define wave_thing +//#define city for future use +#define PI 3.14159265359 + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + + +uniform float speed; +uniform float iTime; +uniform float iTimeDelta; + + + +float jTime; + + + +// vec4 textureMirror(sampler2D tex, vec2 c){ +// vec2 cf = fract(c); +// return texture(tex,mix(cf,1.-cf,mod(floor(c),2.))); +//} + + + +float amp(vec2 p){ + return smoothstep(1.,8.,abs(p.x)); +} + +float pow512(float a){ + a*=a;//^2 + a*=a;//^4 + a*=a;//^8 + a*=a;//^16 + a*=a;//^32 + a*=a;//^64 + a*=a;//^128 + a*=a;//^256 + return a*a; +} +float pow1d5(float a){ + return a*sqrt(a); +} +float hash21(vec2 co){ + return fract(sin(dot(co.xy,vec2(1.9898,7.233)))*45758.5433); +} +float hash(vec2 uv){ + float a = amp(uv); + #ifdef wave_thing + float w = a>0.?(1.-.4*pow512(.51+.49*sin((.02*(uv.y+.5*uv.x)-jTime)*2.))):0.; + #else + float w=1.; + #endif + return (a>0.? + a*pow1d5( + //texture(iChannel0,uv/iChannelResolution[0].xy).r + hash21(uv) + )*w + :0.)-(0.0); +} + +float edgeMin(float dx,vec2 da, vec2 db,vec2 uv){ + uv.x+=5.; + vec3 c = fract((round(vec3(uv,uv.x+uv.y)))*(vec3(0,1,2)+0.61803398875)); + float a1 = 0.0>.6?.15:1.; // 0.0 for future edit + float a2 = 0.0>.6?.15:1.; // 0.0 for future edit + float a3 = 0.0>.6?.15:1.; // 0.0 for future edit + + return min(min((1.-dx)*db.y*a3,da.x*a2),da.y*a1); +} + +vec2 trinoise(vec2 uv){ + const float sq = sqrt(3./2.); + uv.x *= sq; + uv.y -= .5*uv.x; + vec2 d = fract(uv); + uv -= d; + + bool c = dot(d,vec2(1))>1.; + + vec2 dd = 1.-d; + vec2 da = c?dd:d,db = c?d:dd; + + float nn = hash(uv+float(c)); + float n2 = hash(uv+vec2(1,0)); + float n3 = hash(uv+vec2(0,1)); + + + float nmid = mix(n2,n3,d.y); + float ns = mix(nn,c?n2:n3,da.y); + float dx = da.x/db.y; + return vec2(mix(ns,nmid,dx),edgeMin(dx,da, db,uv+d)); +} + + +vec2 map(vec3 p){ + vec2 n = trinoise(p.xz); + return vec2(p.y-2.*n.x,n.y); +} + +vec3 grad(vec3 p){ + const vec2 e = vec2(.005,0); + float a =map(p).x; + return vec3(map(p+e.xyy).x-a + ,map(p+e.yxy).x-a + ,map(p+e.yyx).x-a)/e.x; +} + +vec2 intersect(vec3 ro,vec3 rd){ + float d =0.,h=0.; + for(int i = 0;i<500;i++){ //look nice with 50 iterations + vec3 p = ro+d*rd; + vec2 s = map(p); + h = s.x; + d+= h*.5; + if(abs(h)<.003*d) + return vec2(d,s.y); + if(d>150.|| p.y>2.) break; + } + + return vec2(-1); +} + + +void addsun(vec3 rd,vec3 ld,inout vec3 col){ + + float sun = smoothstep(.21,.2,distance(rd,ld)); + + if(sun>0.){ + float yd = (rd.y-ld.y); + + float a =sin(3.1*exp(-(yd)*14.)); + + sun*=smoothstep(-.8,0.,a); + + col = mix(col,vec3(1.,.8,.4)*.75,sun); + } +} + + +float starnoise(vec3 rd){ + float c = 0.; + vec3 p = normalize(rd)*300.; + for (float i=0.;i<4.;i++) + { + vec3 q = fract(p)-.5; + vec3 id = floor(p); + float c2 = smoothstep(.5,0.,length(q)); + c2 *= step(hash21(id.xz/id.y),.06-i*i*0.005); + c += c2; + p = p*.6+.5*p*mat3(3./5.,0,4./5.,0,1,0,-4./5.,0,3./5.); + } + c*=c; + float g = dot(sin(rd*10.512),cos(rd.yzx*10.512)); + c*=smoothstep(-3.14,-.9,g)*.5+.5*smoothstep(-.3,1.,g); + return c*c; +} + +vec3 gsky(vec3 rd,vec3 ld,bool mask){ + float haze = exp2(-5.*(abs(rd.y)-.2*dot(rd,ld))); + + + //float st = mask?pow512(texture(iChannel0,(rd.xy+vec2(300.1,100)*rd.z)*10.).r)*(1.-min(haze,1.)):0.; + //float st = mask?pow512(hash21((rd.xy+vec2(300.1,100)*rd.z)*10.))*(1.-min(haze,1.)):0.; + float st = mask?(starnoise(rd))*(1.-min(haze,1.)):0.; + vec3 back = vec3(.4,.1,.7)*(1.-.5*0.0 // 0.0 for future edit + *exp2(-.1*abs(length(rd.xz)/rd.y)) + *max(sign(rd.y),0.)); + #ifdef city + float x = round(rd.x*30.); + float h = hash21(vec2(x-166.)); + bool building = (h*h*.125*exp2(-x*x*x*x*.0025)>rd.y); + if(mask && building) + back*=0.,haze=.8, mask=mask && !building; + #endif + vec3 col=clamp(mix(back,vec3(.7,.1,.4),haze)+st,0.,1.); + if(mask)addsun(rd,ld,col); + return col; +} + + +void main(void) +{ + fragColor=vec4(0); + #ifdef AA + for(float x = 0.;x<1.;x+=1./float(AA)){ + for(float y = 0.;y<1.;y+=1./float(AA)){ + #else + const float AA=1.,x=0.,y=0.; + #endif + vec2 uv = (2.*(gl_FragCoord.xy+vec2(x,y))-resolution.xy)/resolution.y; + + //float dt = fract(texture(iChannel0,float(AA)*(fragCoord+vec2(x,y))/iChannelResolution[0].xy).r+iTime); + float dt = fract(hash21(float(AA)*(gl_FragCoord.xy+vec2(x,y)))+iTime); + jTime = mod(iTime-dt*iTimeDelta*.25,4000.); + vec3 ro = vec3(0.,1,(-20000.+jTime*speed)); + + #ifdef stereo + ro+=vec3(.2*(float(uv.x>0.)-.5),0.,0.); //-= for x-view + const float de = .9; + uv.x=uv.x+.5*(uv.x>0.?-de:de); + uv*=2.; + #endif + + vec3 rd = normalize(vec3(uv,4./3.));//vec3(uv,sqrt(1.-dot(uv,uv))); + + vec2 i = intersect(ro,rd); + float d = i.x; + + vec3 ld = normalize(vec3(0,.125+.05*sin(.1*jTime),1)); + + vec3 fog = d>0.?exp2(-d*vec3(.14,.1,.28)):vec3(0.); + vec3 sky = gsky(rd,ld,d<0.); + + vec3 p = ro+d*rd; + vec3 n = normalize(grad(p)); + + float diff = dot(n,ld)+.1*n.y; + vec3 col = vec3(.1,.11,.18)*diff; + + vec3 rfd = reflect(rd,n); + vec3 rfcol = gsky(rfd,ld,true); + + col = mix(col,rfcol,.05+.95*pow(max(1.+dot(rd,n),0.),5.)); + #ifdef VAPORWAVE + col = mix(col,vec3(.4,.5,1.),smoothstep(.05,.0,i.y)); + col = mix(sky,col,fog); + col = sqrt(col); + #else + col = mix(col,vec3(.8,.1,.92),smoothstep(.05,.0,i.y)); + col = mix(sky,col,fog); + //no gamma for that old cg look + #endif + if(d<0.) + d=1e6; + d=min(d,10.); + fragColor += vec4(clamp(col,0.,1.0),d<0.?0.:.1+exp2(-d)); + fragColor = vec4(fragColor.rgb,texture2D(texture,texCoord).a); + #ifdef AA + } + } + fragColor/=float(AA*AA); + #endif +} + + diff --git a/wip/Version 1.0/synthwave.gre b/wip/Version 1.0/synthwave.gre new file mode 100644 index 0000000..d3d7f41 --- /dev/null +++ b/wip/Version 1.0/synthwave.gre @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/wip/Version 1.0/tubeclock.frag b/wip/Version 1.0/tubeclock.frag new file mode 100644 index 0000000..d3a8dd9 --- /dev/null +++ b/wip/Version 1.0/tubeclock.frag @@ -0,0 +1,305 @@ +/* Adapted from https://www.shadertoy.com/view/Dds3WB +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core + + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform int hours; //24 +uniform int minutes;//60 +uniform vec4 colour; +uniform float time; + +// boolean input +uniform int TWELVE_HOUR; +uniform int glow; +uniform int shgrid; + +bool TWELVE_HOUR_CLOCK = bool(TWELVE_HOUR); +bool GLOWPULSE = bool(glow); +bool SHOW_GRID = bool(shgrid); + + + +float pi = atan(1.0)*4.0; +float tau = atan(1.0)*8.0; + +const float scale = 1.0 / 6.0; + +vec2 digitSize = vec2(1.0,1.5) * scale; +vec2 digitSpacing = vec2(1.1,1.6) * scale; + + + +// hash function copy from https://www.shadertoy.com/view/4djSRW +float hash12(vec2 p) +{ + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); +} + + +float noise(vec2 pos) { + vec2 i = floor(pos); + vec2 f = fract(pos); + + float a = hash12(i); + float b = hash12(i + vec2(1, 0)); + float c = hash12(i + vec2(0, 1)); + float d = hash12(i + vec2(1, 1)); + + vec2 u = f * f * (3.0 - 2.0 * f); + + return mix(mix(a, b, u.x), mix(c, d, u.x), u.y); +} + +//Distance to a line segment, +float dfLine(vec2 start, vec2 end, vec2 uv) +{ + start *= scale; + end *= scale; + + vec2 line = end - start; + float frac = dot(uv - start,line) / dot(line,line); + return distance(start + line * clamp(frac, 0.0, 1.0), uv); +} + +//Distance to the edge of a circle. +float dfCircle(vec2 origin, float radius, vec2 uv) +{ + origin *= scale; + radius *= scale; + + return abs(length(uv - origin) - radius); +} + +//Distance to an arc. +float dfArc(vec2 origin, float start, float sweep, float radius, vec2 uv) +{ + origin *= scale; + radius *= scale; + + uv -= origin; + uv *= mat2(cos(start), sin(start),-sin(start), cos(start)); + + float offs = (sweep / 2.0 - pi); + float ang = mod(atan(uv.y, uv.x) - offs, tau) + offs; + ang = clamp(ang, min(0.0, sweep), max(0.0, sweep)); + + return distance(radius * vec2(cos(ang), sin(ang)), uv); +} + +//Distance to the digit "d" (0-9). +float dfDigit(vec2 origin, float d, vec2 uv) +{ + uv -= origin; + d = floor(d); + float dist = 1e6; + + if(d == 0.0) + { + dist = min(dist, dfLine(vec2(1.000,1.000), vec2(1.000,0.500), uv)); + dist = min(dist, dfLine(vec2(0.000,1.000), vec2(0.000,0.500), uv)); + dist = min(dist, dfArc(vec2(0.500,1.000),0.000, 3.142, 0.500, uv)); + dist = min(dist, dfArc(vec2(0.500,0.500),3.142, 3.142, 0.500, uv)); + return dist; + } + if(d == 1.0) + { + dist = min(dist, dfLine(vec2(0.500,1.500), vec2(0.500,0.000), uv)); + return dist; + } + if(d == 2.0) + { + dist = min(dist, dfLine(vec2(1.000,0.000), vec2(0.000,0.000), uv)); + dist = min(dist, dfLine(vec2(0.388,0.561), vec2(0.806,0.719), uv)); + dist = min(dist, dfArc(vec2(0.500,1.000),0.000, 3.142, 0.500, uv)); + dist = min(dist, dfArc(vec2(0.700,1.000),5.074, 1.209, 0.300, uv)); + dist = min(dist, dfArc(vec2(0.600,0.000),1.932, 1.209, 0.600, uv)); + return dist; + } + if(d == 3.0) + { + dist = min(dist, dfLine(vec2(0.000,1.500), vec2(1.000,1.500), uv)); + dist = min(dist, dfLine(vec2(1.000,1.500), vec2(0.500,1.000), uv)); + dist = min(dist, dfArc(vec2(0.500,0.500),3.142, 4.712, 0.500, uv)); + return dist; + } + if(d == 4.0) + { + dist = min(dist, dfLine(vec2(0.700,1.500), vec2(0.000,0.500), uv)); + dist = min(dist, dfLine(vec2(0.000,0.500), vec2(1.000,0.500), uv)); + dist = min(dist, dfLine(vec2(0.700,1.200), vec2(0.700,0.000), uv)); + return dist; + } + if(d == 5.0) + { + dist = min(dist, dfLine(vec2(1.000,1.500), vec2(0.300,1.500), uv)); + dist = min(dist, dfLine(vec2(0.300,1.500), vec2(0.200,0.900), uv)); + dist = min(dist, dfArc(vec2(0.500,0.500),3.142, 5.356, 0.500, uv)); + return dist; + } + if(d == 6.0) + { + dist = min(dist, dfLine(vec2(0.067,0.750), vec2(0.500,1.500), uv)); + dist = min(dist, dfCircle(vec2(0.500,0.500), 0.500, uv)); + return dist; + } + if(d == 7.0) + { + dist = min(dist, dfLine(vec2(0.000,1.500), vec2(1.000,1.500), uv)); + dist = min(dist, dfLine(vec2(1.000,1.500), vec2(0.500,0.000), uv)); + return dist; + } + if(d == 8.0) + { + dist = min(dist, dfCircle(vec2(0.500,0.400), 0.400, uv)); + dist = min(dist, dfCircle(vec2(0.500,1.150), 0.350, uv)); + return dist; + } + if(d == 9.0) + { + dist = min(dist, dfLine(vec2(0.933,0.750), vec2(0.500,0.000), uv)); + dist = min(dist, dfCircle(vec2(0.500,1.000), 0.500, uv)); + return dist; + } + + return dist; +} + +//Distance to a number +float dfNumber(vec2 origin, float num, vec2 uv) +{ + uv -= origin; + float dist = 1e6; + float offs = 0.0; + + for(float i = 5.0;i > -3.0;i--) + { + float d = mod(num / pow(10.0,i),10.0); + + vec2 pos = digitSpacing * vec2(offs,0.0); + + if(i == 0.0) + { + dist = min(dist, dfCircle(vec2(offs+0.9,0.1)*1.1, 0.04,uv)); + } + + if(num > pow(10.0,i) || i == 0.0) + { + dist = min(dist, dfDigit(pos, d, uv)); + offs++; + } + } + return dist; +} + +//Distance to a number This handles 2 digit integers, leading 0's will be drawn +float dfNumberInt(vec2 origin, int inum, vec2 uv) +{ + float num = float(inum); + uv -= origin; + float dist = 1e6; + float offs = 0.0; + + for(float i = 1.0;i >= 0.0;i--) + { + float d = mod(num / pow(10.0,i),10.0); + + vec2 pos = digitSpacing * vec2(offs,0.0); + + dist = min(dist, dfDigit(pos, d, uv)); + offs++; + } + return dist; +} + +float dfColon(vec2 origin, vec2 uv) { + uv -= origin; + float dist = 1e6; + float offs = 0.0; + + dist = min(dist, dfCircle(vec2(offs+0.9,0.9)*1.1, 0.04,uv)); + dist = min(dist, dfCircle(vec2(offs+0.9,0.4)*1.1, 0.04,uv)); + return dist; +} + +//Length of a number in digits +float numberLength(float n) +{ + return floor(max(log(n) / log(10.0), 0.0) + 1.0) + 2.0; +} + +void main(void) +{ + // Test outside the circle for round watches + /*vec2 uvTest = (gl_FragCoord.xy-.5*iResolution.xy)/iResolution.y; + + float absX = uvTest.x*uvTest.x; + float absY = uvTest.y*uvTest.y; + if(sqrt(absX + absY) >0.5) { + fragColor = vec4(0.1); + return; + }*/ + // end test + + vec2 aspect = resolution.xy / resolution.y; + vec2 uv = (gl_FragCoord.xy / resolution.y - aspect/2.0) *0.86; + + + int hour = hours; + +if (TWELVE_HOUR_CLOCK) { + + if( hour > 12 ) hour -= 12; + if( hour == 0 ) hour = 12; } + + + int minute = int(mod(float(minutes*60)/60.,60.)); + + float nsize = numberLength(9999.); + vec2 pos = -digitSpacing * vec2(nsize,1.0)/2.0; + + vec2 basepos = pos; + pos.x = basepos.x + 0.16; + float dist = 1e6; + dist = min(dist, dfNumberInt(pos, hour, uv)); + + pos.x = basepos.x + 0.39; + dist = min(dist, dfColon( pos, uv )); + + pos.x = basepos.x + 0.60; + float dist2 = 1e6; + dist = min(dist, dfNumberInt(pos, minute, uv)); + + vec3 color = vec3(0); + + float shade = 0.0; + + shade = 0.004 / (dist); + + + // color of lights + color += colour.rgb* shade; +if (GLOWPULSE){ + color += colour.rgb* shade * noise((uv + vec2(time*.5)) * 2.5 + .5);// * 10.*(noise(uv.yx)); +} + + if (SHOW_GRID){ + float grid = 0.5-max(abs(mod(uv.x*64.0,1.0)-0.5), abs(mod(uv.y*64.0,1.0)-0.5)); + + color *= 0.25+vec3(smoothstep(0.0,64.0 / resolution.y,grid))*0.75; + } + + fragColor = vec4( color , color* texture2D(texture,texCoord).a ); +} + + diff --git a/wip/Version 1.0/tubeclock.gre b/wip/Version 1.0/tubeclock.gre new file mode 100644 index 0000000..21eac6e --- /dev/null +++ b/wip/Version 1.0/tubeclock.gre @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/wip/Version 1.0/undulatingBurnOut.frag b/wip/Version 1.0/undulatingBurnOut.frag new file mode 100644 index 0000000..450d948 --- /dev/null +++ b/wip/Version 1.0/undulatingBurnOut.frag @@ -0,0 +1,70 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/undulatingBurnOut.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + + +uniform float smoothness; +uniform vec2 center; +uniform vec4 color; +uniform float progress; + + +const float M_PI = 3.14159265358979323846; + +float quadraticInOut(float t) { + float p = 2.0 * t * t; + return t < 0.5 ? p : -p + (4.0 * t) - 1.0; +} + +float getGradient(float r, float dist) { + float d = r - dist; + return mix( + smoothstep(-smoothness, 0.0, r - dist * (1.0 + smoothness)), + -1.0 - step(0.005, d), + step(-0.005, d) * step(d, 0.01) + ); +} + +float getWave(vec2 p){ + vec2 _p = p - center; // offset from center + float rads = atan(_p.y, _p.x); + float degs = degrees(rads) + 180.0; + vec2 range = vec2(0.0, M_PI * 30.0); + vec2 domain = vec2(0.0, 360.0); + float ratio = (M_PI * 30.0) / 360.0; + degs = degs * ratio; + float x = progress; + float magnitude = mix(0.02, 0.09, smoothstep(0.0, 1.0, x)); + float offset = mix(40.0, 30.0, smoothstep(0.0, 1.0, x)); + float ease_degs = quadraticInOut(sin(degs)); + float deg_wave_pos = (ease_degs * magnitude) * sin(x * offset); + return x + deg_wave_pos; +} + +vec4 transition(vec2 p) { + float dist = distance(center, p); + float m = getGradient(getWave(p), dist); + vec4 cfrom = texture2D(texture,p); + vec4 cto =vec4(0.0); // for future use + return mix(mix(cfrom, cto, m), mix(cfrom, vec4(color), 0.75), step(m, -2.0)); +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = gl_FragCoord.xy/resolution.xy; + + + // Output to screen + fragColor = transition(uv); +} diff --git a/wip/Version 1.0/undulatingBurnOut.gre b/wip/Version 1.0/undulatingBurnOut.gre new file mode 100644 index 0000000..3ae2602 --- /dev/null +++ b/wip/Version 1.0/undulatingBurnOut.gre @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/wip/Version 1.0/wavingparticle.frag b/wip/Version 1.0/wavingparticle.frag new file mode 100644 index 0000000..0ca9919 --- /dev/null +++ b/wip/Version 1.0/wavingparticle.frag @@ -0,0 +1,169 @@ +/* Adapted from https://www.shadertoy.com/view/ttB3Rt Shader License: CC BY 3.0 +Rebuilt for enve/friction by axiomgraph + Opengl version 3.3*/ + +#version 330 core +#define PI 3.14159 +#define TWO_PI 6.283185 +#define FREQ_STEP (0.001953125 * 3.0) + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float iTime; +uniform int randomsize; +uniform float PARTICLE_ITERATIONS; // 6.0 +uniform float PARTICLE_RADIUS; // 0.15 +uniform float PARTICLE_RADIUS2; // 0.3 +uniform float PARTICLE_SIZE_VARIATION; // 0.2 +uniform vec4 PARTICLE_COLOR; // 0.3, 0.9, 0.9 +uniform float BRIGHTNESS; // 0.45 + +bool RANDOMIZED_SIZE = bool(randomsize); // boolean value + + +float pow3(in float x) +{ + return x*x*x; +} + +float hash1_2(in vec2 x) +{ + return fract(sin(dot(x, vec2(52.127, 61.2871))) * 521.582); +} + +vec2 hash2_3(in vec3 x) +{ + return fract(sin(x * mat2x3(20.5283, 24.1994, 70.2913, + 89.9132, 57.1454, 45.1211)) * 492.194); +} + + +//Simple interpolated noise +vec2 noise2_3(vec3 coord) +{ + //vec3 f = fract(coord); + vec3 f = smoothstep(0.0, 1.0, fract(coord)); + + vec3 uv000 = floor(coord); + vec3 uv001 = uv000 + vec3(0,0,1); + vec3 uv010 = uv000 + vec3(0,1,0); + vec3 uv011 = uv000 + vec3(0,1,1); + vec3 uv100 = uv000 + vec3(1,0,0); + vec3 uv101 = uv000 + vec3(1,0,1); + vec3 uv110 = uv000 + vec3(1,1,0); + vec3 uv111 = uv000 + vec3(1,1,1); + + vec2 v000 = hash2_3(uv000); + vec2 v001 = hash2_3(uv001); + vec2 v010 = hash2_3(uv010); + vec2 v011 = hash2_3(uv011); + vec2 v100 = hash2_3(uv100); + vec2 v101 = hash2_3(uv101); + vec2 v110 = hash2_3(uv110); + vec2 v111 = hash2_3(uv111); + + vec2 v00 = mix(v000, v001, f.z); + vec2 v01 = mix(v010, v011, f.z); + vec2 v10 = mix(v100, v101, f.z); + vec2 v11 = mix(v110, v111, f.z); + + vec2 v0 = mix(v00, v01, f.y); + vec2 v1 = mix(v10, v11, f.y); + vec2 v = mix(v0, v1, f.x); + + return v; +} + +//Simple interpolated noise +float noise1_2(in vec2 uv) +{ + vec2 f = fract(uv); + //vec2 f = smoothstep(0.0, 1.0, fract(uv)); + + vec2 uv00 = floor(uv); + vec2 uv01 = uv00 + vec2(0,1); + vec2 uv10 = uv00 + vec2(1,0); + vec2 uv11 = uv00 + 1.0; + + float v00 = hash1_2(uv00); + float v01 = hash1_2(uv01); + float v10 = hash1_2(uv10); + float v11 = hash1_2(uv11); + + float v0 = mix(v00, v01, f.y); + float v1 = mix(v10, v11, f.y); + float v = mix(v0, v1, f.x); + + return v; +} + + +//Calculates particle movement +vec2 cellPointFromRootUV(vec2 rootUV, vec2 originalUV, out float len) +{ + vec2 displacement = (noise2_3(vec3(rootUV * 0.07 + iTime * 0.3, 0.5 * (iTime + 0.1) * 1.0 + noise1_2(originalUV * 0.04))) - 0.5); + len = dot(displacement, displacement); + return displacement * 3.0 * (PARTICLE_ITERATIONS) + 0.5 + rootUV; +} + +//Calculates particle size +float particleFromUVAndPoint(in vec2 uv, in vec2 point, in vec2 rootUV, in float pixelSize) +{ + float dist = distance(uv, point); +if ( RANDOMIZED_SIZE) { + dist += (hash1_2(rootUV * 10.0) - 0.5) * PARTICLE_SIZE_VARIATION; + } + + float particle = 1.0 - smoothstep(PARTICLE_RADIUS - dist * 0.05, PARTICLE_RADIUS2 - dist * 0.05 + pixelSize, dist); + return particle * particle; +} + +//Particle system +vec3 surfaceParticles(in vec2 uv, in float pixelSize) +{ + vec3 particles = vec3(0.0); + vec2 rootUV = floor(uv); + + vec2 tempRootUV; + vec2 pointUV; + float dist; + vec3 color; + for (float x = -PARTICLE_ITERATIONS; x <= PARTICLE_ITERATIONS; x += 1.0) + { + for (float y = -PARTICLE_ITERATIONS; y <= PARTICLE_ITERATIONS; y += 1.0) + { + tempRootUV = rootUV + vec2(x, y); + pointUV = cellPointFromRootUV(tempRootUV, uv, dist); + color = mix(vec3(0), PARTICLE_COLOR.rgb *1.0, pow(smoothstep(0.3, 0.0, dist), 4.0)); + particles += particleFromUVAndPoint(uv, pointUV, tempRootUV, pixelSize) * color; + } + } + + return particles; +} + +void main(void) +{ + vec2 uv = (2.0 * gl_FragCoord.xy - resolution.xy) / resolution.x; + + float vignette = 1.0 - smoothstep(0.5, 1.3, length(uv* vec2(1.0, resolution.x / resolution.y))); + + //for antialiasing + float pixelSize = 1.5 / resolution.x; + + uv *= 70.0; + pixelSize *= 70.0; + + vec3 particles = surfaceParticles(uv, pixelSize) * BRIGHTNESS; + + //postprocess + particles = smoothstep(-0.2, 0.8, particles * vignette); + + fragColor = vec4(particles, texture2D(texture,texCoord).a); +} diff --git a/wip/Version 1.0/wavingparticle.gre b/wip/Version 1.0/wavingparticle.gre new file mode 100644 index 0000000..252e056 --- /dev/null +++ b/wip/Version 1.0/wavingparticle.gre @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/wip/Version 1.0/windowslice.frag b/wip/Version 1.0/windowslice.frag new file mode 100644 index 0000000..a153852 --- /dev/null +++ b/wip/Version 1.0/windowslice.frag @@ -0,0 +1,29 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/windowslice.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; + +uniform float progress; + +uniform float count; +uniform float smoothness; + +vec4 transition (vec2 p) { + float pr = smoothstep(-smoothness, 0.0, p.x - progress * (1.0 + smoothness)); + float s = step(pr, fract(count * p.x)); + return mix(texture2D(texture,p), vec4(0.0), s); // for future use +} + +void main(void) +{ + + fragColor = transition(texCoord); +} + diff --git a/wip/Version 1.0/windowslice.gre b/wip/Version 1.0/windowslice.gre new file mode 100644 index 0000000..ea4ee1b --- /dev/null +++ b/wip/Version 1.0/windowslice.gre @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/wip/Version 2.0/BookFlip.frag b/wip/Version 2.0/BookFlip.frag new file mode 100644 index 0000000..2f84550 --- /dev/null +++ b/wip/Version 2.0/BookFlip.frag @@ -0,0 +1,46 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/BookFlip.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; + +uniform float progress; + +vec2 skewRight(vec2 p) { + float skewX = (p.x - progress)/(0.5 - progress) * 0.5; + float skewY = (p.y - 0.5)/(0.5 + progress * (p.x - 0.5) / 0.5)* 0.5 + 0.5; + return vec2(skewX, skewY); +} + +vec2 skewLeft(vec2 p) { + float skewX = (p.x - 0.5)/(progress - 0.5) * 0.5 + 0.5; + float skewY = (p.y - 0.5) / (0.5 + (1.0 - progress ) * (0.5 - p.x) / 0.5) * 0.5 + 0.5; + return vec2(skewX, skewY); +} + +vec4 addShade() { + float shadeVal = max(0.7, abs(progress - 0.5) * 2.0); + return vec4(vec3(shadeVal ), 1.0); +} + +vec4 transition (vec2 p) { + float pr = step(1.0 - progress, p.x); + + if (p.x < 0.5) { + return mix(texture(texture,p), vec4(1.0)* addShade(), pr); + } else { + return mix(texture(texture,skewRight(p)) * addShade(), vec4(0.0), pr); + } +} + +void main(void) +{ + + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/BookFlip.gre b/wip/Version 2.0/BookFlip.gre new file mode 100644 index 0000000..d405eef --- /dev/null +++ b/wip/Version 2.0/BookFlip.gre @@ -0,0 +1,8 @@ + + + + + + diff --git a/wip/Version 2.0/DoomScreenTransition.frag b/wip/Version 2.0/DoomScreenTransition.frag new file mode 100644 index 0000000..5a07f60 --- /dev/null +++ b/wip/Version 2.0/DoomScreenTransition.frag @@ -0,0 +1,80 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/DoomScreenTransition.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float progress;// = 0.01; +// Transition parameters -------- + +// Number of total bars/columns +uniform int bars; // = 30; // + +// Multiplier for speed ratio. 0 = no variation when going down, higher = some elements go much faster +uniform float amplitude ; // = 2.0; // + +// Further variations in speed. 0 = no noise, 1 = super noisy (ignore frequency) + uniform float noise ; // = 0.1; // + +// Speed variation horizontally. the bigger the value, the shorter the waves +uniform float frequency; // = 0.5; // + +// How much the bars seem to "run" from the middle of the screen first (sticking to the sides). 0 = no drip, 1 = curved drip +uniform float dripScale; // = 0.5; // + + +// The code proper -------- + +float rand(int num) { + return fract(mod(float(num) * 67123.313, 12.0) * sin(float(num) * 10.3) * cos(float(num))); +} + +float wave(int num) { + float fn = float(num) * frequency * 0.1 * float(bars); + return cos(fn * 0.5) * cos(fn * 0.13) * sin((fn+10.0) * 0.3) / 2.0 + 0.5; +} + +float drip(int num) { + return sin(float(num) / float(bars - 1) * 3.141592) * dripScale; +} + +float pos(int num) { + return (noise == 0.0 ? wave(num) : mix(wave(num), rand(num), noise)) + (dripScale == 0.0 ? 0.0 : drip(num)); +} + +vec4 transition(vec2 uv) { + int bar = int(uv.x * (float(bars))); + float scale = 1.0 + pos(bar) * amplitude; + float phase = progress * scale; + float posY = uv.y / vec2(1.0).y; + vec2 p; + vec4 c; + if (phase + posY < 1.0) { + p = vec2(uv.x, uv.y + mix(0.0, vec2(1.0).y, phase)) / vec2(1.0).xy; + c = texture(texture,p); + } else { + p = uv.xy / vec2(1.0).xy; + c = vec4(0.0); // for future use + } + + // Finally, apply the color + return c; +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = gl_FragCoord.xy/resolution.xy; + + + // Output to screen + fragColor = transition(uv); +} + diff --git a/wip/Version 2.0/DoomScreenTransition.gre b/wip/Version 2.0/DoomScreenTransition.gre new file mode 100644 index 0000000..2e16136 --- /dev/null +++ b/wip/Version 2.0/DoomScreenTransition.gre @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/wip/Version 2.0/HorizontalClose.frag b/wip/Version 2.0/HorizontalClose.frag new file mode 100644 index 0000000..4cc90b9 --- /dev/null +++ b/wip/Version 2.0/HorizontalClose.frag @@ -0,0 +1,27 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/HorizontalClose.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; + +uniform float progress; +uniform float feather; +vec4 transition (vec2 uv) { + + float s = 2.0 - abs((uv.y - 0.5) / (progress - 1.0)) - 2.0 * progress; + + return mix( + texture(texture,uv), + vec4(0.0), + smoothstep(feather, 0.0 , s) + ); +} +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/HorizontalClose.gre b/wip/Version 2.0/HorizontalClose.gre new file mode 100644 index 0000000..e875628 --- /dev/null +++ b/wip/Version 2.0/HorizontalClose.gre @@ -0,0 +1,9 @@ + + + + + + + diff --git a/wip/Version 2.0/LeftRight.frag b/wip/Version 2.0/LeftRight.frag new file mode 100644 index 0000000..796f5a9 --- /dev/null +++ b/wip/Version 2.0/LeftRight.frag @@ -0,0 +1,39 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/LeftRight.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; + +uniform float progress; + +const vec4 black = vec4(0.0, 0.0, 0.0, 1.0); +const vec2 boundMin = vec2(0.0, 0.0); +const vec2 boundMax = vec2(1.0, 1.0); + +bool inBounds (vec2 p) { + return all(lessThan(boundMin, p)) && all(lessThan(p, boundMax)); +} + +vec4 transition (vec2 uv) { + vec2 spfr,spto = vec2(-1.); + + float size = mix(1.0, 3.0, progress*0.2); + spto = (uv + vec2(-0.5,-0.5))*vec2(size,size)+vec2(0.5,0.5); + spfr = (uv - vec2(1.-progress, 0.0)); + if(inBounds(spfr)){ + return vec4(0.0); + }else if(inBounds(spto)){ + return texture(texture,spto) * (1.0 - progress); + } else{ + return black; + } +} +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/LeftRight.gre b/wip/Version 2.0/LeftRight.gre new file mode 100644 index 0000000..a24a7bd --- /dev/null +++ b/wip/Version 2.0/LeftRight.gre @@ -0,0 +1,8 @@ + + + + + + diff --git a/wip/Version 2.0/PolkaDotsCurtain.frag b/wip/Version 2.0/PolkaDotsCurtain.frag new file mode 100644 index 0000000..0ab67b3 --- /dev/null +++ b/wip/Version 2.0/PolkaDotsCurtain.frag @@ -0,0 +1,32 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/PolkaDotsCurtain.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; +uniform vec2 resolution; + +const float SQRT_2 = 1.414213562373; + +uniform float progress; +uniform float dots; +uniform vec2 center; + +vec4 transition(vec2 uv) { + float ar = resolution.x/resolution.y; + uv.x*=ar; + bool nextImage = distance(fract(uv * dots), vec2(0.5, 0.5)) < ( progress / distance(uv, center)); + uv.x/=ar; +// return nextImage ? vec4(0.0) : texture2D(texture,uv); +return nextImage ? texture(texture,uv) : vec4(0.0); +} + +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/PolkaDotsCurtain.gre b/wip/Version 2.0/PolkaDotsCurtain.gre new file mode 100644 index 0000000..ab668e2 --- /dev/null +++ b/wip/Version 2.0/PolkaDotsCurtain.gre @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/wip/Version 2.0/VHS.frag b/wip/Version 2.0/VHS.frag new file mode 100644 index 0000000..99f535e --- /dev/null +++ b/wip/Version 2.0/VHS.frag @@ -0,0 +1,91 @@ +/* Adapted from https://www.shadertoy.com/view/XtBXDt +Rebuilt for enve/friction by axiomgraph + Opengl version 3.3*/ + +#version 330 core +#define PI 3.14159265 + + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float time; + +vec3 tex2D( sampler2D texture, vec2 _p ){ + vec3 col = texture( texture, _p ).xyz; + if ( 0.5 < abs( _p.x - 0.5 ) ) { + col = vec3( 0.1 ); + } + return col; +} + +float hash( vec2 _v ){ + return fract( sin( dot( _v, vec2( 89.44, 19.36 ) ) ) * 22189.22 ); +} + +float iHash( vec2 _v, vec2 _r ){ + float h00 = hash( vec2( floor( _v * _r + vec2( 0.0, 0.0 ) ) / _r ) ); + float h10 = hash( vec2( floor( _v * _r + vec2( 1.0, 0.0 ) ) / _r ) ); + float h01 = hash( vec2( floor( _v * _r + vec2( 0.0, 1.0 ) ) / _r ) ); + float h11 = hash( vec2( floor( _v * _r + vec2( 1.0, 1.0 ) ) / _r ) ); + vec2 ip = vec2( smoothstep( vec2( 0.0, 0.0 ), vec2( 1.0, 1.0 ), mod( _v*_r, 1. ) ) ); + return ( h00 * ( 1. - ip.x ) + h10 * ip.x ) * ( 1. - ip.y ) + ( h01 * ( 1. - ip.x ) + h11 * ip.x ) * ip.y; +} + +float noise( vec2 _v ){ + float sum = 0.; + for( int i=1; i<9; i++ ) + { + sum += iHash( _v + vec2( i ), vec2( 2. * pow( 2., float( i ) ) ) ) / pow( 2., float( i ) ); + } + return sum; +} + +void main(void){ + vec2 uv = gl_FragCoord.xy / resolution; + vec2 uvn = uv; + vec3 col = vec3( 0.0 ); + + // tape wave + uvn.x += ( noise( vec2( uvn.y, time ) ) - 0.5 )* 0.005; + uvn.x += ( noise( vec2( uvn.y * 100.0, time * 10.0 ) ) - 0.5 ) * 0.01; + + // tape crease + float tcPhase = clamp( ( sin( uvn.y * 8.0 - time * PI * 1.2 ) - 0.92 ) * noise( vec2( time ) ), 0.0, 0.01 ) * 10.0; + float tcNoise = max( noise( vec2( uvn.y * 100.0, time * 10.0 ) ) - 0.5, 0.0 ); + uvn.x = uvn.x - tcNoise * tcPhase; + + // switching noise + float snPhase = smoothstep( 0.03, 0.0, uvn.y ); + uvn.y += snPhase * 0.3; + uvn.x += snPhase * ( ( noise( vec2( uv.y * 100.0, time * 10.0 ) ) - 0.5 ) * 0.2 ); + + col = tex2D( texture, uvn ); + col *= 1.0 - tcPhase; + col = mix( + col, + col.yzx, + snPhase + ); + + // bloom + for( float x = -4.0; x < 2.5; x += 1.0 ){ + col.xyz += vec3( + tex2D( texture, uvn + vec2( x - 0.0, 0.0 ) * 7E-3 ).x, + tex2D( texture, uvn + vec2( x - 2.0, 0.0 ) * 7E-3 ).y, + tex2D( texture, uvn + vec2( x - 4.0, 0.0 ) * 7E-3 ).z + ) * 0.1; + } + col *= 0.6; + + // ac beat + col *= 1.0 + clamp( noise( vec2( 0.0, uv.y + time * 0.2 ) ) * 0.6 - 0.25, 0.0, 0.1 ); + + fragColor = vec4( col, 1.0 ); +} + diff --git a/wip/Version 2.0/VHS.gre b/wip/Version 2.0/VHS.gre new file mode 100644 index 0000000..9b8ded1 --- /dev/null +++ b/wip/Version 2.0/VHS.gre @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/wip/Version 2.0/analogclock.frag b/wip/Version 2.0/analogclock.frag new file mode 100644 index 0000000..1d95d4a --- /dev/null +++ b/wip/Version 2.0/analogclock.frag @@ -0,0 +1,148 @@ +/* Adapted from https://www.shadertoy.com/view/DtScWV +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core +#define PI 3.14159 + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float hours; +uniform float minutes; +uniform float seconds; + +float deg2Rad(float degrees) +{ + return degrees * 0.0174533; +} + +vec2 rotate(vec2 vec, float angle) +{ + mat2 rotMat = mat2(cos(angle), -sin(angle), + sin(angle), cos(angle)); + + return vec * rotMat; +} + +float circleShape(vec2 center, vec2 uv, float radius) +{ + float dist = length(uv - center); + return 1.0 - smoothstep(radius - 0.0025, radius + 0.0025, dist); +} + +float rectShape(vec2 center, vec2 size, vec2 uv, float rotation) +{ + vec2 le = center - size / 2.0; + vec2 ue = center + size / 2.0; + + uv -= 0.5; + uv = rotate(uv, deg2Rad(rotation)); + uv.y += size.y / 2.0; + uv += 0.5; + + float smoothness = 0.0025; + + float rect = smoothstep(le.x - smoothness, le.x + smoothness, uv.x); + rect *= smoothstep(le.y - smoothness, le.y + smoothness, uv.y); + + rect *= 1.0 - smoothstep(ue.x - smoothness, ue.x + smoothness, uv.x); + rect *= 1.0 - smoothstep(ue.y - smoothness, ue.y + smoothness, uv.y); + + return rect; +} + +float angleCoords(vec2 uv, float rotation) +{ + uv -= 0.5; + uv = rotate(uv, deg2Rad(rotation)); + float angle = atan(uv.x, uv.y); + angle /= PI; + angle += 1.0; + angle /= 2.0; + return angle; +} + +float clockMarkings(vec2 uv, vec2 center, float count, float thickness, + float radius, float lngth, float smoothness) +{ + float seg = cos(angleCoords(uv, 0.0) * PI * 2.0 * count); + float ring = circleShape(vec2(0.5, 0.5), uv, radius); + ring -= circleShape(vec2(0.5, 0.5), uv, radius - lngth); + return smoothstep(1.0 - thickness, 1.0 + smoothness - thickness, seg) * ring; +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = gl_FragCoord.xy/resolution.xy; + + float scale = 0.9; + + uv -= 0.5; + uv *= 1.0 / scale; + uv.x *= resolution.x / resolution.y; + uv = rotate(uv, deg2Rad(180.0)); + uv += 0.5; + + vec2 center = vec2(0.5, 0.5); + + //Base color + float mask = circleShape(center, uv, 0.525); + vec3 col1 = mix(vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0), mask); + + //Minute markings + vec3 markColor = vec3(0.1, 0.1, 0.1); + float mark = clockMarkings(uv, center, 60.0, 0.1, 0.5, 0.02, 0.1); + vec3 col = mix(col1, markColor, mark); + + //5 minutes markings + vec3 mark1Color = vec3(0.0, 0.0, 0.0); + float mark1 = clockMarkings(uv, center, 12.0, 0.02, 0.5, 0.035, 0.01); + col = mix(col, mark1Color, mark1); + + + //Hours hand + vec3 hand1Color = vec3(0.0, 0.0, 0.0); + float hand1 = rectShape(center, vec2(0.025, 0.3), uv, hours * 360.0 / 12.0); + col = mix(col, hand1Color, hand1); + + //Circle + vec3 circleColor = vec3(0.0, 0.0, 0.0); + float circle = circleShape(center, uv, 0.03); + col = mix(col, circleColor, circle); + + //Minutes hand + vec3 hand2Color = vec3(0.2, 0.2, 0.2); + float hand2 = rectShape(center, vec2(0.02, 0.4), uv, minutes * 360.0 / 60.0); + col = mix(col, hand2Color, hand2); + + //Circle + circleColor = vec3(0.2, 0.2, 0.2); + circle = circleShape(center, uv, 0.025); + col = mix(col, circleColor, circle); + + //Seconds hand + vec3 hand3Color = vec3(1.0, 0.0, 0.0); + float hand3 = rectShape(center, vec2(0.01, 0.475), uv, seconds * 360.0 / 60.0); + col = mix(col, hand3Color, hand3); + + //Circle + circleColor = vec3(1.0, 0.0, 0.0); + circle = circleShape(center, uv, 0.02); + col = mix(col, circleColor, circle); + + //Circle + circleColor = vec3(1.0, 1.0, 1.0); + circle = circleShape(center, uv, 0.0125); + col = mix(col, circleColor, circle); + +vec3 alphacomb = col1*texture(texture,gl_FragCoord.xy/resolution.xy).a; + + // Output to screen + fragColor = vec4(col,alphacomb); +} diff --git a/wip/Version 2.0/analogclock.gre b/wip/Version 2.0/analogclock.gre new file mode 100644 index 0000000..3ce8aef --- /dev/null +++ b/wip/Version 2.0/analogclock.gre @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/wip/Version 2.0/butterflyWaveScrawler.frag b/wip/Version 2.0/butterflyWaveScrawler.frag new file mode 100644 index 0000000..8f47381 --- /dev/null +++ b/wip/Version 2.0/butterflyWaveScrawler.frag @@ -0,0 +1,47 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/ButterflyWaveScrawler.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; + +uniform float progress; + +uniform float amplitude ; +uniform float waves; +uniform float colorSeparation; + +float PI = 3.14159265358979323846264; +float compute(vec2 p, float progress, vec2 center) { +vec2 o = p*sin(progress * amplitude)-center; +// horizontal vector +vec2 h = vec2(1., 0.); +// butterfly polar function (don't ask me why this one :)) +float theta = acos(dot(o, h)) * waves; +return (exp(cos(theta)) - 2.*cos(4.*theta) + pow(sin((2.*theta - PI) / 24.), 5.)) / 10.; +} +vec4 transition(vec2 uv) { + vec2 p = uv.xy / vec2(1.0).xy; + float inv = 1. - progress; + vec2 dir = p - vec2(.5); + float dist = length(dir); + float disp = compute(p, progress, vec2(0.5, 0.5)) ; + //vec4 texTo = getToColor(p + inv*disp); // for future use + vec4 texTo = vec4(0.0); + vec4 texFrom = vec4( + texture(texture,p + progress*disp*(1.0 - colorSeparation)).r, + texture(texture,p + progress*disp).g, +texture(texture,p + progress*disp*(1.0 + colorSeparation)).b, + 1.0); + return texTo*progress + texFrom*inv; +} +void main(void) +{ + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/butterflyWaveScrawler.gre b/wip/Version 2.0/butterflyWaveScrawler.gre new file mode 100644 index 0000000..1e43ab7 --- /dev/null +++ b/wip/Version 2.0/butterflyWaveScrawler.gre @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/wip/Version 2.0/clockofclocks.frag b/wip/Version 2.0/clockofclocks.frag new file mode 100644 index 0000000..1c23b5d --- /dev/null +++ b/wip/Version 2.0/clockofclocks.frag @@ -0,0 +1,364 @@ +/* Adapted from https://www.shadertoy.com/view/ws2XRd +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core + +#define PI 3.14159265359 +#define TAU 6.28318530718f + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float NumberOfAnimations; + +uniform float hours; +uniform float minutes; +uniform float seconds; + + +float date = (hours*3600.0)+(minutes*60.0)+seconds; + +const vec2 o[11] = vec2[11]( + vec2(359.9,180.), //vertical 0 + vec2(90.,270.), //horizontal 1 + vec2(359.9,90.), //bottomLeftCorner 2 + vec2(90.,180.), //topLeftCorner 3 + vec2(270.,180.), //topRightCorner 4 + vec2(359.9,270.), //bottomRightCorner 5 + vec2(135,135), //"hidden" 6 + vec2(359.9,359.9), //botStump 7 + vec2(180,180), //topStump 8 + vec2(90,90), //leftStump 9 + vec2(270,270) //rightStump 10 + ); + +const vec2 numbers[4*8*10] = vec2[4*8*10]( + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[3],o[1],o[1],o[4], + //ONE + o[6],o[6],o[2],o[5], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[2],o[4],o[0], + o[6],o[3],o[1],o[4], + //TWO + o[2],o[1],o[1],o[5], + o[0],o[2],o[1],o[4], + o[0],o[0],o[6],o[6], + o[0],o[3],o[1],o[5], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[1],o[4], + //THREE + o[2],o[1],o[1],o[5], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[1],o[4], + //FOUR + o[6],o[6],o[2],o[5], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[0],o[0],o[0], + o[3],o[4],o[3],o[4], + //FIVE + o[2],o[1],o[1],o[5], + o[3],o[1],o[5],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[0],o[2],o[1],o[4], + o[0],o[0],o[6],o[6], + o[0],o[3],o[1],o[5], + o[3],o[1],o[1],o[4], + //SIX + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[0],o[2],o[1],o[4], + o[0],o[0],o[6],o[6], + o[0],o[3],o[1],o[5], + o[3],o[1],o[1],o[4], + //SEVEN + o[6],o[6],o[2],o[5], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[6],o[6],o[0],o[0], + o[2],o[1],o[4],o[0], + o[3],o[1],o[1],o[4], + //EIGHT + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[3],o[1],o[1],o[4], + //NINE + o[2],o[1],o[1],o[5], + o[0],o[2],o[5],o[0], + o[3],o[4],o[0],o[0], + o[2],o[1],o[4],o[0], + o[0],o[2],o[5],o[0], + o[0],o[0],o[0],o[0], + o[0],o[3],o[4],o[0], + o[3],o[1],o[1],o[4] + ); + +//https://gist.github.com/itsmrpeck/be41d72e9d4c72d2236de687f6f53974 +float lerpRadians(float a, float b, float lerpFactor) // Lerps from angle a to b (both between 0.f and TAU), taking the shortest path +{ + float result; + float diff = b - a; + if (diff < -PI) // lerp upwards past TAU + { + b += TAU; + result = mix(a, b, lerpFactor); + if (result >= TAU) + { + result -= TAU; + } + } + else if (diff > PI) // lerp downwards past 0 + { + b -= TAU; + result = mix(a, b, lerpFactor); + if (result < 0.f) + { + result += TAU; + } + } + else // straight lerp + { + result = mix(a, b, lerpFactor); + } + + return result; +} + +float when_gt(float x, float y) { + return max(sign(x - y), 0.0); +} + +float when_lt(float x, float y) { + return max(sign(y - x), 0.0); +} + +vec2 getRotation(int x, int y, int n) { + return numbers[((4 * y) + x) + (n * 32)]; +} + +float distanceToSegment( in vec2 p, in vec2 a, in vec2 b ) +{ + //Iq's function (I use this for smooth lines) + vec2 pa = p-a; + vec2 ba = b-a; + float h = clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0); + return length( pa - ba*h ); +} + +int getNumber(int time, int digit) +{ + float d = mod(float(digit), 2.); + int t = int(mod(float(time),10.0) * (1.0 - d)); + t += (time / 10) * int(d); + + return t; +} + +vec2 displayTimeWithWave(in vec2 uv, in vec2 id,in float frac) +{ + id.x -= 10.; + id.y += 4.; + vec2 rotation = vec2(0,0); + vec2 nextRotation = vec2(0,0); + float time = date ; + float nextTime = time + 1.; + + float check = 0.; + + //digits + for(int i =0; i < 3; i++){ + for(int j = 0; j < 2; j++){ + check = when_gt(id.x, -1.0) * when_lt(id.x, 4.)* when_gt(id.y, -1.0) * when_lt(id.y,8.); + + rotation += getRotation(int(id.x), int(id.y), getNumber(int(mod(time, 60.)),j)) + * check; + + nextRotation += getRotation(int(id.x), int(id.y), getNumber(int(mod(nextTime, 60.)), j)) + * check; + + id.x += 4.; + } + id.x += 2.; + time = floor(time / 60.); + nextTime = floor(nextTime / 60.); + } + + //colons + id.x -=13.; + for(int i = 0; i < 2; i++) { + check = when_gt(id.x, 0.0) * when_lt(id.x, 3.)* when_gt(id.y, 1.0) * when_lt(id.y,6.); + rotation.x += (270. + 180. * id.x) * check; + nextRotation.x += (270. + 180. * id.x) * check; + rotation.y += (0. + 180. * id.y) * check; + nextRotation.y += (0. + 180. * id.y) * check; + id.x -=10.; + } + + //reset id for animation + id = floor(uv); + + //lerp between current time and next time(time+1) + float clockLerp = clamp(mod(date * 2.,2.),0.,1.); + float h = mix(rotation.x, nextRotation.x, clockLerp); + float m = mix(rotation.y, nextRotation.y, clockLerp); + + //animate the non clock part + float animLerp = mod(id.x * .035 + id.y * .035 + frac,2.); + h += (90. + id.x * 0. - animLerp * 360. ) * (1. - clamp(rotation.x,0.,1.)); + m += (270. + id.y * 0. + animLerp * 360. ) * (1. - clamp(rotation.y,0.,1.)); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 waveAnimation(in vec2 uv, in vec2 id, in float frac) +{ + float animLerp = mod(id.x * .035 + id.y * .035 + (frac - 1.0),2.); + float h = (90. + id.x * 0. - animLerp * 360. ); + float m = (-90. + id.y * 0. + animLerp * 360. ); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 boxAnimation(in vec2 uv, in vec2 id, in float frac) +{ + vec2 rotation = vec2(0,0); + + float h = (90. + id.x * 180. + frac * 360. ); + float m = (0. - id.y * 180. + frac * 360. ); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 boxAnimation2(in vec2 uv, in vec2 id, in float frac) +{ + vec2 rotation = vec2(0,0); + + float h = (90. + id.x * 180. + frac * 360. ); + float m = (0. - id.y * 180. - frac * 360. ); + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +vec2 diamondAnimation(in vec2 uv, in vec2 id, in float frac) +{ + vec2 rotation = vec2(0,0); + + float h = 45. + clamp((frac*34.) - (abs(id.x)) - (abs(id.y)),0.,34.) * 11.25; + float m = -135. + clamp((frac*34.) - (abs(id.x)) - (abs(id.y)),0.,34.) * 11.25; + + float radianHour = radians(mod(h,360.)); + float radianMinute = radians(mod(m,360.)); + + return vec2(radianHour,radianMinute); +} + +// Animation transition code +// Lifted from Klems, https://www.shadertoy.com/view/ll2SWW +vec2 getAnimation(int fx, vec2 uv, vec2 id, float frac) +{ + vec2 value = vec2(0,0); + fx = int(mod(float(fx), NumberOfAnimations)); + if(fx == 0) value = displayTimeWithWave(uv,id,frac); + else if(fx == 1) value = boxAnimation(uv,id,frac); + else if(fx == 2) value = boxAnimation2(uv,id,frac); + else if(fx == 3) value = diamondAnimation(uv,id,frac); + else value = waveAnimation(uv,id,frac); + + return value; +} + +vec2 getFinalRotation(in vec2 uv, in vec2 id) +{ + float animationTime = 5.; + float segue = .8; + int fx = int(date / animationTime); + float frac = mod(date, animationTime)/ animationTime; + + vec2 valueA = getAnimation(fx, uv, id, frac - segue); + vec2 valueB = getAnimation(fx - 1, uv, id, (1. - segue) + frac); + + return vec2(lerpRadians(valueB.x,valueA.x,smoothstep(segue,1.0,frac)), + lerpRadians(valueB.y,valueA.y,smoothstep(segue,1.0,frac))); +} + +void main(void) +{ + vec2 uv = (gl_FragCoord.xy -.5 * resolution.xy)/resolution.y; + uv*= 22.; + + float p = 20./min(resolution.x, resolution.y); + + //draw circles + vec2 gv = fract(uv) - 0.5; + float d = length(gv); + float outerCircle = smoothstep(0.485 + p, 0.485 - p, d); + float innerCircle = smoothstep(0.445 - p, 0.445 + p, d); + vec3 col = vec3(1,1,1); + + //Get rotation + vec2 id = floor(uv); + vec2 radian = getFinalRotation(uv,id); + + //draw clock hands + col -= smoothstep(1.0-p, 1.0+p,1. - ((distanceToSegment(gv, vec2(0.),vec2(sin(radian.x),cos(radian.x))*.4) - .04))); + col -= smoothstep(1.0-p, 1.0+p,1. - ((distanceToSegment(gv, vec2(0.),vec2(sin(radian.y),cos(radian.y))*.3) - .04))); + + col -= ((innerCircle * outerCircle) * .3); + //debug + //col = vec3(radian.x/(PI*2.),0,0); + + //white border and darken + col += 2. * (1. - (when_gt(id.x, -18.0) * when_lt(id.x, 17.)* when_gt(id.y, -8.0) * when_lt(id.y,7.))); + col = clamp(col,0.,1.); + col -= .1; + + fragColor = vec4(col,texture(texture,texCoord).a); +} diff --git a/wip/Version 2.0/clockofclocks.gre b/wip/Version 2.0/clockofclocks.gre new file mode 100644 index 0000000..c365c44 --- /dev/null +++ b/wip/Version 2.0/clockofclocks.gre @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/wip/Version 2.0/colorfullsignal.frag b/wip/Version 2.0/colorfullsignal.frag new file mode 100644 index 0000000..5e3a397 --- /dev/null +++ b/wip/Version 2.0/colorfullsignal.frag @@ -0,0 +1,42 @@ +/* Adapted from https://godotshaders.com/shader/colorful-signal-effect/ +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +#define PI 3.14159265359 +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; +uniform vec2 resolution; + +uniform vec4 color_signal; +uniform float time; +uniform float size; +uniform float zoom; +uniform float speed; +uniform int RainBow; + +void main(void){ + + vec2 UV= texCoord*2.0-1.0; + UV.x*= resolution.x/resolution.y; + float d = length(UV); + float t = pow(smoothstep(0.9,0.2,d),0.35); + + // For rainbow effect, keep this line : + vec3 rainbow = 0.5 + 0.5*cos(time+UV.xyx+vec3(0,2,4)); + vec4 color= vec4(rainbow.rgb,1.0); + + if (!bool(RainBow)) + { + color = vec4(color_signal.rgb,texture(texture,texCoord).a); + } + + d = sin(zoom*d - speed*time); + d = abs(d); + d = size/d; + color *= d*t; + fragColor = vec4(color.rgb,texture(texture,texCoord).a); + +} + diff --git a/wip/Version 2.0/colorfullsignal.gre b/wip/Version 2.0/colorfullsignal.gre new file mode 100644 index 0000000..a3ea870 --- /dev/null +++ b/wip/Version 2.0/colorfullsignal.gre @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/wip/Version 2.0/digitalclock.frag b/wip/Version 2.0/digitalclock.frag new file mode 100644 index 0000000..e22c707 --- /dev/null +++ b/wip/Version 2.0/digitalclock.frag @@ -0,0 +1,190 @@ +/* Credit : https://www.shadertoy.com/view/MdfGzf + Rebuilt for enve by axiomgraph*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + + +uniform int Hours;// = 15 //min 0 max 24 +uniform int Minutes;// =0; // min 0 max 60 +uniform int Seconds;// =0; // min 0 max 60 + +uniform int AMPM;// =1;// default 24 Hours +uniform int redgreen;//=0; // default color red +uniform int microwavestyle;//=1; // default 0 +uniform int showOffLed;//=0;// default 0 + +bool showMatrix = false; +bool showOff = false; +float iTime=0.0; + +float segment(vec2 uv, bool On) +{ + if (!On && !bool(showOffLed)) + return 0.0; + + float seg = (1.0-smoothstep(0.08,0.09+float(On)*0.02,abs(uv.x)))* + (1.0-smoothstep(0.46,0.47+float(On)*0.02,abs(uv.y)+abs(uv.x))); + + //Fiddle with lights and matrix + //uv.x += sin(iTime*60.0*6.26)/14.0; + //uv.y += cos(iTime*60.0*6.26)/14.0; + + //led like brightness + if (On) + seg *= (1.0-length(uv*vec2(3.8,0.9)));//-sin(iTime*25.0*6.26)*0.04; + else + seg *= -(0.05+length(uv*vec2(0.2,0.1))); + + return seg; +} + +float sevenSegment(vec2 uv,int num) +{ + float seg= 0.0; + seg += segment(uv.yx+vec2(-1.0, 0.0),num!=-1 && num!=1 && num!=4 ); + seg += segment(uv.xy+vec2(-0.5,-0.5),num!=-1 && num!=1 && num!=2 && num!=3 && num!=7); + seg += segment(uv.xy+vec2( 0.5,-0.5),num!=-1 && num!=5 && num!=6 ); + seg += segment(uv.yx+vec2( 0.0, 0.0),num!=-1 && num!=0 && num!=1 && num!=7 ); + seg += segment(uv.xy+vec2(-0.5, 0.5),num==0 || num==2 || num==6 || num==8 ); + seg += segment(uv.xy+vec2( 0.5, 0.5),num!=-1 && num!=2 ); + seg += segment(uv.yx+vec2( 1.0, 0.0),num!=-1 && num!=1 && num!=4 && num!=7 ); + + return seg; +} + +float showNum(vec2 uv,int nr, bool zeroTrim) +{ + //Speed optimization, leave if pixel is not in segment + if (abs(uv.x)>1.5 || abs(uv.y)>1.2) + return 0.0; + + float seg= 0.0; + if (uv.x>0.0) + { + nr /= 10; + if (nr==0 && zeroTrim) + nr = -1; + seg += sevenSegment(uv+vec2(-0.75,0.0),nr); + } + else + seg += sevenSegment(uv+vec2( 0.75,0.0),int(mod(float(nr),10.0))); + + return seg; +} + +float dots(vec2 uv) +{ + float seg = 0.0; + uv.y -= 0.5; + seg += (1.0-smoothstep(0.11,0.13,length(uv))) * (1.0-length(uv)*2.0); + uv.y += 1.0; + seg += (1.0-smoothstep(0.11,0.13,length(uv))) * (1.0-length(uv)*2.0); + return seg; +} + + +void main(void) +{ + + + + vec2 uv = (gl_FragCoord.xy-0.5*resolution.xy) / + min(resolution.x,resolution.y); + + float timeOffset = 0.0; + if (resolution.x>resolution.y) + { + uv *= 6.0; + } + else + { + //uv *= 12.0; + // Many clocks with different time + zoom in on the right one + uv *= 70.0+sin(iTime*0.0628)*58.0; + + uv += vec2(5.5,2.5); + vec2 offset = vec2(floor(uv.x/11.0), + floor(uv.y/5.0 )); + if (length(offset)>0.0) + timeOffset = (offset.y*163.13+offset.x*13.23)+mod(iTime,1.0); + else + timeOffset = 0.0; + + uv.x = mod(uv.x,11.0)-5.5; + uv.y = mod(uv.y, 5.0)-2.5; + } + + uv.x *= -1.0; + uv.x += uv.y/12.0; + //wobble + //uv.x += sin(uv.y*3.0+iTime*14.0)/25.0; // wobble clock + //uv.y += cos(uv.x*3.0+iTime*14.0)/25.0; + uv.x += 3.5; + float seg = 0.0; + + + float secon = float(Seconds); //time + float minut = float(Minutes*60); + float hour = float(Hours*3600); + + float timeSecs = hour+minut+secon+timeOffset; + + seg += showNum(uv,int(mod(timeSecs,60.0)),false); + + timeSecs = floor(timeSecs/60.0); + + uv.x -= 1.75; + + seg += dots(uv); + + uv.x -= 1.75; + + seg += showNum(uv,int(mod(timeSecs,60.0)),false); + + timeSecs = floor(timeSecs/60.0); + if (bool(AMPM)) + { + if (timeSecs>12.0) + timeSecs = mod(timeSecs,12.0); + } + + uv.x -= 1.75; + + seg += dots(uv); + + uv.x -= 1.75; + seg += showNum(uv,int(mod(timeSecs,60.0)),true); + + // matrix over segment + if (bool(microwavestyle)) + { + seg *= 0.8+0.2*smoothstep(0.02,0.04,mod(uv.y+uv.x,0.06025)); + //seg *= 0.8+0.2*smoothstep(0.02,0.04,mod(uv.y-uv.x,0.06025)); + } + + if (seg<0.0) + { + seg = -seg;; + fragColor = vec4(seg,seg,seg,texture(texture,texCoord).a*seg); + } + else + if (bool(microwavestyle)) + if (bool(redgreen)) + fragColor = vec4(0.0,seg,seg*0.5,texture(texture,texCoord).a*seg); + else + fragColor = vec4(0.0,seg*0.8,seg,texture(texture,texCoord).a*seg); + else + if (bool(redgreen)) + fragColor = vec4(0.0,seg,0.0,texture(texture,texCoord).a*seg); + else + fragColor = vec4(seg,0.0,0.0,texture(texture,texCoord).a*seg); + +} + + diff --git a/wip/Version 2.0/digitalclock.gre b/wip/Version 2.0/digitalclock.gre new file mode 100644 index 0000000..eaf18f6 --- /dev/null +++ b/wip/Version 2.0/digitalclock.gre @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/wip/Version 2.0/dotconnect.frag b/wip/Version 2.0/dotconnect.frag new file mode 100644 index 0000000..e2b166c --- /dev/null +++ b/wip/Version 2.0/dotconnect.frag @@ -0,0 +1,110 @@ +/* Credit : + Rebuilt for enve by axiomgraph*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float time; +uniform vec4 color; + +float N21(vec2 p) { + p = fract(p * vec2(2.15, 8.3)); + p += dot(p, p + 2.5); + return fract(p.x * p.y); +} + +vec2 N22(vec2 p) { + float n = N21(p); + return vec2(n, N21(p + n)); +} + +vec2 getPos(vec2 id, vec2 offset) { + vec2 n = N22(id + offset); + float x = cos(time * n.x); + float y = sin(time * n.y); + return vec2(x, y) * 0.4 + offset; +} + +float distanceToLine(vec2 p, vec2 a, vec2 b) { + vec2 pa = p - a; + vec2 ba = b - a; + float t = clamp(dot(pa, ba) / dot(ba, ba), 0., 1.); + return length(pa - t * ba); +} + +float getLine(vec2 p, vec2 a, vec2 b) { + float distance = distanceToLine(p, a, b); + float dx = 15./resolution.y; + return smoothstep(dx, 0., distance) * smoothstep(1.2, 0.3, length(a - b)); +} + +float layer(vec2 st) { + float m = 0.; + vec2 gv = fract(st) - 0.5; + vec2 id = floor(st); + // m = gv.x > 0.48 || gv.y > 0.48 ? 1. : 0.; + vec2 pointPos = getPos(id, vec2(0., 0.)); + m += smoothstep(0.05, 0.03, length(gv - pointPos)); + + float dx=15./resolution.y; + // m += smoothstep(-dx,0., abs(gv.x)-.5); + // m += smoothstep(-dx,0., abs(gv.y)-.5); + // m += smoothstep(dx, 0., length(gv - pointPos)-0.03); + + vec2 p[9]; + p[0] = getPos(id, vec2(-1., -1.)); + p[1] = getPos(id, vec2(-1., 0.)); + p[2] = getPos(id, vec2(-1., 1.)); + p[3] = getPos(id, vec2( 0., -1.)); + p[4] = getPos(id, vec2( 0., 0.)); + p[5] = getPos(id, vec2( 0., 1.)); + p[6] = getPos(id, vec2( 1., -1.)); + p[7] = getPos(id, vec2( 1., 0.)); + p[8] = getPos(id, vec2( 1., 1.)); + + for (int j = 0; j <=8 ; j++) { + m += getLine(gv, p[4], p[j]); + vec2 temp = (gv - p[j]) * 100.; + m += 1./dot(temp, temp) * (sin(10. * time + fract(p[j].x) * 20.) * 0.5 + 0.5); + + } + + m += getLine(gv, p[1], p[3]); + m += getLine(gv, p[1], p[5]); + m += getLine(gv, p[3], p[7]); + m += getLine(gv, p[5], p[7]); + + // m += smoothstep(0.05, 0.04, length(st - vec2(0., 0.))); + return m; +} + +void main(void) +{ + vec2 uv = (gl_FragCoord.xy - 0.5 * resolution.xy) / resolution.y; + + float m = 0.; + + float theta = time * 0.1; + mat2 rot = mat2(cos(theta), -sin(theta), sin(theta), cos(theta)); + vec2 gradient = uv; + uv = rot * uv; + + for (float i = 0.; i < 1.0 ; i += 0.25) { + float depth = fract(i + time * 0.1); + m += layer(uv * mix(10., 0.5, depth) + i * 20.) * smoothstep(0., 0.2, depth) * smoothstep(1., 0.8, depth); + } + + vec3 baseColor = color.rgb; + + vec3 col = (m - gradient.y) * baseColor; // disable gradient in future + // Output to screen + fragColor = vec4(col, texture(texture,texCoord).a); +} + + + diff --git a/wip/Version 2.0/dotconnect.gre b/wip/Version 2.0/dotconnect.gre new file mode 100644 index 0000000..ba6e26e --- /dev/null +++ b/wip/Version 2.0/dotconnect.gre @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/wip/Version 2.0/electroniclock.frag b/wip/Version 2.0/electroniclock.frag new file mode 100644 index 0000000..a26280e --- /dev/null +++ b/wip/Version 2.0/electroniclock.frag @@ -0,0 +1,180 @@ +/* Adapted from https://www.shadertoy.com/view/ldVBDD +Rebuilt for enve/friction by axiomgraph + Opengl version 3.3*/ +#version 330 core +#define PI 3.14159 + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float hours; +uniform float minutes; +uniform float seconds; +uniform vec4 color; + +float d_seg(vec2 position, vec2 start_p, vec2 end_p, float R) +{ + vec2 AP = position - start_p; + vec2 AB = end_p - start_p; + float h = clamp(dot(AP, AB) / dot(AB, AB), 0.0, 1.0); + float seg = abs(length(AP - AB * h) - R); + return max(1.0 / seg - 1.0, 0.0); +} + +mat2 rot(float a) +{ + vec2 r = vec2(cos(a), sin(a)); + return mat2(r.x, r.y, -r.y, r.x); +} + +float get_ch_0(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + line += d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + return line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); +} + +float get_ch_1(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(2.0, 0.0), vec2(2.0, 2.0), R); + return line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 4.0), R); +} + +float get_ch_2(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_3(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_4(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_5(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_6(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_7(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + return line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); +} + +float get_ch_8(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 0.0), vec2(0.0, 2.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float get_ch_9(vec2 pos, float R) +{ + float line = d_seg(pos, vec2(0.0, 4.0), vec2(2.0, 4.0), R); + line += d_seg(pos, vec2(2.0, 4.0), vec2(2.0, 2.0), R); + line += d_seg(pos, vec2(2.0, 2.0), vec2(2.0, 0.0), R); + line += d_seg(pos, vec2(2.0, 0.0), vec2(0.0, 0.0), R); + line += d_seg(pos, vec2(0.0, 2.0), vec2(0.0, 4.0), R); + return line += d_seg(pos, vec2(0.0, 2.0), vec2(2.0, 2.0), R); +} + +float draw_num(vec2 pos, float R, int ch) +{ + float line = 0.0; + ch -= int(10.0 * floor(0.1 * float(ch))); + if (ch < 8) + if (ch < 4) + if (ch < 2) + if (ch < 1) line = get_ch_0(pos, R); + else line = get_ch_1(pos, R); + else + if (ch < 3) line = get_ch_2(pos, R); + else line = get_ch_3(pos, R); + else + if (ch < 6) + if (ch < 5) line = get_ch_4(pos, R); + else line = get_ch_5(pos, R); + else + if (ch < 7) line = get_ch_6(pos, R); + else line = get_ch_7(pos, R); + else + if (ch < 9) line = get_ch_8(pos, R); + else line = get_ch_9(pos, R); + return line; +} + +void main(void) +{ + //font size: + const float k = 0.1; + //font weight: + const float R = 0.03; + //shaking center: + const vec2 O = vec2(1.0, 2.0); + vec2 pos = (2.0 * gl_FragCoord.xy - resolution.xy ) / resolution.y; + float num[6], point[4], T[6], t[6], light = 0.0; + T[0] = 1.0; T[1] = 10.0; T[2] = 60.0; T[3] = 600.0; T[4] = 3600.0; T[5] = 36000.0; + t[0] = 10.0; t[1] = 6.0; t[2] = 10.0; t[3] = 6.0; t[4] = 24.0; t[5] = 2.4; + vec2 P[6]; + vec3 col = color.rgb * 0.1; // color + + float date = hours*3600.0+minutes*60.0+seconds; // time + + for(int i = 0; i < 6; i++) + { + P[i] = (pos - vec2(1.0 - 5.0*k * float(i), 0.0) - k*O) * rot(0.1 * sin(0.05 / (pow(0.5, float(i)) * T[i] * fract(date / T[i])) )) + k*O; + num[i] = draw_num(P[i] / k, R / k, int(mod(date / T[i], t[i]))); + light += num[i]; + } + for(int i = 0; i < 2; i++) + { + point[2*i] = max(1.0 / abs(length(pos - vec2(1.0 - (6.25 + 10.0 * float(i)) * k, 1.0 * k)) - R) - 1.0 / k, 0.0); + point[2*i+1] = max(1.0 / abs(length(pos - vec2(1.0 - (6.25 + 10.0 * float(i)) * k, 3.0 * k)) - R) - 1.0 / k, 0.0); + light += k * (point[2*i] + point[2*i+1]) * mod(floor(date), 2.0); + } + col *= light; + fragColor = vec4(col,col*texture(texture,texCoord).a); +} diff --git a/wip/Version 2.0/electroniclock.gre b/wip/Version 2.0/electroniclock.gre new file mode 100644 index 0000000..423df54 --- /dev/null +++ b/wip/Version 2.0/electroniclock.gre @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/wip/Version 2.0/hexmarching.frag b/wip/Version 2.0/hexmarching.frag new file mode 100644 index 0000000..8288594 --- /dev/null +++ b/wip/Version 2.0/hexmarching.frag @@ -0,0 +1,280 @@ +/* Credit : https://www.shadertoy.com/view/NdKyDw Hex Marching + Rebuilt for enve by axiomgraph*/ +#version 330 core + +#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a)) +#define PI 3.141592654 +#define TAU (2.0*PI) + + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; + +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float time; +uniform float BPM; +uniform float scale; + +const float planeDist = 1.0-0.2; + +// License: WTFPL, author: sam hocevar, found: https://stackoverflow.com/a/17897228/418488 +const vec4 hsv2rgb_K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); +vec3 hsv2rgb(vec3 c) { + vec3 p = abs(fract(c.xxx + hsv2rgb_K.xyz) * 6.0 - hsv2rgb_K.www); + return c.z * mix(hsv2rgb_K.xxx, clamp(p - hsv2rgb_K.xxx, 0.0, 1.0), c.y); +} +// License: WTFPL, author: sam hocevar, found: https://stackoverflow.com/a/17897228/418488 +// Macro version of above to enable compile-time constants +#define HSV2RGB(c) (c.z * mix(hsv2rgb_K.xxx, clamp(abs(fract(c.xxx + hsv2rgb_K.xyz) * 6.0 - hsv2rgb_K.www) - hsv2rgb_K.xxx, 0.0, 1.0), c.y)) + + +// License: Unknown, author: Unknown, found: don't remember +vec4 alphaBlend(vec4 back, vec4 front) { + float w = front.w + back.w*(1.0-front.w); + vec3 xyz = (front.xyz*front.w + back.xyz*back.w*(1.0-front.w))/w; + return w > 0.0 ? vec4(xyz, w) : vec4(0.0); +} + +// License: Unknown, author: Unknown, found: don't remember +vec3 alphaBlend(vec3 back, vec4 front) { + return mix(back, front.xyz, front.w); +} + +// License: Unknown, author: Unknown, found: don't remember +float tanh_approx(float x) { + // Found this somewhere on the interwebs + // return tanh(x); + float x2 = x*x; + return clamp(x*(27.0 + x2)/(27.0+9.0*x2), -1.0, 1.0); +} + +// License: Unknown, author: Unknown, found: don't remember +float hash(float co) { + return fract(sin(co*12.9898) * 13758.5453); +} + +vec3 offset(float z) { + float a = z; + vec2 p = -0.15*(vec2(cos(a), sin(a*sqrt(2.0))) + vec2(cos(a*sqrt(0.75)), sin(a*sqrt(0.5)))); + return vec3(p, z); +} + +vec3 doffset(float z) { + float eps = 0.05; + return 0.5*(offset(z + eps) - offset(z - eps))/(2.0*eps); +} + +vec3 ddoffset(float z) { + float eps = 0.05; + return 0.5*(doffset(z + eps) - doffset(z - eps))/(2.0*eps); +} + +// License: CC0, author: Mårten Rånge, found: https://github.com/mrange/glsl-snippets +vec2 toPolar(vec2 p) { + return vec2(length(p), atan(p.y, p.x)); +} + +// License: CC0, author: Mårten Rånge, found: https://github.com/mrange/glsl-snippets +vec2 toRect(vec2 p) { + return vec2(p.x*cos(p.y), p.x*sin(p.y)); +} + +// License: MIT OR CC-BY-NC-4.0, author: mercury, found: https://mercury.sexy/hg_sdf/ +float mod1(inout float p, float size) { + float halfsize = size*0.5; + float c = floor((p + halfsize)/size); + p = mod(p + halfsize, size) - halfsize; + return c; +} + +vec2 hextile(inout vec2 p) { + // See Art of Code: Hexagonal Tiling Explained! + // https://www.youtube.com/watch?v=VmrIDyYiJBA + const vec2 sz = vec2(1.0, sqrt(3.0)); + const vec2 hsz = 0.5*sz; + + vec2 p1 = mod(p, sz)-hsz; + vec2 p2 = mod(p - hsz, sz)-hsz; + vec2 p3 = dot(p1, p1) < dot(p2, p2) ? p1 : p2; + vec2 n = ((p3 - p + hsz)/sz); + p = p3; + + n -= vec2(0.5); + // Rounding to make hextile 0,0 well behaved + return round(n*2.0)*0.5; +} + +vec4 effect(vec2 p, float aa, float h) { + vec2 hhn = hextile(p); + const float w = 0.02; + vec2 pp = toPolar(p); + float a = pp.y; + float hn = mod1(pp.y, TAU/6.0); + vec2 hp = toRect(pp); + float hd = hp.x-(w*10.0); + + float x = hp.x-0.5*w; + float n = mod1(x, w); + float d = abs(x)-(0.5*w-aa); + + float h0 = hash(10.0*(hhn.x+hhn.y)+2.0*h+n); + float h1 = fract(8667.0*h0); + float cut = mix(-0.5, 0.999, 0.5+0.5*sin(time+TAU*h0)); + const float coln = 6.0; + float t = smoothstep(aa, -aa, d)*smoothstep(cut, cut-0.005, sin(a+2.0*(h1-0.5)*time+h1*TAU))*exp(-150.0*abs(x)); + vec3 col = hsv2rgb(vec3(floor(h0*coln)/coln, 0.8, 1.0))*t*1.75; + + t = mix(0.9, 1.0, t); + t *= smoothstep(aa, -aa, -hd); + if (hd < 0.0) { + col = vec3(0.0); + t = 15.*dot(p, p); + } + return vec4(col, t); +} + +vec4 plane(vec3 ro, vec3 rd, vec3 pp, vec3 npp, vec3 off, float n) { + float h0 = hash(n); + float h1 = fract(8667.0*h0); + + vec3 hn; + vec2 p = (pp-off*vec3(1.0, 1.0, 0.0)).xy; + p *= ROT(TAU*h0); + p.x -= 0.25*h1*(pp.z-ro.z); + const float z = 1.0; + p /= z; + float aa = distance(pp,npp)*sqrt(1.0/3.0)/z; + vec4 col = effect(p, aa, h1); + + return col; +} + +vec3 skyColor(vec3 ro, vec3 rd) { + return vec3(0.0); +} + +vec3 color(vec3 ww, vec3 uu, vec3 vv, vec3 ro, vec2 p) { + float lp = length(p); + vec2 np = p + 2.0/resolution.y; + float rdd = (scale-0.5*tanh_approx(lp)); // Playing around with rdd can give interesting distortions +// float rdd = 2.; + + vec3 rd = normalize(p.x*uu + p.y*vv + rdd*ww); + vec3 nrd = normalize(np.x*uu + np.y*vv + rdd*ww); + + const int furthest = 5; + const int fadeFrom = max(furthest-2, 0); + + const float fadeDist = planeDist*float(furthest - fadeFrom); + float nz = floor(ro.z / planeDist); + + vec3 skyCol = skyColor(ro, rd); + + + vec4 acol = vec4(0.0); + const float cutOff = 0.95; + bool cutOut = false; + + float maxpd = 0.0; + + // Steps from nearest to furthest plane and accumulates the color + for (int i = 1; i <= furthest; ++i) { + float pz = planeDist*nz + planeDist*float(i); + + float pd = (pz - ro.z)/rd.z; + + if (pd > 0.0 && acol.w < cutOff) { + vec3 pp = ro + rd*pd; + maxpd = pd; + vec3 npp = ro + nrd*pd; + + vec3 off = offset(pp.z); + + vec4 pcol = plane(ro, rd, pp, npp, off, nz+float(i)); + + float nz = pp.z-ro.z; + float fadeIn = smoothstep(planeDist*float(furthest), planeDist*float(fadeFrom), nz); + float fadeOut = smoothstep(0.0, planeDist*0.1, nz); +// pcol.xyz = mix(skyCol, pcol.xyz, fadeIn); + pcol.w *= fadeOut*fadeIn; + pcol = clamp(pcol, 0.0, 1.0); + + acol = alphaBlend(pcol, acol); + } else { + cutOut = true; + acol.w = acol.w > cutOff ? 1.0 : acol.w; + break; + } + + } + + vec3 col = alphaBlend(skyCol, acol); +// To debug cutouts due to transparency +// col += cutOut ? vec3(1.0, -1.0, 0.0) : vec3(0.0); + return col; +} + +vec3 effect(vec2 p, vec2 q) { + float tm = planeDist*time*BPM/60.0; + vec3 ro = offset(tm); + vec3 dro = doffset(tm); + vec3 ddro = ddoffset(tm); + + vec3 ww = normalize(dro); + vec3 uu = normalize(cross(normalize(vec3(0.0,1.0,0.0)+ddro), ww)); + vec3 vv = cross(ww, uu); + + vec3 col = color(ww, uu, vv, ro, p); + + return col; +} + + +const mat2 brot = ROT(2.399); +// simplyfied version of Dave Hoskins blur +vec3 dblur(vec2 q,float rad) { + vec3 acc=vec3(0); + const float m = 0.002; + vec2 pixel=vec2(m*resolution.y/resolution.x,m); + vec2 angle=vec2(0,rad); + rad=1.; + const int iter = 30; + for (int j=0; j + + + + + + + + + + diff --git a/wip/Version 2.0/octagrams.frag b/wip/Version 2.0/octagrams.frag new file mode 100644 index 0000000..40cbe17 --- /dev/null +++ b/wip/Version 2.0/octagrams.frag @@ -0,0 +1,104 @@ +/* Adapted from https://www.shadertoy.com/view/tlVGDt +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +#define PI 3.14159265359 +precision highp float; +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; +uniform vec2 resolution; + +uniform float time; + +float gTime = 0.; +const float REPEAT = 5.0; + +mat2 rot(float a) { + float c = cos(a), s = sin(a); + return mat2(c,s,-s,c); +} + +float sdBox( vec3 p, vec3 b ) +{ + vec3 q = abs(p) - b; + return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); +} + +float box(vec3 pos, float scale) { + pos *= scale; + float base = sdBox(pos, vec3(.4,.4,.1)) /1.5; + pos.xy *= 5.; + pos.y -= 3.5; + pos.xy *= rot(.75); + float result = -base; + return result; +} + +float box_set(vec3 pos, float time) { + vec3 pos_origin = pos; + pos = pos_origin; + pos .y += sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box1 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos .y -=sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box2 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos .x +=sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box3 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos .x -=sin(gTime * 0.4) * 2.5; + pos.xy *= rot(.8); + float box4 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5); + pos = pos_origin; + pos.xy *= rot(.8); + float box5 = box(pos,.5) * 6.; + pos = pos_origin; + float box6 = box(pos,.5) * 6.; + float result = max(max(max(max(max(box1,box2),box3),box4),box5),box6); + return result; +} + +float map(vec3 pos, float time) { + vec3 pos_origin = pos; + float box_set1 = box_set(pos, time); + + return box_set1; +} + + +void main(void) { + vec2 p = (gl_FragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y); + vec3 ro = vec3(0., -0.2 ,time * 4.); + vec3 ray = normalize(vec3(p, 1.5)); + ray.xy = ray.xy * rot(sin(time * .03) * 5.); + ray.yz = ray.yz * rot(sin(time * .05) * .2); + float t = 0.1; + vec3 col = vec3(0.); + float ac = 0.0; + + + for (int i = 0; i < 99; i++){ + vec3 pos = ro + ray * t; + pos = mod(pos-2., 4.) -2.; + gTime = time -float(i) * 0.01; + + float d = map(pos, time); + + d = max(abs(d), 0.01); + ac += exp(-d*23.); + + t += d* 0.55; + } + + col = vec3(ac * 0.02); + + col +=vec3(0.,0.2 * abs(sin(time)),0.5 + sin(time) * 0.2); + + + fragColor = vec4(col ,texture(texture,texCoord).a - t * (0.02 + 0.02 * sin (time))); +} diff --git a/wip/Version 2.0/octagrams.gre b/wip/Version 2.0/octagrams.gre new file mode 100644 index 0000000..ffea9ac --- /dev/null +++ b/wip/Version 2.0/octagrams.gre @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/wip/Version 2.0/perlintransition.frag b/wip/Version 2.0/perlintransition.frag new file mode 100644 index 0000000..032f8d7 --- /dev/null +++ b/wip/Version 2.0/perlintransition.frag @@ -0,0 +1,84 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/perlin.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +#ifdef GL_ES +precision highp float; +#endif + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + +uniform float progress; + +uniform float scale; +uniform float smoothness ; +uniform float seed ; + + // http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/ +float random(vec2 co) +{ + float a = seed; + float b = 78.233; + float c = 43758.5453; + float dt= dot(co.xy ,vec2(a,b)); + float sn= mod(dt,3.14); + return fract(sin(sn) * c); +} + +// 2D Noise based on Morgan McGuire @morgan3d +// https://www.shadertoy.com/view/4dS3Wd +float noise (in vec2 st) { + vec2 i = floor(st); + vec2 f = fract(st); + + // Four corners in 2D of a tile + float a = random(i); + float b = random(i + vec2(1.0, 0.0)); + float c = random(i + vec2(0.0, 1.0)); + float d = random(i + vec2(1.0, 1.0)); + + // Smooth Interpolation + + // Cubic Hermine Curve. Same as SmoothStep() + vec2 u = f*f*(3.0-2.0*f); + // u = smoothstep(0.,1.,f); + + // Mix 4 coorners porcentages + return mix(a, b, u.x) + + (c - a)* u.y * (1.0 - u.x) + + (d - b) * u.x * u.y; +} + +vec4 transition (vec2 uv) { + float ar = resolution.x/resolution.y; // aspect ratio + vec4 from = texture(texture,uv); + vec4 to = vec4(0.0); // for future use + uv.x*= ar ; // aspect ratio + float n = noise(uv * scale); + + float p = mix(-smoothness, 1.0 + smoothness, progress); + float lower = p - smoothness; + float higher = p + smoothness; + + float q = smoothstep(lower, higher, n); + + return mix( + from, + to, + 1.0 - q + ); +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + // vec2 uv = gl_FragCoord.xy/resolution.xy; + // Output to screen + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/perlintransition.gre b/wip/Version 2.0/perlintransition.gre new file mode 100644 index 0000000..2530fd8 --- /dev/null +++ b/wip/Version 2.0/perlintransition.gre @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/wip/Version 2.0/radialwipe.frag b/wip/Version 2.0/radialwipe.frag new file mode 100644 index 0000000..26a4eac --- /dev/null +++ b/wip/Version 2.0/radialwipe.frag @@ -0,0 +1,34 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/Radial.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +in vec2 texCoord; + +uniform vec2 resolution; + +uniform float progress; +uniform float feather; + +const float PI = 3.141592653589; + +vec4 transition(vec2 p, vec2 uv) { + float ar = resolution.x/resolution.y; + p.x*=ar; + vec2 rp = p ; + p.x/=ar; + return mix( + vec4(0.0), + texture(texture,uv), + smoothstep(0., feather, atan(rp.y ,rp.x) - (progress-.5) * PI * 2.5) + ); +} +void main(void) +{ +vec2 uv = texCoord; + fragColor = transition(texCoord *2.0-1.0, uv); +} + diff --git a/wip/Version 2.0/radialwipe.gre b/wip/Version 2.0/radialwipe.gre new file mode 100644 index 0000000..30a4b8f --- /dev/null +++ b/wip/Version 2.0/radialwipe.gre @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/wip/Version 2.0/simplergbwaveform.frag b/wip/Version 2.0/simplergbwaveform.frag new file mode 100644 index 0000000..4d5a2ba --- /dev/null +++ b/wip/Version 2.0/simplergbwaveform.frag @@ -0,0 +1,43 @@ +/* Adapted from https://www.shadertoy.com/view/4dK3Wc +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +//#define HIGH_QUALITY + +#ifndef HIGH_QUALITY +const int hres = 200; +const float intensity = 0.04; +const float thres = 0.004; +#else +const int hres = 800; +const float intensity = 0.03; +const float thres = 0.001; +#endif + +void main( void ) +{ + vec2 uv = gl_FragCoord.xy / resolution.xy; + vec3 col = vec3(0); + float s = uv.y*1.8 - 0.15; + float maxb = s+thres; + float minb = s-thres; + + for (int i = 0; i <= hres; i++) { + vec3 x = texture(texture, vec2(float(i)/float(hres), uv.x)).rgb; + col += vec3(intensity)*step(x, vec3(maxb))*step(vec3(minb), x); + + float l = dot(x, x); + col += vec3(intensity)*step(l, maxb*maxb)*step(minb*minb, l); + } + + fragColor = vec4(col,texture(texture,texCoord)); +} diff --git a/wip/Version 2.0/simplergbwaveform.gre b/wip/Version 2.0/simplergbwaveform.gre new file mode 100644 index 0000000..6abd15b --- /dev/null +++ b/wip/Version 2.0/simplergbwaveform.gre @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/wip/Version 2.0/synthwave.frag b/wip/Version 2.0/synthwave.frag new file mode 100644 index 0000000..00bb214 --- /dev/null +++ b/wip/Version 2.0/synthwave.frag @@ -0,0 +1,258 @@ +/* credit : https://www.shadertoy.com/view/tsScRK + Rebuilt for enve by axiomgraph +*/ +#version 330 core +//#define VAPORWAVE +//#define AA 2 +//#define stereo +//#define wave_thing +//#define city for future use +#define PI 3.14159265359 + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + + +uniform float speed; +uniform float iTime; +uniform float iTimeDelta; + + + +float jTime; + + + +// vec4 textureMirror(sampler2D tex, vec2 c){ +// vec2 cf = fract(c); +// return texture(tex,mix(cf,1.-cf,mod(floor(c),2.))); +//} + + + +float amp(vec2 p){ + return smoothstep(1.,8.,abs(p.x)); +} + +float pow512(float a){ + a*=a;//^2 + a*=a;//^4 + a*=a;//^8 + a*=a;//^16 + a*=a;//^32 + a*=a;//^64 + a*=a;//^128 + a*=a;//^256 + return a*a; +} +float pow1d5(float a){ + return a*sqrt(a); +} +float hash21(vec2 co){ + return fract(sin(dot(co.xy,vec2(1.9898,7.233)))*45758.5433); +} +float hash(vec2 uv){ + float a = amp(uv); + #ifdef wave_thing + float w = a>0.?(1.-.4*pow512(.51+.49*sin((.02*(uv.y+.5*uv.x)-jTime)*2.))):0.; + #else + float w=1.; + #endif + return (a>0.? + a*pow1d5( + //texture(iChannel0,uv/iChannelResolution[0].xy).r + hash21(uv) + )*w + :0.)-(0.0); +} + +float edgeMin(float dx,vec2 da, vec2 db,vec2 uv){ + uv.x+=5.; + vec3 c = fract((round(vec3(uv,uv.x+uv.y)))*(vec3(0,1,2)+0.61803398875)); + float a1 = 0.0>.6?.15:1.; // 0.0 for future edit + float a2 = 0.0>.6?.15:1.; // 0.0 for future edit + float a3 = 0.0>.6?.15:1.; // 0.0 for future edit + + return min(min((1.-dx)*db.y*a3,da.x*a2),da.y*a1); +} + +vec2 trinoise(vec2 uv){ + const float sq = sqrt(3./2.); + uv.x *= sq; + uv.y -= .5*uv.x; + vec2 d = fract(uv); + uv -= d; + + bool c = dot(d,vec2(1))>1.; + + vec2 dd = 1.-d; + vec2 da = c?dd:d,db = c?d:dd; + + float nn = hash(uv+float(c)); + float n2 = hash(uv+vec2(1,0)); + float n3 = hash(uv+vec2(0,1)); + + + float nmid = mix(n2,n3,d.y); + float ns = mix(nn,c?n2:n3,da.y); + float dx = da.x/db.y; + return vec2(mix(ns,nmid,dx),edgeMin(dx,da, db,uv+d)); +} + + +vec2 map(vec3 p){ + vec2 n = trinoise(p.xz); + return vec2(p.y-2.*n.x,n.y); +} + +vec3 grad(vec3 p){ + const vec2 e = vec2(.005,0); + float a =map(p).x; + return vec3(map(p+e.xyy).x-a + ,map(p+e.yxy).x-a + ,map(p+e.yyx).x-a)/e.x; +} + +vec2 intersect(vec3 ro,vec3 rd){ + float d =0.,h=0.; + for(int i = 0;i<500;i++){ //look nice with 50 iterations + vec3 p = ro+d*rd; + vec2 s = map(p); + h = s.x; + d+= h*.5; + if(abs(h)<.003*d) + return vec2(d,s.y); + if(d>150.|| p.y>2.) break; + } + + return vec2(-1); +} + + +void addsun(vec3 rd,vec3 ld,inout vec3 col){ + + float sun = smoothstep(.21,.2,distance(rd,ld)); + + if(sun>0.){ + float yd = (rd.y-ld.y); + + float a =sin(3.1*exp(-(yd)*14.)); + + sun*=smoothstep(-.8,0.,a); + + col = mix(col,vec3(1.,.8,.4)*.75,sun); + } +} + + +float starnoise(vec3 rd){ + float c = 0.; + vec3 p = normalize(rd)*300.; + for (float i=0.;i<4.;i++) + { + vec3 q = fract(p)-.5; + vec3 id = floor(p); + float c2 = smoothstep(.5,0.,length(q)); + c2 *= step(hash21(id.xz/id.y),.06-i*i*0.005); + c += c2; + p = p*.6+.5*p*mat3(3./5.,0,4./5.,0,1,0,-4./5.,0,3./5.); + } + c*=c; + float g = dot(sin(rd*10.512),cos(rd.yzx*10.512)); + c*=smoothstep(-3.14,-.9,g)*.5+.5*smoothstep(-.3,1.,g); + return c*c; +} + +vec3 gsky(vec3 rd,vec3 ld,bool mask){ + float haze = exp2(-5.*(abs(rd.y)-.2*dot(rd,ld))); + + + //float st = mask?pow512(texture(iChannel0,(rd.xy+vec2(300.1,100)*rd.z)*10.).r)*(1.-min(haze,1.)):0.; + //float st = mask?pow512(hash21((rd.xy+vec2(300.1,100)*rd.z)*10.))*(1.-min(haze,1.)):0.; + float st = mask?(starnoise(rd))*(1.-min(haze,1.)):0.; + vec3 back = vec3(.4,.1,.7)*(1.-.5*0.0 // 0.0 for future edit + *exp2(-.1*abs(length(rd.xz)/rd.y)) + *max(sign(rd.y),0.)); + #ifdef city + float x = round(rd.x*30.); + float h = hash21(vec2(x-166.)); + bool building = (h*h*.125*exp2(-x*x*x*x*.0025)>rd.y); + if(mask && building) + back*=0.,haze=.8, mask=mask && !building; + #endif + vec3 col=clamp(mix(back,vec3(.7,.1,.4),haze)+st,0.,1.); + if(mask)addsun(rd,ld,col); + return col; +} + + +void main(void) +{ + fragColor=vec4(0); + #ifdef AA + for(float x = 0.;x<1.;x+=1./float(AA)){ + for(float y = 0.;y<1.;y+=1./float(AA)){ + #else + const float AA=1.,x=0.,y=0.; + #endif + vec2 uv = (2.*(gl_FragCoord.xy+vec2(x,y))-resolution.xy)/resolution.y; + + //float dt = fract(texture(iChannel0,float(AA)*(fragCoord+vec2(x,y))/iChannelResolution[0].xy).r+iTime); + float dt = fract(hash21(float(AA)*(gl_FragCoord.xy+vec2(x,y)))+iTime); + jTime = mod(iTime-dt*iTimeDelta*.25,4000.); + vec3 ro = vec3(0.,1,(-20000.+jTime*speed)); + + #ifdef stereo + ro+=vec3(.2*(float(uv.x>0.)-.5),0.,0.); //-= for x-view + const float de = .9; + uv.x=uv.x+.5*(uv.x>0.?-de:de); + uv*=2.; + #endif + + vec3 rd = normalize(vec3(uv,4./3.));//vec3(uv,sqrt(1.-dot(uv,uv))); + + vec2 i = intersect(ro,rd); + float d = i.x; + + vec3 ld = normalize(vec3(0,.125+.05*sin(.1*jTime),1)); + + vec3 fog = d>0.?exp2(-d*vec3(.14,.1,.28)):vec3(0.); + vec3 sky = gsky(rd,ld,d<0.); + + vec3 p = ro+d*rd; + vec3 n = normalize(grad(p)); + + float diff = dot(n,ld)+.1*n.y; + vec3 col = vec3(.1,.11,.18)*diff; + + vec3 rfd = reflect(rd,n); + vec3 rfcol = gsky(rfd,ld,true); + + col = mix(col,rfcol,.05+.95*pow(max(1.+dot(rd,n),0.),5.)); + #ifdef VAPORWAVE + col = mix(col,vec3(.4,.5,1.),smoothstep(.05,.0,i.y)); + col = mix(sky,col,fog); + col = sqrt(col); + #else + col = mix(col,vec3(.8,.1,.92),smoothstep(.05,.0,i.y)); + col = mix(sky,col,fog); + //no gamma for that old cg look + #endif + if(d<0.) + d=1e6; + d=min(d,10.); + fragColor += vec4(clamp(col,0.,1.0),d<0.?0.:.1+exp2(-d)); + fragColor = vec4(fragColor.rgb,texture(texture,texCoord).a); + #ifdef AA + } + } + fragColor/=float(AA*AA); + #endif +} + + diff --git a/wip/Version 2.0/synthwave.gre b/wip/Version 2.0/synthwave.gre new file mode 100644 index 0000000..ad97939 --- /dev/null +++ b/wip/Version 2.0/synthwave.gre @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/wip/Version 2.0/tubeclock.frag b/wip/Version 2.0/tubeclock.frag new file mode 100644 index 0000000..6839f5b --- /dev/null +++ b/wip/Version 2.0/tubeclock.frag @@ -0,0 +1,305 @@ +/* Adapted from https://www.shadertoy.com/view/Dds3WB +Rebuilt for enve by axiomgraph + Opengl version 3.3*/ +#version 330 core + + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform int hours; //24 +uniform int minutes;//60 +uniform vec4 colour; +uniform float time; + +// boolean input +uniform int TWELVE_HOUR; +uniform int glow; +uniform int shgrid; + +bool TWELVE_HOUR_CLOCK = bool(TWELVE_HOUR); +bool GLOWPULSE = bool(glow); +bool SHOW_GRID = bool(shgrid); + + + +float pi = atan(1.0)*4.0; +float tau = atan(1.0)*8.0; + +const float scale = 1.0 / 6.0; + +vec2 digitSize = vec2(1.0,1.5) * scale; +vec2 digitSpacing = vec2(1.1,1.6) * scale; + + + +// hash function copy from https://www.shadertoy.com/view/4djSRW +float hash12(vec2 p) +{ + vec3 p3 = fract(vec3(p.xyx) * .1031); + p3 += dot(p3, p3.yzx + 33.33); + return fract((p3.x + p3.y) * p3.z); +} + + +float noise(vec2 pos) { + vec2 i = floor(pos); + vec2 f = fract(pos); + + float a = hash12(i); + float b = hash12(i + vec2(1, 0)); + float c = hash12(i + vec2(0, 1)); + float d = hash12(i + vec2(1, 1)); + + vec2 u = f * f * (3.0 - 2.0 * f); + + return mix(mix(a, b, u.x), mix(c, d, u.x), u.y); +} + +//Distance to a line segment, +float dfLine(vec2 start, vec2 end, vec2 uv) +{ + start *= scale; + end *= scale; + + vec2 line = end - start; + float frac = dot(uv - start,line) / dot(line,line); + return distance(start + line * clamp(frac, 0.0, 1.0), uv); +} + +//Distance to the edge of a circle. +float dfCircle(vec2 origin, float radius, vec2 uv) +{ + origin *= scale; + radius *= scale; + + return abs(length(uv - origin) - radius); +} + +//Distance to an arc. +float dfArc(vec2 origin, float start, float sweep, float radius, vec2 uv) +{ + origin *= scale; + radius *= scale; + + uv -= origin; + uv *= mat2(cos(start), sin(start),-sin(start), cos(start)); + + float offs = (sweep / 2.0 - pi); + float ang = mod(atan(uv.y, uv.x) - offs, tau) + offs; + ang = clamp(ang, min(0.0, sweep), max(0.0, sweep)); + + return distance(radius * vec2(cos(ang), sin(ang)), uv); +} + +//Distance to the digit "d" (0-9). +float dfDigit(vec2 origin, float d, vec2 uv) +{ + uv -= origin; + d = floor(d); + float dist = 1e6; + + if(d == 0.0) + { + dist = min(dist, dfLine(vec2(1.000,1.000), vec2(1.000,0.500), uv)); + dist = min(dist, dfLine(vec2(0.000,1.000), vec2(0.000,0.500), uv)); + dist = min(dist, dfArc(vec2(0.500,1.000),0.000, 3.142, 0.500, uv)); + dist = min(dist, dfArc(vec2(0.500,0.500),3.142, 3.142, 0.500, uv)); + return dist; + } + if(d == 1.0) + { + dist = min(dist, dfLine(vec2(0.500,1.500), vec2(0.500,0.000), uv)); + return dist; + } + if(d == 2.0) + { + dist = min(dist, dfLine(vec2(1.000,0.000), vec2(0.000,0.000), uv)); + dist = min(dist, dfLine(vec2(0.388,0.561), vec2(0.806,0.719), uv)); + dist = min(dist, dfArc(vec2(0.500,1.000),0.000, 3.142, 0.500, uv)); + dist = min(dist, dfArc(vec2(0.700,1.000),5.074, 1.209, 0.300, uv)); + dist = min(dist, dfArc(vec2(0.600,0.000),1.932, 1.209, 0.600, uv)); + return dist; + } + if(d == 3.0) + { + dist = min(dist, dfLine(vec2(0.000,1.500), vec2(1.000,1.500), uv)); + dist = min(dist, dfLine(vec2(1.000,1.500), vec2(0.500,1.000), uv)); + dist = min(dist, dfArc(vec2(0.500,0.500),3.142, 4.712, 0.500, uv)); + return dist; + } + if(d == 4.0) + { + dist = min(dist, dfLine(vec2(0.700,1.500), vec2(0.000,0.500), uv)); + dist = min(dist, dfLine(vec2(0.000,0.500), vec2(1.000,0.500), uv)); + dist = min(dist, dfLine(vec2(0.700,1.200), vec2(0.700,0.000), uv)); + return dist; + } + if(d == 5.0) + { + dist = min(dist, dfLine(vec2(1.000,1.500), vec2(0.300,1.500), uv)); + dist = min(dist, dfLine(vec2(0.300,1.500), vec2(0.200,0.900), uv)); + dist = min(dist, dfArc(vec2(0.500,0.500),3.142, 5.356, 0.500, uv)); + return dist; + } + if(d == 6.0) + { + dist = min(dist, dfLine(vec2(0.067,0.750), vec2(0.500,1.500), uv)); + dist = min(dist, dfCircle(vec2(0.500,0.500), 0.500, uv)); + return dist; + } + if(d == 7.0) + { + dist = min(dist, dfLine(vec2(0.000,1.500), vec2(1.000,1.500), uv)); + dist = min(dist, dfLine(vec2(1.000,1.500), vec2(0.500,0.000), uv)); + return dist; + } + if(d == 8.0) + { + dist = min(dist, dfCircle(vec2(0.500,0.400), 0.400, uv)); + dist = min(dist, dfCircle(vec2(0.500,1.150), 0.350, uv)); + return dist; + } + if(d == 9.0) + { + dist = min(dist, dfLine(vec2(0.933,0.750), vec2(0.500,0.000), uv)); + dist = min(dist, dfCircle(vec2(0.500,1.000), 0.500, uv)); + return dist; + } + + return dist; +} + +//Distance to a number +float dfNumber(vec2 origin, float num, vec2 uv) +{ + uv -= origin; + float dist = 1e6; + float offs = 0.0; + + for(float i = 5.0;i > -3.0;i--) + { + float d = mod(num / pow(10.0,i),10.0); + + vec2 pos = digitSpacing * vec2(offs,0.0); + + if(i == 0.0) + { + dist = min(dist, dfCircle(vec2(offs+0.9,0.1)*1.1, 0.04,uv)); + } + + if(num > pow(10.0,i) || i == 0.0) + { + dist = min(dist, dfDigit(pos, d, uv)); + offs++; + } + } + return dist; +} + +//Distance to a number This handles 2 digit integers, leading 0's will be drawn +float dfNumberInt(vec2 origin, int inum, vec2 uv) +{ + float num = float(inum); + uv -= origin; + float dist = 1e6; + float offs = 0.0; + + for(float i = 1.0;i >= 0.0;i--) + { + float d = mod(num / pow(10.0,i),10.0); + + vec2 pos = digitSpacing * vec2(offs,0.0); + + dist = min(dist, dfDigit(pos, d, uv)); + offs++; + } + return dist; +} + +float dfColon(vec2 origin, vec2 uv) { + uv -= origin; + float dist = 1e6; + float offs = 0.0; + + dist = min(dist, dfCircle(vec2(offs+0.9,0.9)*1.1, 0.04,uv)); + dist = min(dist, dfCircle(vec2(offs+0.9,0.4)*1.1, 0.04,uv)); + return dist; +} + +//Length of a number in digits +float numberLength(float n) +{ + return floor(max(log(n) / log(10.0), 0.0) + 1.0) + 2.0; +} + +void main(void) +{ + // Test outside the circle for round watches + /*vec2 uvTest = (gl_FragCoord.xy-.5*iResolution.xy)/iResolution.y; + + float absX = uvTest.x*uvTest.x; + float absY = uvTest.y*uvTest.y; + if(sqrt(absX + absY) >0.5) { + fragColor = vec4(0.1); + return; + }*/ + // end test + + vec2 aspect = resolution.xy / resolution.y; + vec2 uv = (gl_FragCoord.xy / resolution.y - aspect/2.0) *0.86; + + + int hour = hours; + +if (TWELVE_HOUR_CLOCK) { + + if( hour > 12 ) hour -= 12; + if( hour == 0 ) hour = 12; } + + + int minute = int(mod(float(minutes*60)/60.,60.)); + + float nsize = numberLength(9999.); + vec2 pos = -digitSpacing * vec2(nsize,1.0)/2.0; + + vec2 basepos = pos; + pos.x = basepos.x + 0.16; + float dist = 1e6; + dist = min(dist, dfNumberInt(pos, hour, uv)); + + pos.x = basepos.x + 0.39; + dist = min(dist, dfColon( pos, uv )); + + pos.x = basepos.x + 0.60; + float dist2 = 1e6; + dist = min(dist, dfNumberInt(pos, minute, uv)); + + vec3 color = vec3(0); + + float shade = 0.0; + + shade = 0.004 / (dist); + + + // color of lights + color += colour.rgb* shade; +if (GLOWPULSE){ + color += colour.rgb* shade * noise((uv + vec2(time*.5)) * 2.5 + .5);// * 10.*(noise(uv.yx)); +} + + if (SHOW_GRID){ + float grid = 0.5-max(abs(mod(uv.x*64.0,1.0)-0.5), abs(mod(uv.y*64.0,1.0)-0.5)); + + color *= 0.25+vec3(smoothstep(0.0,64.0 / resolution.y,grid))*0.75; + } + + fragColor = vec4( color , color* texture(texture,texCoord).a ); +} + + diff --git a/wip/Version 2.0/tubeclock.gre b/wip/Version 2.0/tubeclock.gre new file mode 100644 index 0000000..21eac6e --- /dev/null +++ b/wip/Version 2.0/tubeclock.gre @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/wip/Version 2.0/undulatingBurnOut.frag b/wip/Version 2.0/undulatingBurnOut.frag new file mode 100644 index 0000000..04da418 --- /dev/null +++ b/wip/Version 2.0/undulatingBurnOut.frag @@ -0,0 +1,70 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/undulatingBurnOut.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; +uniform vec2 resolution; +in vec2 texCoord; + + +uniform float smoothness; +uniform vec2 center; +uniform vec4 color; +uniform float progress; + + +const float M_PI = 3.14159265358979323846; + +float quadraticInOut(float t) { + float p = 2.0 * t * t; + return t < 0.5 ? p : -p + (4.0 * t) - 1.0; +} + +float getGradient(float r, float dist) { + float d = r - dist; + return mix( + smoothstep(-smoothness, 0.0, r - dist * (1.0 + smoothness)), + -1.0 - step(0.005, d), + step(-0.005, d) * step(d, 0.01) + ); +} + +float getWave(vec2 p){ + vec2 _p = p - center; // offset from center + float rads = atan(_p.y, _p.x); + float degs = degrees(rads) + 180.0; + vec2 range = vec2(0.0, M_PI * 30.0); + vec2 domain = vec2(0.0, 360.0); + float ratio = (M_PI * 30.0) / 360.0; + degs = degs * ratio; + float x = progress; + float magnitude = mix(0.02, 0.09, smoothstep(0.0, 1.0, x)); + float offset = mix(40.0, 30.0, smoothstep(0.0, 1.0, x)); + float ease_degs = quadraticInOut(sin(degs)); + float deg_wave_pos = (ease_degs * magnitude) * sin(x * offset); + return x + deg_wave_pos; +} + +vec4 transition(vec2 p) { + float dist = distance(center, p); + float m = getGradient(getWave(p), dist); + vec4 cfrom = texture(texture,p); + vec4 cto =vec4(0.0); // for future use + return mix(mix(cfrom, cto, m), mix(cfrom, vec4(color), 0.75), step(m, -2.0)); +} + +void main(void) +{ + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = gl_FragCoord.xy/resolution.xy; + + + // Output to screen + fragColor = transition(uv); +} diff --git a/wip/Version 2.0/undulatingBurnOut.gre b/wip/Version 2.0/undulatingBurnOut.gre new file mode 100644 index 0000000..3ae2602 --- /dev/null +++ b/wip/Version 2.0/undulatingBurnOut.gre @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/wip/Version 2.0/wavingparticle.frag b/wip/Version 2.0/wavingparticle.frag new file mode 100644 index 0000000..c6ae043 --- /dev/null +++ b/wip/Version 2.0/wavingparticle.frag @@ -0,0 +1,169 @@ +/* Adapted from https://www.shadertoy.com/view/ttB3Rt Shader License: CC BY 3.0 +Rebuilt for enve/friction by axiomgraph + Opengl version 3.3*/ + +#version 330 core +#define PI 3.14159 +#define TWO_PI 6.283185 +#define FREQ_STEP (0.001953125 * 3.0) + +layout(location = 0) out vec4 fragColor; +layout(origin_upper_left) in vec4 gl_FragCoord; + +uniform sampler2D texture; + +uniform vec2 resolution; +in vec2 texCoord; + +uniform float iTime; +uniform int randomsize; +uniform float PARTICLE_ITERATIONS; // 6.0 +uniform float PARTICLE_RADIUS; // 0.15 +uniform float PARTICLE_RADIUS2; // 0.3 +uniform float PARTICLE_SIZE_VARIATION; // 0.2 +uniform vec4 PARTICLE_COLOR; // 0.3, 0.9, 0.9 +uniform float BRIGHTNESS; // 0.45 + +bool RANDOMIZED_SIZE = bool(randomsize); // boolean value + + +float pow3(in float x) +{ + return x*x*x; +} + +float hash1_2(in vec2 x) +{ + return fract(sin(dot(x, vec2(52.127, 61.2871))) * 521.582); +} + +vec2 hash2_3(in vec3 x) +{ + return fract(sin(x * mat2x3(20.5283, 24.1994, 70.2913, + 89.9132, 57.1454, 45.1211)) * 492.194); +} + + +//Simple interpolated noise +vec2 noise2_3(vec3 coord) +{ + //vec3 f = fract(coord); + vec3 f = smoothstep(0.0, 1.0, fract(coord)); + + vec3 uv000 = floor(coord); + vec3 uv001 = uv000 + vec3(0,0,1); + vec3 uv010 = uv000 + vec3(0,1,0); + vec3 uv011 = uv000 + vec3(0,1,1); + vec3 uv100 = uv000 + vec3(1,0,0); + vec3 uv101 = uv000 + vec3(1,0,1); + vec3 uv110 = uv000 + vec3(1,1,0); + vec3 uv111 = uv000 + vec3(1,1,1); + + vec2 v000 = hash2_3(uv000); + vec2 v001 = hash2_3(uv001); + vec2 v010 = hash2_3(uv010); + vec2 v011 = hash2_3(uv011); + vec2 v100 = hash2_3(uv100); + vec2 v101 = hash2_3(uv101); + vec2 v110 = hash2_3(uv110); + vec2 v111 = hash2_3(uv111); + + vec2 v00 = mix(v000, v001, f.z); + vec2 v01 = mix(v010, v011, f.z); + vec2 v10 = mix(v100, v101, f.z); + vec2 v11 = mix(v110, v111, f.z); + + vec2 v0 = mix(v00, v01, f.y); + vec2 v1 = mix(v10, v11, f.y); + vec2 v = mix(v0, v1, f.x); + + return v; +} + +//Simple interpolated noise +float noise1_2(in vec2 uv) +{ + vec2 f = fract(uv); + //vec2 f = smoothstep(0.0, 1.0, fract(uv)); + + vec2 uv00 = floor(uv); + vec2 uv01 = uv00 + vec2(0,1); + vec2 uv10 = uv00 + vec2(1,0); + vec2 uv11 = uv00 + 1.0; + + float v00 = hash1_2(uv00); + float v01 = hash1_2(uv01); + float v10 = hash1_2(uv10); + float v11 = hash1_2(uv11); + + float v0 = mix(v00, v01, f.y); + float v1 = mix(v10, v11, f.y); + float v = mix(v0, v1, f.x); + + return v; +} + + +//Calculates particle movement +vec2 cellPointFromRootUV(vec2 rootUV, vec2 originalUV, out float len) +{ + vec2 displacement = (noise2_3(vec3(rootUV * 0.07 + iTime * 0.3, 0.5 * (iTime + 0.1) * 1.0 + noise1_2(originalUV * 0.04))) - 0.5); + len = dot(displacement, displacement); + return displacement * 3.0 * (PARTICLE_ITERATIONS) + 0.5 + rootUV; +} + +//Calculates particle size +float particleFromUVAndPoint(in vec2 uv, in vec2 point, in vec2 rootUV, in float pixelSize) +{ + float dist = distance(uv, point); +if ( RANDOMIZED_SIZE) { + dist += (hash1_2(rootUV * 10.0) - 0.5) * PARTICLE_SIZE_VARIATION; + } + + float particle = 1.0 - smoothstep(PARTICLE_RADIUS - dist * 0.05, PARTICLE_RADIUS2 - dist * 0.05 + pixelSize, dist); + return particle * particle; +} + +//Particle system +vec3 surfaceParticles(in vec2 uv, in float pixelSize) +{ + vec3 particles = vec3(0.0); + vec2 rootUV = floor(uv); + + vec2 tempRootUV; + vec2 pointUV; + float dist; + vec3 color; + for (float x = -PARTICLE_ITERATIONS; x <= PARTICLE_ITERATIONS; x += 1.0) + { + for (float y = -PARTICLE_ITERATIONS; y <= PARTICLE_ITERATIONS; y += 1.0) + { + tempRootUV = rootUV + vec2(x, y); + pointUV = cellPointFromRootUV(tempRootUV, uv, dist); + color = mix(vec3(0), PARTICLE_COLOR.rgb *1.0, pow(smoothstep(0.3, 0.0, dist), 4.0)); + particles += particleFromUVAndPoint(uv, pointUV, tempRootUV, pixelSize) * color; + } + } + + return particles; +} + +void main(void) +{ + vec2 uv = (2.0 * gl_FragCoord.xy - resolution.xy) / resolution.x; + + float vignette = 1.0 - smoothstep(0.5, 1.3, length(uv* vec2(1.0, resolution.x / resolution.y))); + + //for antialiasing + float pixelSize = 1.5 / resolution.x; + + uv *= 70.0; + pixelSize *= 70.0; + + vec3 particles = surfaceParticles(uv, pixelSize) * BRIGHTNESS; + + //postprocess + particles = smoothstep(-0.2, 0.8, particles * vignette); + + fragColor = vec4(particles, texture(texture,texCoord).a); +} diff --git a/wip/Version 2.0/wavingparticle.gre b/wip/Version 2.0/wavingparticle.gre new file mode 100644 index 0000000..252e056 --- /dev/null +++ b/wip/Version 2.0/wavingparticle.gre @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/wip/Version 2.0/windowslice.frag b/wip/Version 2.0/windowslice.frag new file mode 100644 index 0000000..5a398c8 --- /dev/null +++ b/wip/Version 2.0/windowslice.frag @@ -0,0 +1,29 @@ +/* Adapted from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/windowslice.glsl +License: MIT +Rebuilt for enve/friction by axiomgraph +Opengl version 3.3*/ +#version 330 core +precision mediump float; + +layout(location = 0) out vec4 fragColor; +layout(pixel_center_integer) in vec4 gl_FragCoord; +uniform sampler2D texture; + in vec2 texCoord; + +uniform float progress; + +uniform float count; +uniform float smoothness; + +vec4 transition (vec2 p) { + float pr = smoothstep(-smoothness, 0.0, p.x - progress * (1.0 + smoothness)); + float s = step(pr, fract(count * p.x)); + return mix(texture(texture,p), vec4(0.0), s); // for future use +} + +void main(void) +{ + + fragColor = transition(texCoord); +} + diff --git a/wip/Version 2.0/windowslice.gre b/wip/Version 2.0/windowslice.gre new file mode 100644 index 0000000..ea4ee1b --- /dev/null +++ b/wip/Version 2.0/windowslice.gre @@ -0,0 +1,10 @@ + + + + + + + +