A7: Visual effects, hit marker and hurt flash

EffectsView (src/client/effects/) draws muzzle flashes at the held
weapon's muzzle, tracer ribbons to each pellet's impact (and streaks
behind projectiles in flight), hit bursts on players, chips and dust by
material or ground, keg blasts with fireball, debris, smoke and a light,
build dust, collapse clouds for broken pieces, splashes and surge spray.

Particles are simulated on the CPU in packed arrays and drawn by two
MultiMeshes (blended and added) through a small billboard shader that
reads each particle's size from custom data (the stock billboard modes
drop the instance scale) and converts Palette's sRGB colours. Pools are
allocated once at the preset's budget (256/512/1024 particles, 64
tracers, 4 lights): three draw calls whatever happens.

The HUD gains a reticle, four ticks round it when your shot strikes a
player (HitFeedback), and a rust flash at the screen's edge when hurt.

Tests: test_effects_view (12), including a 24-shooter stress scene that
stays inside each budget and never adds nodes. Captures: make
effects-captures (fight, blast, work, stress), checked by eye, and the
blast in the Compatibility renderer.

Closes #47

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 11:45:19 -05:00
co-authored by Claude Opus 5.5
parent 8af068c625
commit e8414fde9a
22 changed files with 1506 additions and 12 deletions
+21
View File
@@ -22,6 +22,8 @@ var print_pass: MeshInstance3D
var sun: DirectionalLight3D
## The sky, light, haze, rain and murk of the moment (A6).
var weather: WeatherView
## Flashes, tracers, dust, blasts and spray (A7).
var effects: EffectsView
## Applies the player's graphics settings: the sun's shadows and the print pass.
@@ -34,6 +36,8 @@ func apply_settings(settings: GameSettings) -> void:
sun.directional_shadow_mode = splits.get(settings.shadow_splits(), DirectionalLight3D.SHADOW_PARALLEL_4_SPLITS)
if print_pass != null:
print_pass.visible = settings.print_pass
if effects != null:
effects.budget = settings.particle_budget()
## Builds the scene for `simulation`. `local_id` is the player this client plays, or 0.
@@ -77,6 +81,9 @@ func setup(simulation: Simulation, local_id: int = 0) -> void:
entities.local_id = local_id
entities.setup(sim)
add_child(entities)
effects = EffectsView.new()
effects.muzzle_of = muzzle_of
add_child(effects)
sync()
@@ -88,6 +95,20 @@ func sync() -> void:
props.sync()
structures.sync()
entities.sync()
effects.sync(sim, camera.transform.origin)
## Where the weapon in a player's drawn hands has its muzzle (its model's +Z end), or
## Vector3.INF when they have no figure showing a held item.
func muzzle_of(entity_id: int) -> Vector3:
var figure: FigureRig = entities.figure_of(entity_id) if entities != null else null
if figure == null or not figure.visible or not figure.is_inside_tree():
return Vector3.INF
var held: MeshInstance3D = figure.held()
if held == null or held.mesh == null or not held.is_visible_in_tree():
return Vector3.INF
var box: AABB = held.mesh.get_aabb()
return held.global_transform * Vector3(box.get_center().x, box.get_center().y, box.end.z)
## Puts the camera on a player's shoulder, looking where they look. `pitch` replaces