shader_type spatial; // UFO material (its own MultiMesh batch, EnemySystem.ufo_renderer) for the saucer from // EnemySystem.build_ufo_mesh(): each part's color comes from the vertex COLOR, and its glow and // metalness from UV (x, y). No flap: the saucer turns slowly about its axis and bobs a little, // with a per-enemy phase from INSTANCE_CUSTOM.r, and the rim lights (glow 1) pulse in a chase // around the ring. As in thief.gdshader, a hit flashes it white through INSTANCE_CUSTOM.g (1 on // the hit, fading), a rim light keeps it readable, and night_glow (set by DayNight) adds a faint // purple glow at night; the lights and the dome glow brighter in the dark. uniform float spin_speed = 1.2; uniform float bob_amount = 0.05; uniform float bob_speed = 2.2; uniform float chase_speed = 6.0; uniform float glow_energy = 1.4; uniform float night_glow : hint_range(0.0, 1.0) = 0.0; varying float flash; varying float glow; varying float metal; void vertex() { float phase = INSTANCE_CUSTOM.r * 6.2831853; // The lights chase around the ring (two pulses per turn), riding along with the spin. float around = atan(VERTEX.z, VERTEX.x); float pulse = 0.45 + 0.55 * max(sin(around * 2.0 - TIME * chase_speed + phase), 0.0); glow = UV.x * mix(1.0, pulse, step(0.99, UV.x)); metal = UV.y; float a = TIME * spin_speed + phase; mat2 spin = mat2(vec2(cos(a), sin(a)), vec2(-sin(a), cos(a))); VERTEX.xz = spin * VERTEX.xz; NORMAL.xz = spin * NORMAL.xz; VERTEX.y += sin(TIME * bob_speed + phase) * bob_amount; flash = INSTANCE_CUSTOM.g; } void fragment() { vec3 base = COLOR.rgb; float f = clamp(flash, 0.0, 1.0); ALBEDO = mix(base, vec3(1.0), f); METALLIC = metal; ROUGHNESS = mix(0.12, 0.4, metal); SPECULAR = 0.5; // The night's purple sits on the hull; the glowing parts keep their own color. EMISSION = base * glow * glow_energy * (1.0 + night_glow) + vec3(1.0, 0.9, 0.8) * f * 0.6 + vec3(0.5, 0.28, 0.75) * night_glow * 0.35 * (1.0 - glow); RIM = 0.6; RIM_TINT = 0.4; }