Expand description
Metaball / Isosurface Entity System
Each entity is a 3D scalar field defined by a set of field sources (metaballs). The visible surface is extracted via marching cubes at a configurable threshold. HP affects field strength — damage literally reshapes the entity’s body.
§Architecture
MetaballEntity
├─ sources: Vec<FieldSource> (position, strength, radius, falloff, color)
├─ threshold: f32 (isosurface level)
├─ hp_ratio: f32 (0.0 = dead, 1.0 = full HP)
└─ grid_resolution: u32 (32 normal, 64 boss)
Per frame:
1. Update sources (HP modulation, damage zones, breathing)
2. Evaluate field on 3D grid (CPU or GPU compute)
3. March cubes → ExtractedMesh
4. Apply surface material (iridescence, translucency, fresnel)
5. Render into G-buffer via deferred pipelineRe-exports§
pub use entity_field::MetaballEntity;pub use entity_field::FieldSource;pub use entity_field::FalloffType;pub use field_eval::FieldSample;pub use marching_cubes::MCVertex;pub use marching_cubes::ExtractedMesh;pub use marching_cubes::MarchingCubesExtractor;pub use gpu_marching_cubes::GpuMarchingCubes;pub use surface_material::SurfaceMaterial;pub use surface_material::MaterialSample;pub use damage::DamageEvent;pub use damage::DamageResponse;pub use damage::DamageSystem;pub use templates::EntityTemplate;
Modules§
- damage
- Damage response through field manipulation — hits deform the body, crits punch holes, low HP makes the entity skeletal, death dissolves sources.
- entity_
field - MetaballEntity — the scalar field definition for isosurface entities.
- field_
eval - Field evaluation and sampling — evaluate the scalar field at any point, compute gradient for normals, color and emission via weighted average of source contributions.
- gpu_
marching_ cubes - GPU-accelerated marching cubes via compute shaders.
- marching_
cubes - Isosurface extraction for metaball fields.
- surface_
material - Surface material properties for the isosurface — iridescence, translucency, fresnel, procedural veining, and mathematical symbol projection.
- templates
- Entity templates — predefined source configurations for different entity types.