├── README.md └── traveler.glsl /README.md: -------------------------------------------------------------------------------- 1 | # Traveler 2 2 | TokyoDemoFest 2018 GLSL Graphics Compo 1st place. 3 | 4 | ![Traveler2](https://pbs.twimg.com/media/DtaUdKrU0AE6jMk.jpg:large) 5 | 6 | # Links 7 | - [Pouet](http://www.pouet.net/prod.php?which=79391) 8 | - [Online Demo](https://www.shadertoy.com/view/4tGBDG) 9 | - [Youtube Video](https://www.youtube.com/watch?v=gTTQDZkQi-w) 10 | -------------------------------------------------------------------------------- /traveler.glsl: -------------------------------------------------------------------------------- 1 | #define TAU 6.283185307 2 | #define PI 3.141592654 3 | #define HALF_PI 1.5707963267948966 4 | #define U(z,w) (mix(z,w,step(w.x,z.x))) 5 | 6 | #define MAT_WING 1.0 7 | #define MAT_BODY 2.0 8 | #define MAT_STAGE 3.0 9 | 10 | #define saturate(x) (clamp(x, 0.0, 1.0)) 11 | 12 | #define BPM (130.) 13 | 14 | const int Iterations = 3; 15 | 16 | float orgBeat, beat, sceneBeat, kick, hihat, snare; 17 | float stageScale; 18 | float edgeOnly; 19 | vec3 fogColor; 20 | mat3 sphereRot, stageRot, stageRot2; 21 | vec3 ray; 22 | vec3 ro, ta, sp; 23 | vec3 cameraLight, stageLight, travelerLight; 24 | vec3 stageFlareCol, travelerFlareCol; 25 | float stageFlareIntensity, travelerFlareIntensity, stageFlareExp, travelerFlareExp; 26 | float shadeIntensity, glowIntensity, particleIntensity; 27 | float stageFold, stageRotateZ; 28 | float particle1Intensity, particle2Intensity; 29 | float switchTraveler; 30 | float glitchIntensity; 31 | vec3 glitchColor; 32 | 33 | float smin( float a, float b, float k ) 34 | { 35 | float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 ); 36 | return mix( b, a, h ) - k*h*(1.0-h); 37 | } 38 | 39 | float sm(float start, float end, float t, float smo) 40 | { 41 | return smoothstep(start, start + smo, t) - smoothstep(end - smo, end, t); 42 | } 43 | 44 | float sm2(float start, float end, float t, float bs, float es) 45 | { 46 | return smoothstep(start, start + bs, t) - smoothstep(end - es, end, t); 47 | } 48 | 49 | vec3 hash3( vec3 p ){ 50 | vec3 q = vec3(dot(p,vec3(127.1,311.7, 114.5)), dot(p,vec3(269.5,183.3, 191.9)), dot(p,vec3(419.2,371.9, 514.1))); 51 | return fract(sin(q)*43758.5453); 52 | } 53 | 54 | mat3 rotateMat(float roll, float pitch, float yaw) 55 | { 56 | float cp = cos(pitch); 57 | float sp = sin(pitch); 58 | float sr = sin(roll); 59 | float cr = cos(roll); 60 | float sy = sin(yaw); 61 | float cy = cos(yaw); 62 | 63 | return mat3(cp * cy, (sr * sp * cy) - (cr * sy), (cr * sp * cy) + (sr * sy), 64 | cp * sy, (sr * sp * sy) + (cr * cy), (cr * sp * sy) - (sr * cy), 65 | -sp, sr * cp, cr * cp); 66 | } 67 | 68 | float stepUp(float t, float len, float smo) 69 | { 70 | float tt = mod(t += smo, len); 71 | float stp = floor(t / len) - 1.0; 72 | return smoothstep(0.0, smo, tt) + stp; 73 | } 74 | 75 | float pingPong(float t, float len, float smo) 76 | { 77 | t = mod(t + smo, len * 2.); 78 | return 1.0 - (smoothstep(0., smo, t) - smoothstep(len, len + smo, t)); 79 | } 80 | 81 | float glowTime(vec3 p) 82 | { 83 | float t = mix(beat, beat - 45.0, step(44.0, beat)); 84 | t = mix(t, mod(beat - 53.0, 8.), step(108.0, beat)); 85 | t = mix(t, beat - 177.0, step(176.0, beat) * step(beat, 184.0)); 86 | t = mix(t, mod(beat - 177.0, 8.), step(184.0, beat) * step(beat, 224.0)); 87 | t = mix(t, -1.0, saturate(step(beat, 44.0) + (step(52.0, beat) * step(beat, 108.0)) + step(224.0, beat))); 88 | return t; 89 | } 90 | 91 | float patternIntensity(vec3 p) 92 | { 93 | float t = beat - 28.0; 94 | if (t < 0.0) { 95 | return 0.0; 96 | } 97 | t -= 2.5; 98 | float len = distance(sp, p); 99 | return sm(0.0, 2.5, mod(len - t * 1.5, 6.0), .5); 100 | } 101 | 102 | float sphere( vec3 p, float s ) 103 | { 104 | return length(p)-s; 105 | } 106 | 107 | float sdBox( vec3 p, vec3 b ) 108 | { 109 | vec3 d = abs(p) - b; 110 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 111 | } 112 | 113 | float sdTorus( vec3 p, vec2 t ) 114 | { 115 | vec2 q = vec2(length(p.xz)-t.x,p.y); 116 | return length(q)-t.y; 117 | } 118 | 119 | float de(vec3 p, mat3 rot, float scale) { 120 | vec3 offset = vec3(1,1,1); 121 | 122 | float freq = 64.0; 123 | for (int i=0; i横->全->縦->前->縦->ループ 130 | float b = mix(beat - 44., beat - 192.0, step(176.0, beat)); 131 | b = mix(b, 0.0, step(beat, 44.0)); 132 | b = mix(b, mod(beat, 8.0) + 64.0, step(108.0, beat) * step(beat, 176.0)); 133 | p.yx = mix(p.yx, p.xy, (1.0 - pingPong(b, freq * 0.25, 1.0)) * step(p.x, p.y)); 134 | p.xz = mix(p.xz, p.zx, (1.0 - pingPong(b, freq * 0.75, 1.0)) * step(p.x, p.z)); 135 | p.yz = mix(p.yz, p.zy, (1.0 - saturate(pingPong(mod(b, freq * 0.75), freq * 0.25, 1.0) - step(freq * 0.75 - 1.0, mod(b, freq*0.75)))) * step(p.y, p.z)); 136 | 137 | p.z -= 0.5*offset.z*(scale-1.)/scale; 138 | p.z = -abs(-p.z); 139 | p.z += 0.5*offset.z*(scale-1.)/scale; 140 | 141 | p.xy = scale*p.xy - offset.xy*(scale-1.); 142 | p.z = scale*p.z; 143 | } 144 | 145 | vec3 d = abs(p) - vec3(1.,1.,1.); 146 | float distance = length(vec3(max(d, vec3(0.0)))); 147 | distance *= pow(scale, -float(Iterations)); 148 | 149 | return distance; 150 | } 151 | 152 | mat2 rotate(in float a) { 153 | float s = sin(a), c = cos(a); 154 | return mat2(c, s, -s, c); 155 | } 156 | 157 | // https://www.shadertoy.com/view/Mlf3Wj 158 | vec2 foldRotate(in vec2 p, in float s) { 159 | float a = PI / s - atan(p.x, p.y); 160 | float n = TAU / s; 161 | a = floor(a / n) * n; 162 | p *= rotate(a); 163 | return p; 164 | } 165 | 166 | vec2 distStage(vec3 p, mat3 rot, float scale) 167 | { 168 | p.xy = (p.xy - 0.75) * rotate(p.z * stageRotateZ) + 0.75; 169 | p.xy = foldRotate(p.xy - 0.75, stageFold) + 0.75; 170 | p = mod(p, 1.5) - 0.75; 171 | float d = de(p, rot, scale); 172 | d = mix(d, 100., step(144.0, beat) * step(beat, 176.0)); 173 | return vec2(d, MAT_STAGE); 174 | } 175 | 176 | vec2 distSphere(vec3 p) 177 | { 178 | float wing = sphere(p, 0.1); 179 | float b1 = sdBox(p, vec3(10.0, 0.02, 10.0)); 180 | float b2 = sdBox(p, vec3(0.02, 10.0, 10.0)); 181 | float b3 = sdBox(p, vec3(10.0, 10.0, 0.02)); 182 | float s = sphere(p, 0.098); 183 | wing = max(-b1, wing); 184 | wing = max(-b2, wing); 185 | wing = max(-b3, wing); 186 | wing = max(-s, wing); 187 | 188 | vec2 w = vec2(wing, MAT_WING); 189 | vec2 body = vec2(sphere(p, 0.08), MAT_BODY); 190 | return U(w, body); 191 | } 192 | 193 | mat2 rot(float x) 194 | { 195 | return mat2(cos(x), sin(x), -sin(x), cos(x)); 196 | } 197 | 198 | /*float ifs(vec3 p) { 199 | p *= 15.; 200 | for(int i = 0; i < 3; i++) { 201 | p.xy *= rot(0.8 + .8*stepUp(beat + 1.0, 2.0, 0.5)); 202 | p.xz *= rot(0.4 + .4*stepUp(beat, 2.0, 0.5)); 203 | p = abs(p); 204 | p = 2.0*p - 1.0; 205 | } 206 | return sdBox(p, vec3(.9))*pow(2.0, -3.0) / 15.0; 207 | }*/ 208 | 209 | vec2 distMetaBall(vec3 p) 210 | { 211 | float s1 = sphere((p + vec3(sin(beat) * 0.1, sin(beat) * 0.1, 0.)), 0.05); 212 | float s2 = sphere((p + vec3(0., sin(beat * 0.5) * 0.1, sin(beat * 0.5) * 0.1)) , 0.04); 213 | float s3 = sphere((p + vec3(sin(beat * 0.25) * 0.1, 0., sin(beat * 0.25) * 0.1)), 0.03); 214 | float d = smin(s3, smin(s1, s2, .1), .1); 215 | return vec2(d, MAT_WING); 216 | } 217 | 218 | vec2 distTorus(vec3 p) 219 | { 220 | mat3 m1 = rotateMat(beat * 0.1, beat, beat * 0.7); 221 | mat3 m2 = rotateMat(beat, beat * 0.5, beat * 0.25); 222 | mat3 m3 = rotateMat(beat * 0.3, beat, beat * 0.8); 223 | float t1 = sdTorus(p * m1, vec2(0.1, 0.01)); 224 | float t2 = sdTorus(p * m2, vec2(0.08, 0.005)); 225 | float t3 = sdTorus(p * m3, vec2(0.06, 0.004)); 226 | return vec2(min(t3, min(t1, t2)), MAT_WING); 227 | } 228 | 229 | vec2 distBox(vec3 p) 230 | { 231 | float i = sdBox(p, vec3(.06)); 232 | return vec2(i, MAT_WING); 233 | } 234 | 235 | vec2 distTraveler(vec3 p) 236 | { 237 | return distSphere(p); 238 | } 239 | 240 | vec2 distTraveler2(vec3 p) 241 | { 242 | vec2 d1 = distMetaBall(p); 243 | vec2 d3 = distTorus(p); 244 | vec2 d2 = distBox(p); 245 | float s = mod(stepUp(beat, 6.0, 3.0), 3.0); 246 | vec2 d = d1; 247 | d.x = mix(d.x, d2.x, saturate(s)); 248 | d.x = mix(d.x, d3.x, saturate(s - 1.0)); 249 | d.x = mix(d.x, d1.x, saturate(s - 2.0)); 250 | return d; 251 | } 252 | 253 | vec2 distAll(vec3 p) 254 | { 255 | vec2 st1 = distStage(p, stageRot, stageScale); 256 | vec2 st2 = distStage(p, stageRot2 * stageRot, stageScale); 257 | vec2 tr = distTraveler((p - sp) * sphereRot); 258 | vec2 tr2 = distTraveler2((p - sp) * sphereRot); 259 | 260 | vec2 trd = tr; 261 | trd = mix(trd, tr2, step(0.75 + switchTraveler* 0.1, p.y)); 262 | trd.x = mix(trd.x, tr2.x, saturate(beat - 208.)); 263 | trd.x = mix(trd.x, tr.x, saturate(beat - 224.)); 264 | trd.x *= 0.9; 265 | 266 | float visibleStage = step(176.0, beat) * step(max(beat - 177.0, 0.0) * 1.7, distance(p, sp)); 267 | st1.x = mix(st1.x, 100.0, visibleStage); 268 | st2.x = mix(st2.x, 100.0, visibleStage); 269 | return U(trd, U(st1, st2)); 270 | } 271 | 272 | vec2 distGlow(vec3 p) 273 | { 274 | vec2 st1 = distStage(p, stageRot, stageScale); 275 | vec2 st2 = distStage(p, stageRot2 * stageRot, stageScale); 276 | 277 | float gt = glowTime(p); 278 | 279 | float frontSp = sphere(p - sp, gt + 1.); 280 | float backSp = sphere(p - sp, gt); 281 | float cut = max(frontSp, -backSp); 282 | vec2 st = U(st1, st2); 283 | st.x = max(st.x, cut); 284 | return st; 285 | } 286 | 287 | float distCubeParticle(vec3 pos) 288 | { 289 | pos.y -= beat * 0.25; 290 | vec3 id = floor(pos / 1.); 291 | pos = mod(pos, 1.) - 0.5; 292 | vec3 rnd = hash3(id) * 2.0 - 1.0; 293 | mat3 rot = rotateMat(rnd.x * beat * 2.0, rnd.y * beat * 2.0, rnd.z * beat * 2.0); 294 | float d = sdBox((pos + rnd * 0.25) * rot, vec3(.025)); 295 | d = mix(d, .5, step(rnd.x, -0.7)); 296 | return d; 297 | } 298 | 299 | float distSphereParticle(vec3 pos) 300 | { 301 | pos.y -= beat * 0.4; 302 | vec3 id = floor(pos / 0.4); 303 | pos = mod(pos, 0.4) - 0.2; 304 | vec3 rnd = hash3(id) * 2.0 - 1.0; 305 | mat3 rot = rotateMat(rnd.x * beat * 2.0, rnd.y * beat * 2.0, rnd.z * beat * 2.0); 306 | float d = sphere((pos * rot + rnd * 0.1), 0.01); 307 | d = mix(d, .1, step(rnd.x, 0.0)); 308 | return d; 309 | } 310 | 311 | /* 312 | vec3 normal(vec3 pos, float e) 313 | { 314 | vec3 eps = vec3(e,0.0,0.0); 315 | 316 | return normalize( vec3( 317 | distAll(pos+eps.xyy).x - distAll(pos-eps.xyy).x, 318 | distAll(pos+eps.yxy).x - distAll(pos-eps.yxy).x, 319 | distAll(pos+eps.yyx).x - distAll(pos-eps.yyx).x ) ); 320 | } 321 | */ 322 | 323 | vec3 normal( in vec3 pos, float eps ) 324 | { 325 | vec2 e = vec2(1.0,-1.0)*0.5773*eps; 326 | return normalize( e.xyy*distAll( pos + e.xyy ).x + 327 | e.yyx*distAll( pos + e.yyx ).x + 328 | e.yxy*distAll( pos + e.yxy ).x + 329 | e.xxx*distAll( pos + e.xxx ).x ); 330 | /* 331 | vec3 eps = vec3( 0.0005, 0.0, 0.0 ); 332 | vec3 nor = vec3( 333 | map(pos+eps.xyy).x - map(pos-eps.xyy).x, 334 | map(pos+eps.yxy).x - map(pos-eps.yxy).x, 335 | map(pos+eps.yyx).x - map(pos-eps.yyx).x ); 336 | return normalize(nor); 337 | */ 338 | } 339 | 340 | mat3 createCamera(vec3 ro, vec3 ta, float cr ) 341 | { 342 | vec3 cw = normalize(ta - ro); 343 | vec3 cp = vec3(sin(cr), cos(cr),0.0); 344 | vec3 cu = normalize( cross(cw,cp) ); 345 | vec3 cv = normalize( cross(cu,cw) ); 346 | return mat3( cu, cv, cw ); 347 | } 348 | 349 | float softshadow( in vec3 ro, in vec3 rd, in float mint, in float maxt, in float k) 350 | { 351 | float res = 1.0; 352 | float t = mint; 353 | for( int i=0; i<8; i++ ) 354 | { 355 | float h = distAll( ro + rd*t).x; 356 | res = min( res, k*h/t ); 357 | t += clamp( h, 0.05, 0.2 ); 358 | if( res<0.001 || t>maxt ) break; 359 | } 360 | return clamp( res, 0.0, 1.0 ); 361 | } 362 | 363 | float sdRect( vec2 p, vec2 b ) 364 | { 365 | vec2 d = abs(p) - b; 366 | return min(max(d.x, d.y),0.0) + length(max(d,0.0)); 367 | } 368 | 369 | float tex(vec2 p, float z) 370 | { 371 | vec2 q = (fract(p / 10.0) - 0.5) * 10.0; 372 | float d = 9999.0; 373 | for (int i = 0; i < 3; ++i) { 374 | q = abs(q) - 0.5; 375 | q *= rot(0.785398); 376 | q = abs(q) - 0.5; 377 | q *= rot(z * 0.5); 378 | float k = sdRect(q, vec2(1.0, 0.55 + q.x)); 379 | d = min(d, k); 380 | } 381 | float f = 1.0 / (1.0 + abs(d)); 382 | return pow(f, 16.0) + smoothstep(0.95, 1.0, f); 383 | } 384 | 385 | vec3 light(vec3 pos, vec3 normal, vec3 ray, vec3 col, vec3 lpos, vec3 diffuse, vec3 specular, float smoothness) 386 | { 387 | vec3 lvec = normalize(lpos - pos); 388 | vec3 hvec = normalize(lvec - ray); 389 | float llen = length(lpos - pos); 390 | vec3 diff = diffuse * col * (dot(normal, lvec) * 0.5 + 0.5) * (1.0 / PI); 391 | 392 | float bpnorm = ( smoothness + 2.0 ) / ( 2.0 * PI ); 393 | vec3 spec = specular * col * bpnorm * pow( max( 0.0, dot( normal, hvec ) ), smoothness ); 394 | 395 | return vec3(diff + spec) / (llen * llen); 396 | } 397 | 398 | vec3 shade(vec3 pos, vec3 normal, vec3 ray, vec3 diffuse, vec3 specular, float smoothness) 399 | { 400 | vec3 col = light(pos, normal, ray, cameraLight * 2.0, ro, diffuse, specular, smoothness); 401 | col += light(pos, normal, ray, stageLight, ro + vec3(0.0, 0.0, 2.0), diffuse, specular, smoothness); 402 | return col; 403 | } 404 | 405 | vec3 rgb2hsv(vec3 hsv) 406 | { 407 | vec4 t = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); 408 | vec3 p = abs(fract(vec3(hsv.x) + t.xyz) * 6.0 - vec3(t.w)); 409 | return hsv.z * mix(vec3(t.x), clamp(p - vec3(t.x), 0.0, 1.0), hsv.y); 410 | } 411 | 412 | vec3 materialize(vec3 ro, vec3 ray, float depth, vec2 mat) 413 | { 414 | vec3 pos = ro + ray * depth; 415 | vec3 nor = normal(pos, 0.0025); 416 | vec3 spLocalNormal = normalize((pos - sp) * sphereRot); 417 | vec3 col = vec3(0.); 418 | 419 | vec3 coord = mix(19.3602379925 * spLocalNormal, pos * 9.3602379925, step(MAT_BODY, mat.y)); 420 | vec3 pattern = vec3(tex(coord.zy, 113.09), tex(coord.xz, 113.09), tex(coord.xy, 113.09)); 421 | 422 | if (mat.y == MAT_WING) { 423 | float wing_pattern = saturate(pattern.x + pattern.y + pattern.z); 424 | vec3 cameraLightCol = light(pos, nor, ray, cameraLight * 2.0, ro, vec3(.1), vec3(.1), mix(5.0, 100.0, wing_pattern)); 425 | vec3 stageLightCol = light(pos, nor, ray, stageLight, ro + vec3(0.0, 0.0, 2.0), vec3(.1), vec3(.1), mix(5.0, 100.0, wing_pattern)); 426 | col += cameraLightCol + stageLightCol; 427 | 428 | col += vec3(1.0, 0.25, 0.35) * 1.3 * wing_pattern * (cos(beat * 0.5) * 0.5 + 1.0); 429 | } else if (mat.y == MAT_BODY) { 430 | col += vec3(1.0, 0.25, 0.35) * 1. * saturate(cos(beat * 0.5) * 0.5 + 1.0); 431 | } else if (mat.y == MAT_STAGE) { 432 | vec3 lpos = ro + vec3(0.0, 0.0, 2.0); 433 | vec3 lvec = normalize(lpos - pos); 434 | 435 | vec3 cameraLightCol = light(pos, nor, ray, cameraLight * 2.0, ro, vec3(1.), vec3(1.), 25.); 436 | vec3 stageLightCol = light(pos, nor, ray, stageLight, ro + vec3(0.0, 0.0, 2.0), vec3(1.), vec3(1.), 25.); 437 | float sha = (softshadow(pos, lvec, 0.01, length(lpos - pos), 4.0) + mix(.2, .4, step(160.0, beat))); 438 | 439 | // ステージが出現する演出 440 | float noShade = 0.0; 441 | noShade = step(distance(pos, sp), sceneBeat) * step(45.0, beat); 442 | 443 | float wing_pattern = pow(saturate(pattern.x + pattern.y + pattern.z), 1.5) * 1.2; 444 | col += ((cameraLightCol + stageLightCol * sha + light(pos, nor, ray, travelerLight, sp, vec3(1.), vec3(1.), mix(25., 100., step(176.0, beat)))) * edgeOnly * noShade + max(wing_pattern, 0.0) * (mix(vec3(0.1,0.2,0.4), rgb2hsv(vec3(pos.z * 1.0 + beat * 0.1, .85, 1.5)), step(160.0, beat))) * 4.0 * patternIntensity(pos)) * glowIntensity; 445 | } 446 | 447 | return mix(col, fogColor, pow(depth * 0.018, 2.1)); 448 | } 449 | 450 | vec3 glowTrace(vec3 ro, vec3 ray, float maxDepth) 451 | { 452 | float t = 0.0; 453 | vec3 col = vec3(0.); 454 | for (int i = 0; i < 16; i++) { 455 | vec3 p = ro+ray*t; 456 | float len = distance(sp, p); 457 | float gt = glowTime(p); 458 | 459 | // 光らせたくないときは-1.0を返してる 460 | if (gt < 0.0) { 461 | break; 462 | } 463 | 464 | vec3 h = hash3(floor(p * 30.0) / 30.0) * 2.0 - 1.0; 465 | float val = 1.0 - sm(gt, gt + 2.0, len, .25); 466 | // TODO: smでバラバラ感を制御しているが思った挙動じゃないので調査する 467 | vec2 res = distGlow(p + h * 0.15 * val); 468 | col += saturate(0.002 / res.x) * rgb2hsv(vec3(p.x * 1., 0.8, 1.0)); 469 | t += res.x; 470 | if (maxDepth < t) { 471 | break; 472 | } 473 | } 474 | return col; 475 | } 476 | 477 | 478 | vec4 particleTrace(vec3 ro, vec3 ray, float maxDepth) 479 | { 480 | float t = 0.0; 481 | vec3 col = vec3(0.0); 482 | for (int i = 0; i < 48; i++) 483 | { 484 | vec3 p = ro+ray*t; 485 | float d = distSphereParticle(p); 486 | col += max(vec3(0.0), particle1Intensity / d * vec3(1.0, 0.5, 0.5)); 487 | t += d * 0.5; 488 | if (maxDepth < t) { 489 | break; 490 | } 491 | } 492 | return vec4(saturate(col), t); 493 | } 494 | 495 | vec4 particle2Trace(vec3 ro, vec3 ray, float maxDepth) 496 | { 497 | float t = 0.0; 498 | vec3 col = vec3(0.0); 499 | for (int i = 0; i < 48; i++) 500 | { 501 | vec3 p = ro+ray*t; 502 | float d = distCubeParticle(p); 503 | col += max(vec3(0.0), particle2Intensity / d * vec3(0.0, 0.5, 1.0)); 504 | t += d * 0.25; 505 | if (maxDepth < t) { 506 | break; 507 | } 508 | } 509 | return vec4(saturate(col), t); 510 | } 511 | 512 | vec4 trace(vec3 ro, vec3 ray) 513 | { 514 | float t = 0.0; 515 | float stepIntensity = 0.0; 516 | vec2 res; 517 | for (int i = 0; i < 80; i++) { 518 | vec3 p = ro+ray*t; 519 | res = distAll(p); 520 | if( res.x < 0.0001 || t > 100.0) { 521 | stepIntensity = float(i) / 64.0; 522 | break; 523 | } 524 | t += res.x; 525 | } 526 | vec3 p = ro + ray * t; 527 | float val = patternIntensity(p); 528 | vec3 sg1 = pow(stepIntensity * 1.0, 5.0) * vec3(.2, .4, .8) * val * 5.; 529 | vec3 sg2 = pow(stepIntensity * 1.0, 1.0) * vec3(1., 0., 0.) - pow(stepIntensity * 1.0, 2.0) * vec3(0., 1., 1.); 530 | vec3 sg3 = pow(stepIntensity * 1.0, 1.0) * vec3(0., 0.5, .75); 531 | float v = saturate((beat - 236.0) / 4.0); 532 | float v2 = 1.0 - saturate((beat - 239.5) / 1.5); 533 | float v3 = saturate((beat - 232.0) / 8.0); 534 | return vec4(saturate(materialize(ro, ray, t, res) + sg1 * shadeIntensity - mix(vec3(0.), sg3 * 2.0 * v2, v3) + mix(vec3(0.), sg2 * 2.0 * v2, v)), t); 535 | } 536 | 537 | void initBeat(float b) 538 | { 539 | sceneBeat = b; 540 | 541 | kick = mod(sceneBeat, 1.); 542 | hihat = sceneBeat < 16.0 ? 0.0 : pingPong(sceneBeat + 0.5, 1.0, 0.1) * 0.1; 543 | snare = sceneBeat < 32.0 ? 0.0 : stepUp(sceneBeat - 32.5, 2.0, 0.5); 544 | } 545 | 546 | vec2 hash( vec2 p ){ 547 | p = vec2( dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))); 548 | return fract(sin(p)*43758.5453) * 2.0 - 1.0; 549 | } 550 | 551 | vec2 fbm_hash( vec2 x ) 552 | { 553 | const vec2 k = vec2( 0.3183099, 0.3678794 ); 554 | x = x*k + k.yx; 555 | return -1.0 + 2.0*fract( 16.0 * k*fract( x.x*x.y*(x.x+x.y)) ); 556 | } 557 | 558 | float noise( in vec2 p ) 559 | { 560 | vec2 i = floor( p ); 561 | vec2 f = fract( p ); 562 | 563 | vec2 u = f*f*(3.0-2.0*f); 564 | 565 | return mix( mix( dot( fbm_hash( i + vec2(0.0,0.0) ), f - vec2(0.0,0.0) ), 566 | dot( fbm_hash( i + vec2(1.0,0.0) ), f - vec2(1.0,0.0) ), u.x), 567 | mix( dot( fbm_hash( i + vec2(0.0,1.0) ), f - vec2(0.0,1.0) ), 568 | dot( fbm_hash( i + vec2(1.0,1.0) ), f - vec2(1.0,1.0) ), u.x), u.y); 569 | } 570 | 571 | float fbm(vec2 uv, float s) 572 | { 573 | uv *= s; 574 | mat2 m = mat2( 1.6, 1.2, -1.2, 1.6 ); 575 | float f = 0.5000*noise( uv ); uv = m*uv; 576 | f += 0.2500*noise( uv ); uv = m*uv; 577 | f += 0.1250*noise( uv ); uv = m*uv; 578 | f += 0.0625*noise( uv ); uv = m*uv; 579 | return f * 0.5 + 0.5; 580 | } 581 | 582 | float quadraticInOut(float t) { 583 | float p = 2.0 * t * t; 584 | return t < 0.5 ? p : -p + (4.0 * t) - 1.0; 585 | } 586 | 587 | float elasticOut(float t) { 588 | return sin(-13.0 * (t + 1.0) * HALF_PI) * pow(2.0, -10.0 * t) + 1.0; 589 | } 590 | 591 | float exponentialInOut(float t) { 592 | return t == 0.0 || t == 1.0 593 | ? t 594 | : t < 0.5 595 | ? +0.5 * pow(2.0, (20.0 * t) - 10.0) 596 | : -0.5 * pow(2.0, 10.0 - (t * 20.0)) + 1.0; 597 | } 598 | 599 | float exponentialIn(float t) { 600 | return t == 0.0 ? t : pow(2.0, 10.0 * (t - 1.0)); 601 | } 602 | 603 | float exponentialOut(float t) { 604 | return t == 1.0 ? t : 1.0 - pow(2.0, -10.0 * t); 605 | } 606 | 607 | vec3 scene(vec2 p) 608 | { 609 | 610 | float cameraF = sin(beat * 0.25); 611 | float scene0Beat = beat; 612 | float scene1Beat = beat - 12.; 613 | float scene2Beat = beat - 44.; 614 | float scene3Beat = beat - 124.; 615 | float scene4Beat = beat - 176.; 616 | 617 | float cscene0to1 = step(12.0, beat); 618 | float cscene1to2 = exponentialOut(saturate(beat - 44.)); 619 | float cscene2_1to2_2 = saturate((beat - 108.0) / 16.0); 620 | cscene2_1to2_2 = quadraticInOut(cscene2_1to2_2 * cscene2_1to2_2); 621 | float cscene3to4 = quadraticInOut(saturate((beat - 172.0) / 4.0)); 622 | float cscene3to4_2 = exponentialOut(saturate((beat - 176.0) / 1.0)); 623 | 624 | float scene2to3FadeOut = saturate((beat - 140.0) / 4.0 ); 625 | 626 | ////// Traveler ////// 627 | float toffset = max(0.0, beat - 239.5) * 0.7; 628 | sp = mix(vec3(0.75, 0.75, mix(-20.0, 20.0, beat / 16.0)), vec3(0.75, 0.75, 0.2 + beat * 0.25 + toffset), cscene0to1); 629 | //travelerInit(vec3(0.75, 0.75, 0.2 + beat * 0.25 + toffset)); 630 | ////////////////////// 631 | 632 | ////// Camera ////// 633 | vec3 scene0CameraPos = vec3(0.9, 0.8, 0.0); 634 | vec3 scene1CameraPos = sp + vec3(sin(scene1Beat * 0.475) * 0.3 + cameraF * 0.05, .15 + cameraF * 0.05, cos(scene1Beat * 0.475) * 0.3 + cameraF * 0.05); 635 | vec3 scene2CameraPos = sp + vec3(sin(scene2Beat * 0.2) * 0.15, cos(scene2Beat * 0.4) * 0.05 + 0.05, cos(scene2Beat * 0.15 + PI) * 0.05 - 0.2); 636 | vec3 scene3CameraPos = sp + vec3(cos(scene1Beat * 0.25) * 0.7 + cameraF * 0.05, .15 + cameraF * 0.05, sin(scene1Beat * 0.25) * 0.5 + cameraF * 0.05); 637 | 638 | float cb = scene1Beat - 4.0; 639 | vec3 scene4CameraPos = sp + vec3(sin(cb * 0.2) * 0.15, cos(cb * 0.4) * 0.05 + 0.05, cos(cb * 0.15 + PI) * 0.05 - 0.2); 640 | 641 | vec3 scene0CameraTarget = vec3(0.75, 0.75, 1.0); 642 | vec3 scene1CameraTarget = sp; 643 | vec3 scene2CameraTarget = sp + vec3(0.0, 0.0, (sin(scene2Beat * 0.05) * 0.5 + 0.5) * 3.0); 644 | vec3 scene3CameraTarget = sp; 645 | vec3 scene4CameraTarget = sp + vec3(0.0, 0.0, (sin(scene2Beat * 0.05) * 0.5 + 0.5) * 3.0); 646 | 647 | float scene0CameraAngle = 0.0; 648 | float scene1CameraAngle = sin(beat * 0.5) * 0.1; 649 | 650 | float scene0CameraFov = 3.0; 651 | float scene1CameraFov = 2.5; 652 | float scene2_1CameraFov = 1.0; 653 | float scene2_2CameraFov = 3.5; 654 | float scene3_1CameraFov = 1.0; 655 | float scene3_2CameraFov = 3.5; 656 | float scene3_3CameraFov = 3.5; 657 | float scene3_4CameraFov = 1.5; 658 | float scene4CameraFov = 0.45; 659 | 660 | vec2 rnd = hash(vec2(beat * 0.5)) * 0.05; 661 | rnd *= saturate(max(0.0, 1.0 - distance(scene0CameraPos, sp) / 3.0) * (1.0 - cscene0to1) + 662 | saturate((beat - 234.0) / 6.0) * (1.0 - saturate(beat - 240.0))); 663 | 664 | ro = mix(scene0CameraPos + vec3(rnd, 0.0), scene1CameraPos, cscene0to1); 665 | ro = mix(ro, scene2CameraPos, cscene1to2); 666 | 667 | // scene2 side camera 668 | float cscene2to2_1 = exponentialInOut(saturate((beat - 61.0) / 4.0)); 669 | float cscene2to2_2 = exponentialInOut(saturate((beat - 65.0) / 9.0)); 670 | float cscene2to2_3 = exponentialInOut(saturate((beat - 67.0) / 8.0)); 671 | float cscene2to2_3_2 = exponentialInOut(saturate((beat - 67.0) / 12.0)); 672 | vec3 scene2_1SidePos = sp + mix(vec3(30.0, 1.0, -10.0), vec3(1.0, .0, 1.0), cscene2to2_1); 673 | vec3 scene2_2SidePos = sp + mix(vec3(1.0, 0.0, 1.0), vec3(sin(-beat * 3. + 0.8) * 1.25, 0.0, cos(-beat * 3. + 0.8)), cscene2to2_2); 674 | ro = mix(ro, scene2_1SidePos, cscene2to2_1); 675 | ro = mix(ro, scene2_2SidePos, cscene2to2_2); 676 | ro = mix(ro, scene2CameraPos, cscene2to2_3); 677 | //// 678 | 679 | // scene2 vertical camera 680 | float cscene2to2_4 = exponentialInOut(saturate((beat - 96.0) / 4.0)); 681 | float cscene2to2_5 = exponentialInOut(saturate((beat - 100.0) / 8.0)); 682 | vec3 scene2VerticalPos = sp + mix(vec3(1.0, 30.0, -10.0), vec3(0.1, sin(-beat * 0.5) * 2., cos(-beat * 0.5)) * 2., cscene2to2_4); 683 | //// 684 | 685 | ro = mix(ro, scene2VerticalPos, cscene2to2_4); 686 | ro = mix(ro, scene2CameraPos, cscene2to2_5); 687 | 688 | ro = mix(ro, scene3CameraPos, cscene2_1to2_2); 689 | ro = mix(ro, scene4CameraPos + vec3(rnd * 2.0, 0.0) - vec3(0., 0., toffset), cscene3to4); 690 | 691 | ta = mix(scene0CameraTarget + vec3(rnd * 2.0, 0.0), scene1CameraTarget, cscene0to1); 692 | ta = mix(ta, scene2CameraTarget, cscene1to2); 693 | 694 | // scene2 side camera 695 | ta = mix(ta, sp, cscene2to2_1); 696 | ta = mix(ta, scene2CameraTarget, cscene2to2_3_2); 697 | //// 698 | 699 | // scene2 vertical camera 700 | ta = mix(ta, sp, cscene2to2_4); 701 | ta = mix(ta, scene2CameraTarget, cscene2to2_5); 702 | //// 703 | 704 | ta = mix(ta, scene3CameraTarget, cscene2_1to2_2); 705 | ta = mix(ta, scene4CameraTarget + vec3(rnd, 0.0), cscene3to4_2); 706 | 707 | float fov = mix(scene0CameraFov, scene1CameraFov, cscene0to1); 708 | fov = mix(fov, scene2_1CameraFov, cscene1to2); 709 | 710 | // scene2 vertical camera 711 | fov = mix(fov, 1.0, cscene2to2_4); 712 | fov = mix(fov, scene2_1CameraFov, cscene2to2_5); 713 | //// 714 | 715 | fov = mix(fov, scene2_2CameraFov, cscene2_1to2_2); 716 | 717 | float scene2_2to3_1FovAnim = elasticOut(quadraticInOut(saturate((beat - 144.0) / 1.0))); 718 | fov = mix(fov, scene3_1CameraFov, scene2_2to3_1FovAnim); 719 | 720 | float scene3_1to3_2FovAnim = exponentialInOut(saturate((beat - 148.0) / 12.0)); 721 | fov = mix(fov, scene3_2CameraFov, scene3_1to3_2FovAnim); 722 | fov = mix(fov, scene3_3CameraFov, cscene3to4); 723 | fov = mix(fov, scene3_4CameraFov, cscene3to4); 724 | fov = mix(fov, scene4CameraFov, cscene3to4_2); 725 | 726 | float cameraAng = mix(scene0CameraAngle, scene1CameraAngle, cscene0to1); 727 | 728 | mat3 cm = createCamera(ro, ta, cameraAng); 729 | ray = cm * normalize(vec3(p, fov)); 730 | //////////////////// 731 | 732 | ////// Fog ////// 733 | vec3 scene0Fog = vec3(0.0); 734 | vec3 scene2Fog = vec3(8., 16., 32.); 735 | vec3 scene3Fog = vec3(0.0); 736 | vec3 scene4Fog = vec3(8., 16., 32.); 737 | 738 | float scene0to1Fog = saturate((beat - 46.0) * 0.5); 739 | float scene3to4Fog = saturate((beat - 184.0) * 0.5); 740 | fogColor = mix(scene0Fog, scene2Fog, scene0to1Fog); 741 | fogColor = mix(fogColor, scene3Fog, scene2to3FadeOut); 742 | fogColor = mix(fogColor, scene4Fog, scene3to4Fog); 743 | ///////////////// 744 | 745 | ////// Flare ////// 746 | float scene0StageFlareIntensity = 0.0; 747 | float scene2StageFlareIntensity = 0.5; 748 | float scene3StageFlareIntensity = 0.0; 749 | float scene4StageFlareIntensity = 0.45; 750 | 751 | float scene0StageFlareExp = 1.0; 752 | float scene2StageFlareExp = 7.5; 753 | float scene4StageFlareExp = 2.0; 754 | 755 | float scene0TravelerFlareIntensity = max(0.2, cos(sceneBeat * 0.5) * 0.5 + 0.5); 756 | float scene1TravelerFlareIntensity = max(0.2, cos(beat * 0.5) * 0.5 + 0.5); 757 | 758 | float scene0TravelerFlareExp = mix(1.0, 800.0, distance(ro, sp) / 10.0); 759 | float scene1TravelerFlareExp = 8.0; 760 | 761 | stageFlareCol = vec3(.3, .6, 1.2); 762 | travelerFlareCol = vec3(1., .25, .35); 763 | 764 | float scene3to4Flare = saturate((beat - 176.0) / 4.0); 765 | 766 | stageFlareIntensity = mix(scene0StageFlareIntensity, scene2StageFlareIntensity, scene0to1Fog); 767 | stageFlareIntensity = mix(stageFlareIntensity, scene3StageFlareIntensity, scene2to3FadeOut); 768 | stageFlareIntensity = mix(stageFlareIntensity, scene4StageFlareIntensity, scene3to4Flare); 769 | 770 | stageFlareExp = mix(scene0StageFlareExp, scene2StageFlareExp, cscene0to1); 771 | stageFlareExp = mix(stageFlareExp, scene4StageFlareExp, scene3to4Flare); 772 | 773 | travelerFlareIntensity = mix(scene0TravelerFlareIntensity, scene1TravelerFlareIntensity, cscene0to1); 774 | 775 | travelerFlareExp = mix(scene0TravelerFlareExp, scene1TravelerFlareExp, cscene0to1); 776 | /////////////////// 777 | 778 | ////// Light ////// 779 | vec3 scene0CameraLight = vec3(.005); 780 | vec3 scene4CameraLight = vec3(0.04, 0.06, 0.08) * 0.2; 781 | 782 | vec3 scene0StageLight = vec3(.0); 783 | vec3 scene2StageLight = vec3(0.2, 0.4, 0.8); 784 | vec3 scene3StageLight = vec3(0.); 785 | vec3 scene4StageLight = vec3(0.4, 0.8, 1.6) * 2.; 786 | 787 | cameraLight = mix(scene0CameraLight, scene4CameraLight, cscene3to4_2); 788 | 789 | stageLight = mix(scene0StageLight, scene2StageLight, cscene1to2); 790 | stageLight = mix(stageLight, scene3StageLight, scene2to3FadeOut); 791 | stageLight = mix(stageLight, scene4StageLight, cscene3to4_2); 792 | /////////////////// 793 | 794 | ////// Edge ////// 795 | edgeOnly = mix(0.0, 1.0, cscene1to2); 796 | ////////////////// 797 | 798 | ////// Particle ////// 799 | particleIntensity = mix(0.0, 1.0, saturate((beat - 145.0) * 10.0)); 800 | 801 | float particleAnim = saturate((beat - 145.0) / 4.0 ); 802 | particle1Intensity = mix(0.003, 0.0002, particleAnim); 803 | particle2Intensity = mix(0.016, 0.0007, particleAnim); 804 | ////////////////////// 805 | 806 | ////// Shade ////// 807 | shadeIntensity = mix(1.0, 0.0, scene2to3FadeOut); 808 | shadeIntensity = mix(shadeIntensity, 1.0, cscene3to4); 809 | /////////////////// 810 | 811 | ////// Glow ////// 812 | glowIntensity = mix(1.0, 0.0, scene2to3FadeOut); 813 | glowIntensity = mix(glowIntensity, 1.0, cscene3to4); 814 | ////////////////// 815 | 816 | ////// Last Stage ////// 817 | stageFold = mix(1.0, stepUp(scene4Beat, 64. * 0.25, 1.0) * 4.0 + 5.0 + stepUp(max(0.0, beat - 244.0), 1.0, 0.2) * 10.0, cscene3to4_2); 818 | stageRotateZ = mix(0.0, 1.0 - pingPong(scene4Beat, 64. * 0.25, 1.0), cscene3to4_2); 819 | //////////////////////// 820 | 821 | ////// Traveler Light ////// 822 | travelerLight = mix(vec3(.02, 0.004, 0.004) * 0.8, vec3(.02, .004, .004) * 1.5, cscene3to4_2); 823 | //////////////////////////// 824 | 825 | ////// Beat ////// 826 | float bb = mix(scene1Beat, scene2Beat, cscene1to2); 827 | initBeat(bb); 828 | ///////////////// 829 | 830 | ////// stage ////// 831 | stageScale = 3.4 - mix(0.00, 0.25, clamp(kick, 0.0, 1.0)); 832 | stageRot = rotateMat(0.1-hihat,-hihat, 0.4-hihat); 833 | vec3 angle = mod(vec3(snare * 1.3, snare * 0.27, snare * 0.69), vec3(TAU) * 0.5); 834 | stageRot2 = rotateMat(angle.x, angle.y, angle.z); 835 | sphereRot = rotateMat(sin(beat * 0.5),cos(beat * 0.5), sin(beat * 0.5 * .33)); 836 | /////////////////// 837 | 838 | vec4 c = trace(ro, ray); 839 | c.rgb += glowTrace(ro, ray, c.w + 0.01) * glowIntensity; 840 | vec4 p1 = particleTrace(ro, ray, c.w); 841 | vec4 p2 = particle2Trace(ro, ray, c.w); 842 | c.rgb += p1.rgb * particleIntensity; 843 | c.rgb = mix(c.rgb + p2.rgb * particleIntensity, mix(p2.rgb, fogColor, pow(p2.w * 0.04, 2.1)), saturate(p2.g) * particleIntensity); 844 | return c.rgb; 845 | } 846 | 847 | // https://www.shadertoy.com/view/MdfBRX 848 | float Bokeh(vec2 p, vec2 sp, float size, float mi, float blur) 849 | { 850 | float d = length(p - sp); 851 | float c = smoothstep(size, size*(1.-blur), d); 852 | c *= mix(mi, 1., smoothstep(size*.8, size, d)); 853 | return c; 854 | } 855 | 856 | vec3 dirt(vec2 uv, float n) 857 | { 858 | vec2 p = fract(uv * n); 859 | vec2 st = (floor(uv * n) + 0.5) / n; 860 | vec2 rnd = hash(st); 861 | float c = Bokeh(p, vec2(0.5, 0.5) + vec2(0.3) * rnd, 0.2, abs(rnd.y * 0.4) + 0.3, 0.25 + rnd.x * rnd.y * 0.2); 862 | 863 | return vec3(c) * exp(rnd.x * 4.0); 864 | } 865 | 866 | vec3 postProcess(vec2 uv, vec3 col) 867 | { 868 | uv *= 0.5; 869 | 870 | vec3 di = dirt(uv, 3.5); 871 | di += dirt(uv - vec2(0.17), 3.0); 872 | di += dirt(uv- vec2(0.41), 2.75); 873 | di += dirt(uv- vec2(0.3), 2.5); 874 | di += dirt(uv - vec2(0.47), 3.5); 875 | di += dirt(uv- vec2(0.21), 4.0); 876 | di += dirt(uv- vec2(0.6), 4.5); 877 | 878 | float flare = pow(max(0.0, dot(vec3(0.0, 0.0, 1.0), ray)), stageFlareExp * 1.25); 879 | float flare2 = pow(max(0.0, dot(vec3(0.0, 0.0, 1.0), ray)), stageFlareExp); 880 | vec3 f = flare * stageFlareCol + flare2 * di * stageFlareCol * 0.05; 881 | 882 | float sflare = pow(max(0.0, dot(normalize(sp - ro), ray)), travelerFlareExp * 1.25); 883 | float sflare2 = pow(max(0.0, dot(normalize(sp - ro), ray)), travelerFlareExp); 884 | vec3 s = sflare * travelerFlareCol + sflare2 * di * travelerFlareCol * 0.05; 885 | 886 | return col + f * stageFlareIntensity + s * travelerFlareIntensity; 887 | } 888 | 889 | float triPrism( vec3 p, vec2 h ) 890 | { 891 | vec3 q = abs(p); 892 | return max(q.z-h.y,max(q.x*0.866025+p.y*0.5,-p.y)-h.x*0.5); 893 | } 894 | 895 | float Logo1(vec3 p) 896 | { 897 | float d = 99999.9; 898 | d = min(d, triPrism((p + vec3(2.75, -8.0, 0.0)) * vec3(0.76, 1.0, 1.0), vec2(11.45, 0.0))); 899 | d = min(d, triPrism((p + vec3(-11.6, -13.8, 0.0)) * vec3(0.76, -1.0, 1.0), vec2(11.45, 0.0))); 900 | d = min(d, triPrism((p + vec3(16.9, -13.8, 0.0)) * vec3(0.76, -1.0, 1.0), vec2(11.45, 0.0))); 901 | return d; 902 | } 903 | 904 | 905 | float Logo2(vec3 p) 906 | { 907 | float d = 99999.9; 908 | d = min(d, triPrism((p + vec3(5.7, -10.05, 0.0)) * vec3(0.76, 1.0, 1.0), vec2(6.85, 0.0))); 909 | d = min(d, triPrism((p + vec3(-17.0, -10.8, 0.0)) * vec3(0.76, -1.0, 1.0), vec2(8.45, 0.0))); 910 | return d; 911 | } 912 | 913 | float gage(vec2 p) 914 | { 915 | float d = 99999.9; 916 | p.x += 2.8; 917 | p.y += 0.1; 918 | d = min(d, sdRect(p, vec2(14.0, 1.0))); 919 | 920 | float t = clamp(iTime / 30.0 * 13.8, 0.0, 13.8); 921 | p.x -= t; 922 | d = max(d, -sdRect(p, vec2(13.8 - t, 0.8))); 923 | return d; 924 | } 925 | 926 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 927 | { 928 | vec2 p = (fragCoord.xy * 2.0 - iResolution.xy) / min(iResolution.x, iResolution.y); 929 | float t = iTime - 30.; 930 | orgBeat = t * BPM / 60.0; 931 | 932 | float b = orgBeat; 933 | b = mix(b, 226.0 + mod(orgBeat * 2.0, 0.5), step(228.0, orgBeat) * step(orgBeat, 228.5)); 934 | b = mix(b, 229.0 + mod(orgBeat * 2.0, 0.5), step(231.0, orgBeat) * step(orgBeat, 231.5)); 935 | b = mix(b, 227.0 + mod(orgBeat * 2.0, 0.5), step(232.0, orgBeat) * step(orgBeat, 232.5)); 936 | b = mix(b, 238.3 + mod(orgBeat * 4.0, 1.0), step(238.0, orgBeat) * step(orgBeat, 244.0)); 937 | t = b * 60.0 / BPM; 938 | 939 | beat = (t + hash(p).x * 0.0065 * (1.0 - saturate((orgBeat - 230.0) / 4.0)) * step(12., orgBeat)) * BPM / 60.0; 940 | 941 | switchTraveler = mix(2.0, -2.0, saturate(sm(126.0, 172.0, orgBeat, 8.0))); 942 | glitchIntensity = step(44.0, orgBeat) * exp(-3.0 * max(0.0, orgBeat - 44.0)) + 943 | step(144.0, orgBeat) * exp(-3.0 * max(0.0, orgBeat - 144.0)) + 944 | step(176.0, orgBeat) * exp(-3.0 * max(0.0, orgBeat - 176.0)) + 945 | step(228.0, orgBeat) * exp(-3.0 * max(0.0, orgBeat - 228.0)) + 946 | step(231.0, orgBeat) * exp(-3.0 * max(0.0, orgBeat - 231.0)) + 947 | step(232.0, orgBeat) * exp(-3.0 * max(0.0, orgBeat - 232.0)) + 948 | sm2(234.0, 242.65, orgBeat, 4.0, 0.5); 949 | glitchColor = vec3(1.0); 950 | 951 | //// Glitch //// 952 | 953 | vec2 block = floor((p * vec2(100, 400.0)) / vec2(16)); 954 | vec2 uv_noise = block / vec2(64); 955 | uv_noise += floor(vec2(t) * vec2(1234.0, 3543.0)) / vec2(64); 956 | 957 | float block_thresh = pow(fract(t * 1236.0453), 2.0) * .5; 958 | float line_thresh = pow(fract(t * 2236.0453), 3.0) * .6; 959 | 960 | vec2 noise1 = hash(uv_noise) * 0.5 + 0.5; 961 | vec2 noise2 = hash(vec2(uv_noise.y, 0.0)) * 0.5 + 0.5; 962 | 963 | if (noise1.r < block_thresh || 964 | noise2.g < line_thresh) { 965 | float intensity = 1.0 - smoothstep(0.3, 1.0, length(p)); 966 | intensity *= sm(-0.4 + switchTraveler, 0.4 + switchTraveler, p.y, 0.1); 967 | intensity = saturate(intensity + glitchIntensity); 968 | vec2 dist = (fract(uv_noise) - 0.5) * intensity; 969 | fragCoord.x -= dist.x * 350.1 * intensity; 970 | fragCoord.y -= dist.y * 350.2 * intensity; 971 | vec3 h = hash3(vec3(fract(uv_noise) - 0.5, 0.0)) * 2.0; 972 | glitchColor = mix(vec3(1.0), h, intensity); 973 | } 974 | //////////////// 975 | 976 | p = (fragCoord.xy * 2.0 - iResolution.xy) / min(iResolution.x, iResolution.y); 977 | 978 | //// shutdown effect //// 979 | float ttt = (orgBeat - 242.0) * 4.; 980 | float val = min(150.0, mix(mix(mix(1.0, 5.0, saturate(exponentialIn(ttt))), 1.1, saturate(exponentialOut(ttt - 1.0))), 2000.0, saturate(exponentialIn(ttt - 2.0)))); 981 | val = mix(val, 2000.0, saturate(ttt - 3.00)); 982 | p.y *= val; 983 | p.x *= mix(mix(1.0, 3.0, saturate(exponentialOut(ttt - 1.0))), 0.1, saturate(exponentialOut(ttt - 2.0))); 984 | //////////////////////// 985 | 986 | vec2 size = iResolution.xy / min(iResolution.x, iResolution.y); 987 | vec2 pp = p + (vec2(fbm(vec2(beat * 0.1), 1.0), fbm(vec2(beat * 0.1 + 114.514), 1.0)) * 2.0 - 1.0) * .65; 988 | vec3 col = scene(pp) * glitchColor; 989 | 990 | col = postProcess(p, col); 991 | col = saturate(col); 992 | 993 | //// Nega-Posi //// 994 | col = mix(col, 1.0 - col, step(228.0, orgBeat) * step(orgBeat, 228.5)); 995 | col = mix(col, 1.0 - col, step(231.0, orgBeat) * step(orgBeat, 231.5)); 996 | col = mix(col, 1.0 - col, step(232.0, orgBeat) * step(orgBeat, 232.5)); 997 | col = mix(col, 1.0 - col, step(242.0, orgBeat) * step(orgBeat, 244.0)); 998 | /////////////////// 999 | 1000 | //// vignet //// 1001 | vec2 uv = fragCoord.xy / iResolution.xy; 1002 | uv *= 1.0 - uv.yx; 1003 | float vig = uv.x*uv.y * 200.0; 1004 | vig = pow(vig, 0.1); 1005 | col = saturate(pow(col, vec3(1.0 / 2.2))) * vig; 1006 | /////////////// 1007 | 1008 | col = mix(col, vec3(1.), saturate((beat - 251.0) / 4.0)); 1009 | col = mix(col, vec3(0.), saturate((beat - 256.0) / 2.0)); 1010 | 1011 | //// loading screen //// 1012 | vec2 ppp = p; 1013 | p *= 12.5 * 1.33333333; 1014 | p+= vec2(-1.55, 9.5); 1015 | 1016 | float logo1 = 1.0 - smoothstep(0.0, 0.1, Logo1(vec3(p, 0.0))); 1017 | float logo2 = 1.0 - smoothstep(0.0, 0.1, Logo2(vec3(p, 0.0))); 1018 | float g = 1.0 - smoothstep(0.0, 0.1, gage(p)); 1019 | 1020 | col = mix(col, vec3(1.0), 1.0 - smoothstep(1.0, 1.5, t)); 1021 | col = mix(col, vec3(0.23), logo1 * (1.0 - smoothstep(2.0, 3.3, t))); 1022 | col = mix(col, vec3(0.85, 0.35, 0.35), logo2 * (1.0 - smoothstep(2.0, 3.3, t))); 1023 | col = mix(col, vec3(0.85, 0.35, 0.35), g * (1.0 - smoothstep(1.0, 1.5, t))); 1024 | /////////////////////// 1025 | 1026 | col = mix(col, vec3(1.), smoothstep(1.9, 2.0, ttt)); 1027 | col = mix(col, vec3(0.), saturate(step(size.y, ppp.y) + step(ppp.y, -size.y) + step(size.x, ppp.x) + step(ppp.x, -size.x) + step(3.3, ttt))); 1028 | 1029 | fragColor = vec4(col, 1.0); 1030 | } --------------------------------------------------------------------------------