fork a shader
Write or paste an ISF shader (GLSL ES with a /*{ ... }*/ header). It compiles + renders in yer browser. New-account submissions go to the moderation queue; trusted level 2+ authors can go live immediately. Everything is CC0. Got a file first? preview it locally →
A model marks this as witnessed_generation (honest AI provenance). Leave blank if you hand-authored it.
/*{ "DESCRIPTION": "first person: live coding at night, banging on the keyboard while the screen draws weird shapes under the code. turn fury past 2/3 and every so often he headbutts the keyboard three times. drag to steer his gaze.", "CREDIT": "made in glslop studio", "CATEGORIES": ["scene", "generative", "interactive"], "INPUTS": [ { "NAME": "look", "TYPE": "point2D", "DEFAULT": [0.5, 0.5], "LABEL": "gaze (drag)" }, { "NAME": "tempo", "TYPE": "float", "DEFAULT": 1.0, "MIN": 0.2, "MAX": 3.0, "LABEL": "typing tempo" }, { "NAME": "fury", "TYPE": "float", "DEFAULT": 0.45, "MIN": 0.0, "MAX": 1.0, "LABEL": "fury" }, { "NAME": "glances", "TYPE": "float", "DEFAULT": 0.6, "MIN": 0.0, "MAX": 1.0, "LABEL": "glances down" }, { "NAME": "vibe", "TYPE": "float", "DEFAULT": 0.0, "MIN": 0.0, "MAX": 1.0, "LABEL": "screen palette" }, { "NAME": "lamp", "TYPE": "float", "DEFAULT": 0.7, "MIN": 0.0, "MAX": 1.0, "LABEL": "desk lamp" } ] }*/ #define PI 3.14159265 float h11(float p) { p = fract(p * 0.1031); p *= p + 33.33; p *= p + p; return fract(p); } float h21(vec2 p) { vec3 q = fract(vec3(p.xyx) * 0.1031); q += dot(q, q.yzx + 33.33); return fract((q.x + q.y) * q.z); } float n11(float x) { float i = floor(x), f = fract(x); f = f * f * (3.0 - 2.0 * f); return mix(h11(i), h11(i + 1.0), f) * 2.0 - 1.0; } vec3 pal(float t) { return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67))); } mat2 rot(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); } // ray vs axis-aligned ellipsoid centred at the origin; -1 on a miss float eHit(vec3 o, vec3 d, vec3 r) { vec3 oc = o / r, dc = d / r; float a = dot(dc, dc), b = dot(oc, dc), c = dot(oc, oc) - 1.0; float h = b * b - a * c; if (h < 0.0) return -1.0; return (-b - sqrt(h)) / a; } // ray vs box; -1 on a miss. nrm = the face normal that was hit float bHit(vec3 o, vec3 d, vec3 bmin, vec3 bmax, out vec3 nrm) { vec3 inv = 1.0 / d; vec3 t0 = (bmin - o) * inv, t1 = (bmax - o) * inv; vec3 tn3 = min(t0, t1), tf3 = max(t0, t1); float tn = max(max(tn3.x, tn3.y), tn3.z), tf = min(min(tf3.x, tf3.y), tf3.z); nrm = -sign(d) * step(tn3.yzx, tn3.xyz) * step(tn3.zxy, tn3.xyz); return (tn > tf || tn < 0.0) ? -1.0 : tn; } // ray vs capsule from pa to pb (after iq); -1 on a miss float capHit(vec3 ro, vec3 rd, vec3 pa, vec3 pb, float r) { vec3 ba = pb - pa, oa = ro - pa; float baba = dot(ba, ba), bard = dot(ba, rd), baoa = dot(ba, oa), rdoa = dot(rd, oa), oaoa = dot(oa, oa); float a = baba - bard * bard, b = baba * rdoa - baoa * bard, c = baba * oaoa - baoa * baoa - r * r * baba; float h = b * b - a * c; if (h >= 0.0) { float t = (-b - sqrt(h)) / a; float y = baoa + t * bard; if (y > 0.0 && y < baba) return t; vec3 oc = y <= 0.0 ? oa : ro - pb; b = dot(rd, oc); c = dot(oc, oc) - r * r; h = b * b - c; if (h > 0.0) return -b - sqrt(h); } return -1.0; } // cables (monitor to tower, keyboard to tower, lamp to wall) and the lamp's arm, as capsules void seg(int i, out vec3 a, out vec3 b, out float r) { r = 0.0055; if (i == 0) { a = vec3(0.0, 0.09, 0.615); b = vec3(0.02, 0.006, 0.7); } else if (i == 1) { a = vec3(0.02, 0.006, 0.7); b = vec3(0.3, 0.006, 0.9); } else if (i == 2) { a = vec3(0.3, 0.006, 0.9); b = vec3(0.62, 0.006, 0.92); } else if (i == 3) { a = vec3(0.62, 0.006, 0.92); b = vec3(0.69, 0.12, 0.8); } else if (i == 4) { a = vec3(0.04, 0.012, 0.222); b = vec3(0.07, 0.006, 0.5); r = 0.0045; } else if (i == 5) { a = vec3(0.07, 0.006, 0.5); b = vec3(0.2, 0.006, 0.85); r = 0.0045; } else if (i == 6) { a = vec3(0.2, 0.006, 0.85); b = vec3(0.67, 0.05, 0.82); r = 0.0045; } else if (i == 7) { a = vec3(-0.62, 0.012, 0.62); b = vec3(-0.6, 0.3, 0.68); r = 0.008; } else if (i == 8) { a = vec3(-0.6, 0.3, 0.68); b = vec3(-0.48, 0.415, 0.51); r = 0.008; } else { a = vec3(-0.62, 0.006, 0.66); b = vec3(-0.25, 0.006, 0.95); } } // typing clock, shared by the hands, the keyboard and the screen float gTyped; // characters typed so far float gLine; // index of the line being typed float gCol; // ticks into that line (he stops to think once the line is done) float gTyping; // 1 while actually typing vec3 gHand0, gHand1; float gSlam, gDown, gFlash, gImpK, gSlamCyc; // the headbutt: how far into it, head down, key flash float lineLen(float id) { return 6.0 + floor(h11(id * 1.37 + 0.5) * 22.0); } float lineIndent(float id) { return 2.0 * floor(h11(id * 2.71 + 0.2) * 3.0); } // lift then slam: rises slowly, comes down fast float slam(float ph) { return smoothstep(0.0, 1.0, min(ph / 0.7, (1.0 - ph) / 0.3)); } // the scene's ellipsoids: two hands (palm, four fingers, a hoodie forearm), a rubber duck, a mouse void part(int i, out vec3 c, out vec3 r) { if (i < 12) { float h = i < 6 ? 0.0 : 1.0; float k = float(i) - h * 6.0; float side = h * 2.0 - 1.0; vec3 base = h < 0.5 ? gHand0 : gHand1; if (k < 0.5) { c = base; r = vec3(0.046, 0.018, 0.05); } else if (k < 4.5) { float f = k - 2.5; float tap = max(0.0, sin(gTyped * 2.3 + k * 1.7 + h * 3.1)) * 0.014 * (0.4 + fury) * gTyping; c = base + vec3(f * 0.021, -0.016 + tap, 0.058 - abs(f) * 0.007); r = vec3(0.0095, 0.009, 0.028); } else { c = base + vec3(side * 0.03, 0.03, -0.25); r = vec3(0.05, 0.043, 0.22); } } else if (i == 12) { c = vec3(-0.47, 0.032, 0.40); r = vec3(0.042, 0.032, 0.036); } else if (i == 13) { c = vec3(-0.47, 0.078, 0.385); r = vec3(0.024); } else if (i == 14) { c = vec3(0.36, 0.0, 0.11); r = vec3(0.032, 0.02, 0.055); } else if (i == 15) { c = vec3(-0.47, 0.39, 0.49); r = vec3(0.065, 0.04, 0.065); } else { c = vec3(-0.62, 0.008, 0.62); r = vec3(0.06, 0.011, 0.06); } } // what's on the monitor: s in [0,1]^2 vec3 screenContent(vec2 s) { float T = TIME; vec2 q = (s - 0.5) * vec2(1.77, 1.0); vec3 col = vec3(0.015, 0.012, 0.03); col += 0.025 * pal(vibe + 0.5 + length(q) * 0.6 - T * 0.05) * (0.5 + 0.5 * sin(length(q - vec2(0.3 * sin(T * 0.2), 0.0)) * 40.0 - T * 2.0)); // the sketch: shapes change every two lines of code, like re-evaluating it float era = floor(gLine / 2.0); for (int i = 0; i < 6; i++) { float fi = float(i); float seed = fi * 7.13 + era * 3.71; vec2 c = vec2(sin(T * (0.31 + 0.11 * fi) + fi * 2.1) * 0.6, cos(T * (0.23 + 0.07 * fi) + fi * 1.3) * 0.3); vec2 lq = rot(T * (h11(seed) - 0.5) * 2.0 + fi) * (q - c); float sz = (0.06 + 0.08 * h11(seed + 1.0)) * (1.0 + 0.25 * sin(T * 3.0 + fi * 1.7)); float kind = h11(seed + 2.0); float d; if (kind < 0.33) d = length(lq) - sz; else if (kind < 0.66) d = max(abs(lq.x), abs(lq.y)) - sz * 0.85; else d = length(lq) - sz * (0.75 + 0.3 * cos(5.0 * atan(lq.y, lq.x) + T * 2.0)); vec3 sc = pal(vibe + h11(seed + 3.0) * 0.7 + T * 0.02); float ring = step(0.5, h11(seed + 4.0)); float fill = mix(smoothstep(0.004, -0.004, d), smoothstep(0.012, 0.0, abs(d) - 0.006), ring); col = mix(col, sc, fill * 0.9); col += sc * 0.002 / (abs(d) + 0.004); } // the code, hydra style: dark bands behind each line, cursor on the line being typed float rowH = 1.0 / 11.0, cw = rowH * 0.48; vec2 tp = vec2(s.x * 1.77 - 0.05, (1.0 - s.y) - 0.04); float row = floor(tp.y / rowH), ci = floor(tp.x / cw); vec2 f = vec2(fract(tp.x / cw), fract(tp.y / rowH)); float cur = 9.0; float lid = gLine - (cur - row); if (row >= 0.0 && row <= cur && lid >= 0.0 && tp.x > 0.0) { float len = lineLen(lid), ind = lineIndent(lid); bool isCur = abs(row - cur) < 0.5; float shown = isCur ? min(gCol, len) : len; if (ci >= ind - 1.0 && ci < ind + shown + 1.0) col = mix(col, vec3(0.0), 0.62); if (ci >= ind && ci < ind + shown) { float word = floor((ci - ind + floor(h11(lid) * 4.0)) / (3.0 + floor(h11(lid * 5.3) * 4.0))); float space = step(h21(vec2(lid, ci) * 1.7), 0.14); float code = floor(h21(vec2(lid * 13.1, ci)) * 997.0); vec2 g = (f - vec2(0.2, 0.18)) / vec2(0.6, 0.64); if (g.x > 0.0 && g.x < 1.0 && g.y > 0.0 && g.y < 1.0) { vec2 bit = floor(g * vec2(3.0, 5.0)); float on = step(0.45, h11(code + bit.x * 3.1 + bit.y * 7.7)); float tk = h11(lid * 3.3 + word * 1.9); vec3 tc = tk < 0.25 ? vec3(1.0, 0.36, 0.75) : tk < 0.45 ? vec3(0.55, 1.0, 0.45) : tk < 0.6 ? vec3(1.0, 0.72, 0.3) : vec3(0.88, 0.9, 0.95); col = mix(col, tc, on * (1.0 - space)); } } if (isCur && abs(ci - (ind + shown)) < 0.5 && fract(T * 1.8) < 0.6 && f.y > 0.1 && f.y < 0.9) col = mix(col, vec3(0.9), 0.85); } // every second line "evaluates": a quick flash col += vec3(0.2) * exp(-gCol * 0.9) * step(mod(gLine, 2.0), 0.5); return col; } // soft contact shadow of the hands and forearms on the desk and keyboard float contactShadow(vec3 p) { float s = 1.0; for (int h = 0; h < 2; h++) { vec3 b = h == 0 ? gHand0 : gHand1; float side = float(h) * 2.0 - 1.0; float lift = b.y - 0.05; vec2 d = (p.xz - b.xz - vec2(0.0, 0.03)) / vec2(0.07, 0.09); s *= 1.0 - 0.55 * exp(-dot(d, d) * 1.5) / (1.0 + lift * 30.0); vec2 a = (p.xz - b.xz - vec2(side * 0.03, -0.25)) / vec2(0.07, 0.24); s *= 1.0 - 0.4 * exp(-dot(a, a) * 1.5); } return s; } void main() { float T = TIME; gTyped = T * tempo * (6.0 + 6.0 * fury); gLine = floor(gTyped / 30.0) + 14.0; gCol = mod(gTyped, 30.0); gTyping = step(gCol, lineLen(gLine)); // now and then, when fury is past 2/3: stop typing and headbutt the keyboard three times float sCyc = floor(T / 15.0), lt = mod(T, 15.0) - 8.0; float sOn = step(0.667, fury) * step(h11(sCyc * 5.3 + 1.0), 0.8); gSlamCyc = sCyc; gSlam = sOn * smoothstep(0.0, 0.4, lt) * (1.0 - smoothstep(3.2, 3.8, lt)); gDown = 0.0; for (int k = 0; k < 3; k++) { float x = lt - 0.9 - float(k) * 0.75; gDown = max(gDown, x < 0.0 ? pow(smoothstep(-0.38, 0.0, x), 2.0) : 1.0 - smoothstep(0.0, 0.32, x)); } gDown *= gSlam; gImpK = clamp(floor((lt - 0.9) / 0.75), 0.0, 2.0); float since = lt - 0.9 - gImpK * 0.75; gFlash = sOn * step(0.0, since) * exp(-since * 4.0) * step(lt, 3.5); gTyping *= 1.0 - gSlam; float amp = (0.012 + 0.05 * fury) * gTyping; gHand0 = vec3(-0.105, 0.05 + slam(fract(gTyped * 0.5)) * amp, 0.13); gHand1 = vec3(0.105, 0.05 + slam(fract(gTyped * 0.5 + 0.5)) * amp, 0.13); // where he looks: mostly the screen, now and then down at his hands or the mug float cyc = floor(T / 6.0), ph = fract(T / 6.0); float glance = smoothstep(0.62, 0.70, ph) * (1.0 - smoothstep(0.84, 0.92, ph)) * step(h11(cyc * 1.7 + 0.3), glances); vec3 tScreen = vec3(n11(T * 0.27) * 0.12, 0.27 + n11(T * 0.21 + 4.0) * 0.04, 0.55); vec3 tDesk = h11(cyc * 3.1) < 0.7 ? vec3(0.0, 0.03, 0.17) : vec3(0.5, 0.08, 0.34); vec3 target = mix(tScreen, tDesk, glance); target.xy += (look - 0.5) * vec2(1.2, 0.8); // handheld wobble, plus a jolt on every hard keystroke float jolt = gTyping * pow(1.0 - fract(gTyped), 6.0) * fury; vec3 ro = vec3(n11(T * 0.6 + 2.0) * 0.01, 0.42 + n11(T * 0.8 + 7.0) * 0.008 - jolt * 0.004, -0.30); target += vec3(n11(T * 1.9), n11(T * 1.6 + 3.0), 0.0) * 0.006 * (1.0 + 2.0 * fury); vec3 fw = normalize(target - ro); // headbutt pose, in the side view (y up, z forward): hips slide in, the spine leans from the hips, // the neck bends from the top of the spine, and the eye rides on the head. Each hit swings the // head down and forward along an arc; between hits it rears back up. At rest this is the normal eye. float lean = gSlam * 0.45 + gDown * 0.29; // spine angle from vertical float neck = gSlam * 0.25 + gDown * 0.75; // extra bend at the neck vec2 hipYZ = vec2(-0.10, -0.45 + 0.12 * gSlam); vec2 spine = rot(-lean) * vec2(0.43, 0.08); // rot(-x) turns (up, forward) towards forward vec2 eyeYZ = hipYZ + spine + rot(-(lean + neck)) * vec2(0.09, 0.07); vec3 eyeP = vec3(n11(T * 0.6 + 2.0) * 0.01 + gFlash * 0.015 * (h11(gImpK + sCyc) - 0.5), eyeYZ.x, eyeYZ.y); vec2 lookYZ = rot(-min(lean + neck, 1.35)) * normalize(vec2(-0.17, 0.98)); vec3 headFw = normalize(vec3((h11(gImpK * 1.7 + sCyc) - 0.5) * gFlash * 0.08, lookYZ.x, lookYZ.y)); ro = mix(ro, eyeP, gSlam); fw = normalize(mix(fw, headFw, gSlam)); vec3 rt = normalize(cross(vec3(0.0, 1.0, 0.0), fw)); vec3 up = cross(fw, rt); vec2 uv = (gl_FragCoord.xy - 0.5 * RENDERSIZE) / RENDERSIZE.y; uv = rot(n11(T * 0.45 + 11.0) * 0.03 + gFlash * 0.1 * (h11(gImpK + sCyc * 3.0) - 0.5)) * uv; vec3 rd = normalize(fw * 0.62 + rt * uv.x + up * uv.y); // trace: planes, a cylinder, ellipsoids float tb = 1e9, t; int id = 0, hp = 0; vec3 hc = vec3(0.0), hr = vec3(1.0), p; if (rd.y < 0.0) { t = -ro.y / rd.y; p = ro + rd * t; if (p.z > -0.2 && p.z < 1.0 && abs(p.x) < 1.6) { tb = t; id = 1; } // desk t = (-0.75 - ro.y) / rd.y; if (t < tb) { tb = t; id = 2; } // floor t = (0.022 - ro.y) / rd.y; p = ro + rd * t; if (abs(p.x) < 0.24 && p.z > 0.05 && p.z < 0.22 && t < tb) { tb = t; id = 7; } // keyboard top } if (rd.z > 0.0) { t = (1.0 - ro.z) / rd.z; if (t < tb) { tb = t; id = 3; } // wall t = (-0.2 - ro.z) / rd.z; p = ro + rd * t; if (p.y > -0.045 && p.y < 0.0 && t < tb) { tb = t; id = 4; } // desk front edge t = (0.55 - ro.z) / rd.z; p = ro + rd * t; if (abs(p.x) < 0.37 && p.y > 0.152 && p.y < 0.583 && t < tb) { tb = t; id = 5; } // monitor t = (0.6 - ro.z) / rd.z; p = ro + rd * t; if (abs(p.x) < 0.04 && p.y > 0.0 && p.y < 0.16 && t < tb) { tb = t; id = 6; } // monitor neck t = (0.05 - ro.z) / rd.z; p = ro + rd * t; if (abs(p.x) < 0.24 && p.y > 0.0 && p.y < 0.022 && t < tb) { tb = t; id = 8; } // keyboard front } { vec2 oc = ro.xz - vec2(0.5, 0.34); float a = dot(rd.xz, rd.xz), b = dot(oc, rd.xz), c = dot(oc, oc) - 0.045 * 0.045; float h = b * b - a * c; if (h > 0.0) { float t0 = (-b - sqrt(h)) / a, y0 = ro.y + rd.y * t0; if (y0 > 0.0 && y0 < 0.11 && t0 < tb) { tb = t0; id = 9; } // mug else if (y0 >= 0.11) { float t1 = (0.095 - ro.y) / rd.y; vec2 m = ro.xz + rd.xz * t1 - vec2(0.5, 0.34); if (dot(m, m) < 0.041 * 0.041 && t1 < tb) { tb = t1; id = 10; } // coffee } } } vec3 tN = vec3(0.0), sa = vec3(0.0), sb = vec3(0.0); float sr = 1.0; { vec3 bn; float tbx = bHit(ro, rd, vec3(0.6, 0.0, 0.3), vec3(0.79, 0.43, 0.78), bn); if (tbx > 0.0 && tbx < tb) { tb = tbx; id = 11; tN = bn; } // computer tower } for (int i = 0; i < 10; i++) { vec3 a, b; float r; seg(i, a, b, r); float tc = capHit(ro, rd, a, b, r); if (tc > 0.0 && tc < tb) { tb = tc; id = 12; sa = a; sb = b; sr = r; hp = i; } // cables, lamp arm } for (int i = 0; i < 17; i++) { vec3 c, r; part(i, c, r); float te = eHit(ro - c, rd, r); if (te > 0.0 && te < tb) { tb = te; id = 20; hc = c; hr = r; hp = i; } } // surfaces p = ro + rd * tb; vec3 n = vec3(0.0, 0.0, -1.0), alb = vec3(0.1), emit = vec3(0.0); float spec = 0.0, ao = 1.0; if (id == 1) { n = vec3(0.0, 1.0, 0.0); float grain = 0.5 + 0.5 * sin(p.x * 55.0 + sin(p.z * 9.0 + p.x * 3.0) * 4.0); alb = mix(vec3(0.26, 0.15, 0.09), vec3(0.36, 0.22, 0.12), grain); vec2 nb = rot(0.25) * (p.xz - vec2(-0.55, 0.12)); if (abs(nb.x) < 0.11 && abs(nb.y) < 0.15) { alb = vec3(0.86, 0.84, 0.78); if (fract(nb.y * 60.0) < 0.1) alb = vec3(0.55, 0.65, 0.85); if (nb.x < -0.095) alb = vec3(0.7, 0.18, 0.2); if (abs(nb.y - 0.05 + 0.02 * sin(nb.x * 90.0)) < 0.004 && nb.x > -0.06 && nb.x < 0.07) alb = vec3(0.15, 0.15, 0.3); } vec2 pn = rot(-0.6) * (p.xz - vec2(-0.36, 0.0)); if (abs(pn.x) < 0.07 && abs(pn.y) < 0.005) alb = vec3(0.1, 0.12, 0.55); if (length((p.xz - vec2(0.0, 0.62)) / vec2(0.16, 0.09)) < 1.0) alb = vec3(0.05); if (abs(p.x - 0.36) < 0.11 && abs(p.z - 0.11) < 0.09) alb = vec3(0.05, 0.05, 0.07); // mouse pad ao = contactShadow(p); } else if (id == 2) { n = vec3(0.0, 1.0, 0.0); alb = vec3(0.1, 0.09, 0.1); } else if (id == 3) { alb = vec3(0.15, 0.16, 0.21); if (abs(p.x + 0.8) < 0.2 && abs(p.y - 0.75) < 0.27) alb = pal(vibe + floor(p.y * 14.0) / 14.0 * 0.5 + 0.1) * 0.7; if (abs(p.x - 0.85) < 0.16 && abs(p.y - 0.62) < 0.12) alb = vec3(0.8, 0.8, 0.75) * (0.7 + 0.3 * step(0.5, fract(p.x * 30.0 + p.y * 30.0))); } else if (id == 4) { alb = vec3(0.2, 0.12, 0.07); } else if (id == 5) { vec2 s = vec2((p.x + 0.35) / 0.7, (p.y - 0.17) / 0.395); alb = vec3(0.035); spec = 0.6; if (s.x > 0.0 && s.x < 1.0 && s.y > 0.0 && s.y < 1.0) { emit = screenContent(s) * 1.5; alb = vec3(0.0); } vec2 n1 = rot(0.12) * (p.xy - vec2(0.33, 0.56)); vec2 n2 = rot(-0.08) * (p.xy - vec2(-0.355, 0.24)); if (max(abs(n1.x), abs(n1.y)) < 0.035) { alb = vec3(0.95, 0.85, 0.25); emit = vec3(0.0); spec = 0.0; if (fract(n1.y * 90.0) < 0.15 && abs(n1.x) < 0.025) alb *= 0.6; } if (max(abs(n2.x), abs(n2.y)) < 0.03) { alb = vec3(1.0, 0.45, 0.7); emit = vec3(0.0); spec = 0.0; } } else if (id == 6) { alb = vec3(0.05); } else if (id == 7) { n = vec3(0.0, 1.0, 0.0); vec2 kp = vec2((p.x + 0.24) / 0.48 * 16.0, (p.z - 0.05) / 0.17 * 5.5); vec2 kc = floor(kp), kf = fract(kp); float gapx = step(0.08, kf.x) * step(kf.x, 0.92); if (kc.y < 0.5 && kc.x > 4.5 && kc.x < 11.5) gapx = 1.0 - step(abs(kp.x - 8.0), 3.42) * 0.0 - (1.0 - step(abs(kp.x - 8.0), 3.42)); // spacebar float key = gapx * step(0.1, kf.y) * step(kf.y, 0.9); vec2 kid = kc; if (kc.y < 0.5 && kc.x > 4.5 && kc.x < 11.5) kid = vec2(8.0, 0.0); float pressed = step(0.86, h21(kid + floor(gTyped) * vec2(1.3, 2.7))) * gTyping; vec3 rgb = pal(kc.x * 0.06 - T * 0.4 + vibe); alb = mix(vec3(0.02), vec3(0.08), key); float legend = step(abs(kf.x - 0.35), 0.09) * step(abs(kf.y - 0.62), 0.1) * key; emit = rgb * (0.03 * key + 0.5 * pressed * key + 0.12 * (1.0 - key) + 0.25 * legend); if (gFlash > 0.001) { vec2 kc0 = vec2(8.0 + (h11(gImpK * 3.7 + gSlamCyc) - 0.5) * 6.0, 2.6 + (h11(gImpK * 5.1 + gSlamCyc * 1.3) - 0.5) * 2.0); float hitk = step(length((kid + 0.5 - kc0) * vec2(1.0, 1.5)), 2.4) * step(0.4, h21(kid + gImpK * 7.1 + gSlamCyc * 3.3)); emit += mix(rgb, vec3(1.0), 0.6) * hitk * gFlash * key * 2.5; } ao = contactShadow(p); } else if (id == 8) { alb = vec3(0.04); emit = pal(p.x * 2.0 - T * 0.4 + vibe) * 0.15; } else if (id == 9) { n = normalize(vec3(p.x - 0.5, 0.0, p.z - 0.34)); alb = vec3(0.85, 0.18, 0.5); spec = 0.5; if (abs(p.y - 0.06) < 0.012) alb = vec3(0.92); } else if (id == 10) { n = vec3(0.0, 1.0, 0.0); alb = vec3(0.07, 0.035, 0.015); spec = 1.0; } else if (id == 11) { n = tN; alb = vec3(0.045, 0.045, 0.055); spec = 0.3; if (n.z < -0.5) { // front panel vec2 f = vec2((p.x - 0.6) / 0.19, p.y / 0.43); if (f.y < 0.55 && fract(f.y * 40.0) < 0.35 && f.x > 0.2 && f.x < 0.85) alb = vec3(0.012); float pw = length((f - vec2(0.55, 0.86)) * vec2(0.19, 0.43)); emit = vec3(0.2, 0.5, 1.0) * smoothstep(0.009, 0.006, pw) * smoothstep(0.003, 0.005, pw) * 2.0; float hdd = step(0.5, h11(floor(T * 14.0))) * step(0.5, gTyping + gSlam); emit += vec3(1.0, 0.25, 0.1) * hdd * smoothstep(0.004, 0.002, length((f - vec2(0.55, 0.79)) * vec2(0.19, 0.43))) * 2.0; emit += pal(f.y * 0.6 - T * 0.3 + vibe) * step(abs(f.x - 0.07), 0.025) * 0.8; } else if (n.x < -0.5) { // glass side, two fans glowing inside vec2 g = p.zy; alb = vec3(0.02, 0.02, 0.03); spec = 0.8; for (int k = 0; k < 3; k++) { float fk = float(k); vec2 c = k < 2 ? vec2(0.355, 0.1 + fk * 0.15) : vec2(0.72, 0.35); float rr = k < 2 ? 0.058 : 0.045; float d = length(g - c); float blades = 0.5 + 0.5 * sin(atan(g.y - c.y, g.x - c.x) * 7.0 - T * 25.0); emit += pal(vibe + fk * 0.3 - T * 0.2) * (smoothstep(0.007, 0.0, abs(d - rr)) * 1.2 + step(d, rr - 0.004) * blades * 0.08); } vec2 gq = g - vec2(0.56, 0.2); if (abs(gq.x) < 0.14 && abs(gq.y) < 0.022) { // graphics card alb = vec3(0.07, 0.07, 0.08); emit += pal(vibe + gq.x * 3.0 - T * 0.3) * step(gq.y, -0.016) * 1.2; } if (abs(g.x - 0.62) < 0.035 && abs(g.y - 0.33) < 0.035) alb = vec3(0.1, 0.1, 0.11); // cpu cooler } } else if (id == 12) { vec3 ba = sb - sa, pa = p - sa; n = (pa - ba * clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0)) / sr; bool arm = hp == 7 || hp == 8; alb = arm ? vec3(0.55, 0.56, 0.6) : (hp >= 4 && hp <= 6) ? vec3(0.3, 0.12, 0.45) : vec3(0.025); spec = arm ? 0.9 : 0.25; } else if (id == 20) { n = normalize((p - hc) / (hr * hr)); if (hp < 12) { int k = hp < 6 ? hp : hp - 6; alb = vec3(0.78, 0.52, 0.4); if (k == 5) { alb = vec3(0.09, 0.1, 0.13); if (p.z > hc.z + 0.17) alb = vec3(0.13, 0.14, 0.18); } // keyboard glow on the undersides of the hands emit = alb * pal(T * 0.4 + vibe) * 0.12 * max(0.3 - n.y, 0.0) * exp(-max(p.y - 0.02, 0.0) * 30.0); } else if (hp < 14) { alb = vec3(1.0, 0.8, 0.1); if (hp == 13 && n.z < -0.6 && p.y < hc.y - 0.002) alb = vec3(1.0, 0.42, 0.05); if (hp == 13 && n.z < -0.3 && abs(abs(p.x - hc.x) - 0.01) < 0.004 && abs(p.y - hc.y - 0.007) < 0.004) alb = vec3(0.02); } else if (hp == 14) { alb = vec3(0.05); spec = 0.5; emit = pal(-T * 0.4 + vibe) * 0.4 * step(abs(p.x - hc.x), 0.003) * step(0.0, n.y); } else { // lamp shade (glowing rim) and base alb = vec3(0.08, 0.32, 0.3); spec = 0.6; if (hp == 15 && p.y < hc.y - 0.018) { alb = vec3(0.0); emit = vec3(1.0, 0.82, 0.55) * (0.4 + 2.5 * lamp); } } } // light: the screen is the main lamp; a dim warm room light; a cold night ambient vec3 scr = 0.1 + 0.35 * pal(vibe + T * 0.02 + 0.2) + 0.25 * exp(-gCol * 0.9) * step(mod(gLine, 2.0), 0.5); vec3 L = vec3(0.0, 0.37, 0.53) - p; float dl = length(L); L /= dl; float front = step(p.z, 0.545); float fall = front / (1.0 + dl * dl * 5.0); vec3 col = alb * scr * max(dot(n, L), 0.0) * fall * 2.4; vec3 lampC = vec3(1.0, 0.8, 0.55); vec3 Lp = vec3(-0.46, 0.355, 0.48) - p; float dlp = length(Lp); Lp /= dlp; float cone = smoothstep(0.45, 0.85, dot(-Lp, normalize(vec3(0.3, -1.0, -0.35)))); col += alb * lampC * lamp * (cone * 1.6 + 0.12) * max(dot(n, Lp), 0.0) / (1.0 + dlp * dlp * 12.0); col += alb * lampC * lamp * 0.05; col += alb * vec3(0.05, 0.06, 0.09) * 0.5; col *= ao; col += scr * pow(max(dot(n, normalize(L - rd)), 0.0), 40.0) * spec * fall; col += emit; { // a soft glow around the bulb vec3 bulb = vec3(-0.47, 0.36, 0.49) - ro; float along = max(dot(bulb, rd), 0.0); float miss = length(bulb - rd * along); if (along < tb + 0.01) col += lampC * lamp * 0.00012 / (miss * miss + 0.0004); } // lens: vignette, tonemap, grain vec2 sv = gl_FragCoord.xy / RENDERSIZE; col *= 0.35 + 0.65 * pow(16.0 * sv.x * sv.y * (1.0 - sv.x) * (1.0 - sv.y), 0.25); col = col / (1.0 + col); col = pow(col, vec3(0.4545)); col += (h21(gl_FragCoord.xy + fract(T) * 100.0) - 0.5) * 0.03; gl_FragColor = vec4(col, 1.0); }
forking #6qapphkp — lineage will be recorded.
renders in YOUR browser. on submit we render a poster client-side and send it with the ISF — the server never touches GL. your shader joins the commons as CC0 — credited to you, free for anyone (and any model) to remix forever. that's the whole point. it's permanent: once it's public, CC0 has no take-backs. by submitting you attest you have the right to release it as CC0.