shader_type spatial; render_mode blend_mix, unshaded, cull_disabled, shadows_disabled; // The floor of cyberspace under the playmat: a neon grid on black that fades into the void, with // a slow scan ring running out from the table. It continues the mat's grid (same pitch, same // origin), so the mat reads as a lit part of one floor. uniform vec4 line_color : source_color = vec4(0.133, 0.827, 0.933, 1.0); uniform vec3 floor_color : source_color = vec3(0.004, 0.008, 0.011); uniform vec2 pitch = vec2(2.96, 2.18); uniform vec2 origin = vec2(0.0, 1.09); uniform float width = 0.014; uniform float energy = 0.3; // The grid fades between these distances from the table's centre. uniform float fade_from = 6.0; uniform float fade_to = 48.0; uniform float scan_speed = 9.0; uniform float scan_period = 9.0; varying vec3 world_pos; void vertex() { world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; } void fragment() { vec2 p = world_pos.xz - origin; vec2 g = abs(fract(p / pitch + 0.5) - 0.5) * pitch; vec2 aa = fwidth(p) * 1.5; vec2 l = 1.0 - smoothstep(vec2(width) - aa, vec2(width) + aa, g); float line = max(l.x, l.y); float r = length(world_pos.xz); float fade = 1.0 - smoothstep(fade_from, fade_to, r); // Lines get thin far away; fade them by their screen size too so they don't shimmer. fade *= clamp(1.2 - length(aa) * 3.0, 0.0, 1.0); float ring_r = mod(TIME * scan_speed, scan_period * scan_speed); float ring = exp(-pow((r - ring_r) / 1.6, 2.0)) * (1.0 - ring_r / (scan_period * scan_speed)); float glow_floor = (1.0 - smoothstep(4.0, 22.0, r)) * 0.06; ALBEDO = floor_color + line_color.rgb * (line * energy * (1.0 + ring * 1.6) * fade + glow_floor); }