// 0 tokens, still streaming // LGTM: looks green to me // my context window is one glyph // TODO: ask the TODO agent // works on my GPU // << REWIND NORTHWEST uniform float seconds; uniform int columns; uniform float lineWidths[SOURCE_LINES]; uniform float atlasColumns; uniform vec2 frustum; varying vec2 glyphUv; varying vec4 phosphor; float hash(float seed) { return fract(sin(seed * 127.1 + 31.7) * 4375.5453); } void main() { int instance = gl_InstanceID; float col = float(instance % columns); float row = float(instance / columns) - 1.0; float depth = hash(col + 8.0); float range = mix(8.0, 64.0, depth); float pitch = 2.0 * range * frustum.y * mix(0.026, 0.0105, depth); float period = atlasColumns + 4.0 + floor(13.0 * hash(col + 3.1)); float travel = seconds * mix(3.6, 2.2, depth) + period * hash(col); float sourceRow = row - floor(travel); float pass = -floor(sourceRow / period); float letter = mod(sourceRow, period); // Select one line for the lifetime of a falling stream. float sequence = col + pass; bool comment = HEADER_LINES > 0 && mod(sequence, 7.0) == 0.0; int line; if (comment) { line = int(mod(col + floor(sequence / 7.0), float(HEADER_LINES))); } else { line = HEADER_LINES + int(hash(col + 3.6 * pass) * float(SOURCE_LINES - HEADER_LINES)); } float width = lineWidths[line]; if (letter >= width) { gl_Position = vec4(2.0, 2.0, 0.0, 1.0); return; } glyphUv = vec2((letter + uv.x) / atlasColumns, 1.0 - (float(line) + 1.0 - uv.y) / float(SOURCE_LINES)); // Spread each depth layer across the view, with room for the camera to drift. vec2 reach = range * frustum; float x = (hash(col + 1.7) * 2.0 - 1.0) * (reach.x * 1.2 + 2.5); float y = reach.y * 1.1 + 2.0 - (row + fract(travel) + hash(col + 2.4)) * pitch; vec3 glyph = vec3(position.xy * vec2(0.6, 1.0) * pitch, 0.0); gl_Position = projectionMatrix * modelViewMatrix * vec4(vec3(x, y, -range) + glyph, 1.0); vec2 screen = vec2(0.5, -0.5) * gl_Position.xy / gl_Position.w + 0.5; float margin = smoothstep(0.11, 0.53, length((screen - vec2(0.25, 0.35)) * vec2(1.45, 1.0))); float tail = letter / (width - 1.0); float head = smoothstep(width - 3.5, width - 1.0, letter); float ink = (0.32 + 0.28 * tail + 0.40 * head) * mix(1.0, 0.34, depth) * mix(0.26, 1.0, margin); vec3 tip = vec3(0.76, 1.0, 0.84); vec3 color = mix(vec3(0.23, 0.70, 0.53), tip, 0.18 * tail + 0.82 * head); color = mix(color, vec3(0.16, 0.45, 0.48), 0.55 * depth); if (comment) color += vec3(0.02, -0.015, 0.12); phosphor = vec4(color, ink); }