UFOs no longer reuse the crow's bird mesh. EnemySystem.build_ufo_mesh() merges the mesh arrays of two CylinderMesh hull halves, a TorusMesh rim, a hemisphere SphereMesh dome and eight small sphere lights into one ArrayMesh (about 1.65 m across, -0.13..0.45 m about its origin), with per-part vertex colors and (glow, metalness) in UV. A second HordeRenderer (ufo_renderer) draws it with the new game/resources/ufo.gdshader: albedo from COLOR, no flap, a slow spin and bob with a per-enemy phase, chasing rim lights, and the bird shader's hit flash (INSTANCE_CUSTOM.g) and night_glow. Both batches mirror the dense slots (write_new, move_slot, clear), and commit_render scales each slot to nothing in the batch that doesn't draw its type. DayNight now takes a list of enemy materials and sets night_glow on both. UFOs get their own arrival cue (kenney/digital/powerUp2.ogg, previously unused) instead of the crow's caw. HordeRenderer.is_drawn() backs the new test_roster checks: a UFO is drawn by the UFO batch only, a crow by the bird batch only, a thief by neither, also after a swap-removal; and the saucer's size and centering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.9 KiB
Text
48 lines
1.9 KiB
Text
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;
|
|
}
|