diff --git a/35c3-text.glsl b/35c3-text.glsl new file mode 100644 index 0000000..b1ac4b0 --- /dev/null +++ b/35c3-text.glsl @@ -0,0 +1,62 @@ +#pragma map font=image:./res/ascii.png + +vec4 ascii(vec2 uv, int char) { + vec2 charPos = vec2(char % 16, 15 - char / 16) / 16; + return texture2D(font, (charPos + clamp(uv*.5+.5, 0, 1) / 16) * vec2(1, -1)); +} + +vec4 text(vec2 uv, float time) { + int text[19]; // REFRESHING MEMORIES + text[0] = 0x52; // R + text[1] = 0x45; // E + text[2] = 0x46; // F + text[3] = 0x52; // R + text[4] = 0x45; // E + text[5] = 0x53; // S + text[6] = 0x48; // H + text[7] = 0x49; // I + text[8] = 0x4E; // N + text[9] = 0x47; // G + text[10] = 0x20; + text[11] = 0x4D; // M + text[12] = 0x45; // E + text[13] = 0x4D; // M + text[14] = 0x4F; // O + text[15] = 0x52; // R + text[16] = 0x49; // I + text[17] = 0x45; // E + text[18] = 0x53; // S + + float numShown = 10; + + int edge = int(step(1, mod(time, 2))); + int strStart = 11 * edge; + int xoffset = 1 * edge; + + vec4 face = vec4(0); + + int strPos = int(floor((uv.x) * numShown - xoffset)) + strStart; + if (uv.x > (xoffset / numShown) && strPos < text.length()) { + int char = text[strPos]; + vec2 charUV = vec2(mod(uv.x * numShown, 1), uv.y) * 2 - 1; + face = ascii(charUV * 0.8, char); + } + + return vec4(0, 0, 0, face.r * 16); +} + +vec3 wave(vec2 uv, float time) { + vec3 a = vec3(0, 132, 176) / 255; + vec3 b = vec3(0, 163, 86) / 255; + return mix(a, b, sin(uv.x * 2 + time*4)*.5+.5); +} + +void mainImage(out vec4 fragColor, in vec2 fragCoord) { + vec2 uv = fragCoord / iResolution.xy; + + fragColor.a = 1; + fragColor.rgb = wave(uv, iTime * .5); + + vec4 textColor = text(uv, iTime * .5); + fragColor.rgb = mix(fragColor.rgb, textColor.rgb, textColor.a); +} diff --git a/clock-firework.glsl b/clock-firework.glsl new file mode 100644 index 0000000..b0ced98 --- /dev/null +++ b/clock-firework.glsl @@ -0,0 +1,153 @@ +// "Fireworks" by Martijn Steinrucken aka BigWings - 2015 +// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported +// License. +// Email:countfrolic@gmail.com Twitter:@The_ArtOfCode + +// Adaptation for Bitlair's LED-Banner by polyfloyd + +#pragma map font=image:./res/ascii.png + +#define PI 3.141592653589793238 + +#define B(x,y,z,w) (smoothstep(x-z, x+z, w)*smoothstep(y+z, y-z, w)) + +#define NUM_EXPLOSIONS 32. +#define NUM_PARTICLES 70. + +// +#define MOD3 vec3(.1031,.11369,.13787) + +vec3 hash31(float p) { + vec3 p3 = fract(vec3(p) * MOD3); + p3 += dot(p3, p3.yzx + 19.19); + return fract(vec3((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y, (p3.y+p3.z)*p3.x)); +} + +float hash12(vec2 p){ + vec3 p3 = fract(vec3(p.xyx) * MOD3); + p3 += dot(p3, p3.yzx + 19.19); + return fract((p3.x + p3.y) * p3.z); +} + +float circ(vec2 uv, vec2 pos, float size) { + uv -= pos; + + size *= size; + return smoothstep(size*1.1, size, dot(uv, uv)); +} + +float light(vec2 uv, vec2 pos, float size) { + uv -= pos; + size *= size; + return size/dot(uv, uv); +} + +vec3 explosion(vec2 uv, vec2 p, float seed, float t) { + vec3 col = vec3(0.); + + vec3 en = hash31(seed); + vec3 baseCol = en; + for(float i=0.; i + +vec4 ascii(vec2 uv, int char) { + vec2 charPos = vec2(char % 16, 15 - char / 16) / 16; + return texture2D(font, (charPos + clamp(uv*.5+.5, 0, 1) / 16) * vec2(1, -1)); +} + +int imod(int n, int d) { + return int(mod(n, d)); +} + +float text(vec2 uv, float time) { + int s = int(iDate.w) + 1; + int seconds = imod(s, 60); + int minutes = imod(s / 60, 60); + int hours = imod(s / (60*60) + 1, 24); + int text[8]; // HH:MM:SS + text[0] = 0x30 + imod(hours/10, 10); // H + text[1] = 0x30 + imod(hours, 10); // H + text[2] = 0x3a; // : + text[3] = 0x30 + imod(minutes/10, 10); // M + text[4] = 0x30 + imod(minutes, 10); // M + text[5] = 0x3a; // : + text[6] = 0x30 + imod(seconds/10, 10); // S + text[7] = 0x30 + imod(seconds, 10); // S + + const float numShown = 10; + const int xoffset = 1; + + vec4 face = vec4(0); + int charPos = int(floor((uv.x) * numShown - xoffset)); + if (uv.x > (xoffset / numShown) && charPos < text.length()) { + int char = text[charPos]; + vec2 charUV = vec2(mod(uv.x * numShown, 1), uv.y) * 2 - 1; + face = ascii(charUV * 0.8, char); + } + return clamp(face.r * 16, 0, 1); +} + +void mainImage( out vec4 fragColor, in vec2 fragCoord ) { + vec2 uv = fragCoord / iResolution.xy; + + vec4 fw = fireworks(fragCoord, iTime+60); + float tx = text(uv, iTime); + + vec4 color = vec4(0, 0, 0, 1); + color.rgb = mix(color.rgb, fw.rgb, fw.a); + color.rgb = mix(color.rgb, 1-fw.rgb, tx); + fragColor = color; +} diff --git a/res/ascii.png b/res/ascii.png new file mode 100644 index 0000000..2adc542 Binary files /dev/null and b/res/ascii.png differ diff --git a/spasm.glsl b/spasm.glsl deleted file mode 100644 index d6a7b2d..0000000 --- a/spasm.glsl +++ /dev/null @@ -1,49 +0,0 @@ -//by @Flexi23, @DanielPettersso, @mrdoob - -#ifdef GL_ES -precision highp float; -#endif -#define pi2_inv 0.159154943091895335768883763372 -uniform float time; -uniform vec2 resolution; -//uniform vec2 mouse; - -// extra changes by @xprogram & @Harley - -float border(vec2 uv, float thickness){ - uv = fract(uv - vec2(0.5)); - uv = min(uv, vec2(1.)-uv)*2.; - return clamp(max(uv.x,uv.y)-1.+thickness,0.,1.)/thickness; -} - -// complex multiplication -vec2 mul(vec2 a, vec2 b){ - return vec2( a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x); -} - -vec2 div(vec2 numerator, vec2 denominator){ - return vec2( numerator.x*denominator.x + numerator.y*denominator.y, - numerator.y*denominator.x - numerator.x*denominator.y)/ - vec2(denominator.x*denominator.x + denominator.y*denominator.y); -} - -vec2 spiralzoom(vec2 domain, vec2 center, float n, float spiral_factor, float zoom_factor, vec2 pos){ - vec2 uv = domain - center * 1.0; - float d = length(uv); - return vec2( atan(uv.y, uv.x)*n*pi2_inv + log(d)*spiral_factor*cos(time), -log(d)*zoom_factor) + pos; -} - -void main( void ) { - vec2 uv = gl_FragCoord.xy / max(resolution.x, resolution.y); - - vec2 p1 = vec2(0.25+cos(time*.9)*0.1, 0.3-tan(time*.5)*cos(time)); - vec2 p2 = vec2(0.75+tan(time)*.1, 0.7-cos(time)*.5); - - vec2 moebius = div(uv-p2, uv-p1); - - vec2 spiral_uv = spiralzoom(moebius,vec2(-0.2),1.,1.6,1.8,-vec2(0.5,0.5)*time*.6); - vec2 spiral_uv2 = spiralzoom(moebius,vec2(-0.2),1.,1.6,1.8,-vec2(0.5,0.5)*time*.9); - vec2 spiral_uv3 = spiralzoom(moebius,vec2(-0.2),1.,1.6,1.8,-vec2(0.5,0.5)*time*.7); - gl_FragColor = vec4(border(spiral_uv,0.3), border(spiral_uv2,0.1) ,border(spiral_uv3,0.9),1.); - -}