uniform float time; uniform vec2 resolution; uniform sampler2D texture_sampler; uniform sampler2D texts; float zoom = 1.; float gTime = 0.; float getBeat(void) { return floor(abs(time*4.) / (60./145.) ); } float getBar(void) { return floor(abs(time) / (60./145.)); } vec2 csqr(vec2 a) { return vec2(a.x * a.x - a.y * a.y, 2. * a.x * a.y); } mat2 rot(float a) { return mat2(cos(a), sin(a), -sin(a), cos(a)); } 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, .2)) / 1.5; pos.xy *= 5.; pos.y -= 3.5; pos.xy *= rot(.55); 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) { float box_set1 = box_set(pos, time); return box_set1; } vec4 mainImage2(vec2 fragCoord) { vec2 p = (fragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y); vec3 ro = vec3( time * 4., -time , time * 8.); vec3 ray = normalize(vec3(p, 0.55)); ray.xy = ray.xy * rot(sin(time * .1) * 6.); ray.yz = ray.yz * rot(sin(time * .01) * .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.5, 4.) - 2.; gTime = time - float(i) * 0.01; float d = map(pos, time); d = max(abs(d), 0.03); ac += exp(-d * 26.); t += d * 0.55; } col = vec3(ac * 0.025); col += vec3(0.1 + sin(time) * 0.2, 0.5, 0.); return vec4(col, 1.0 - t * (0.02 + 0.02 * sin(time))); } vec3 palette(float t) { vec3 a = vec3(0.5, 0.5, 0.5); vec3 b = vec3(1.0, 1.0, 1.0); vec3 c = vec3(1.0, 1.0, 1.0); vec3 d = vec3(0.0, 0.6666, 0.3333); return a + b * cos(6.28318 * (c*t+d)); } float rand(vec2 co) { float a = 12.9898; 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); } vec3 noise(vec2 uv) { float rng = rand(vec2(uv.x+time, uv.y)); vec3 col = vec3(0.0+rng*0.1, 0.2+rng*0.1, 0.4+rng*0.1); col.x += sin(uv.x+time*0.2)*0.1; col.y += sin(uv.y+time*0.2)*0.1; col.z += sin(uv.y+time*0.2)*0.1; return col; } vec3 wave(vec2 uv, float phase, float _offset, float height, float waveLenght, float color) { float val = -(sin(phase+uv.x*waveLenght+time) + (uv.y*6.+height)+_offset)*0.055; val *= 1. + sin(phase + uv.x*waveLenght+time) + (uv.y*6.-height+_offset); //return smoothstep(0.0, 1.0, val) * palette(color/360.); return clamp(val, 0., .9) * palette(color/360.); } float gStartTime = 0.; float gPrevTime = -0.1; vec4 waveTexture(vec2 uv) { uv.y = sin(uv.x*16. + time)/32. + uv.y-0.03; uv.x -= (time-gStartTime)*0.2; vec4 tex = texture2D(texts, uv); if (tex.y > 0. && (gPrevTime != gStartTime)) { gStartTime = time; gPrevTime = gStartTime; } return vec4(tex.rgb, 1.0); } void TextScroller(out vec4 fragColor, in vec2 fragCoord) { // Normalized pixel coordinates (from -1 to 1, origo at 0,0) vec2 uv = (fragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y); vec3 col = vec3(0., 0.4, 0.6); col += wave(uv, 0., 1., 3., 1., sin(time+0.3)*90.); col += wave(uv, sin(time), 0., 3., -1., sin(time-1.2)*120.); col += wave(uv, -3., 0., 3., 1., sin(time+0.5)*90.); vec4 outBuf = waveTexture(uv * 0.1); fragColor = max(mainImage2(gl_FragCoord.xy)*0.2, vec4(col*outBuf.xyz, 1.0)); // + vec4(random(uv*2.), 1.0); } void main(void) { TextScroller(gl_FragColor, gl_FragCoord.xy); /*else { mainImage2(gl_FragColor, gl_FragCoord.xy); vec4 l; vec2 texttop = vec2(0., -.35), pt = (gl_FragCoord.xy / resolution) - texttop; if(pt.y > 0.) { l = gl_FragColor + texture2D(texts, pt); } gl_FragColor = l; } */ }