Drop-in C++20 blast physics, ocean wave-train displacement, warhead phasing, and volumetric GPU explosion shaders.
Live 3D Demo · Why Shockwave · Architecture · Quick start · Warheads · License
Game explosions usually split into two disconnected halves: an emitter prefab that looks fine in isolation, and gameplay water or shock radius numbers tuned in a separate spreadsheet. Shockwave ties them together under one C++20 header contract:
- One truth across CPU and GPU: Yield scaling, thermal burn windows, shock speeds, and smoke lifetimes live in
<shockwave/shockwave.hpp>and drive both CPU queries and raymarched fragment shaders. - Real ship heave from blast waves:
SeaNuclearWaveandSeaImpactWavesevaluate vertical wave displacement and exact analytical slopes (slopeX,slopeZ) at any(x, z)coordinate—giving you dynamic vessel pitch, roll, and foam without an FFT ocean solver. - No mesh folding under salvos: Multiple simultaneous hits accumulate cleanly into a fixed-capacity ring buffer with
tanhelevation and slope clamping (±22 m,0.55max slope), plus automatic coalescence for dense cluster strikes. - Zero-texture volumetric shaders: Both the native Apple Metal renderer and the WebGL2 GLSL 300 es demo raymarch a deterministic 64³ noise lattice for incandescent fireballs, toroidal mushroom plumes, supersonic Wilson domes with Prandtl-Glauert condensation strata, and shaped-charge Mach lances.
Open the Interactive 3D Sandbox to compare every warhead across Sea, Cliff, and Midair environments, inspect live h(r) sea cross-sections, Shift + Click any surface to stack salvos, and copy ready-to-paste C++20 code directly from the {} C++ modal.
To run the sandbox locally:
python3 -m http.server 8080 --directory demoinclude/shockwave/explosion_profiles.hpp— Calibration profiles (Nuclear,HighExplosive,Cluster,Incendiary,Thermobaric,FocusedJet) with matching yields, burn durations, and visual scale multipliers.include/shockwave/sea_nuclear_wave.hpp&sea_impact_wave.hpp— Allocation-free ocean crater and dispersive wave solvers returning height, analytical normals (slopeX,slopeZ), rim foam, and wave loading.include/shockwave/phonk_warhead.hpp— Two-stage tandem shaped-charge timing (0.16 sprecursor followed by0.22 sdelayed plasma lance) decoupled cleanly from gameplay damage ownership.include/shockwave/metal/— Native Objective-C++ + Apple Metal raymarchers (phonk_ordnance_render.hpp,cluster_impact_render.hpp) with scene depth occlusion and shock refraction.
Add the repository as a submodule or drop include/ into your C++20 engine. The simulation headers require only the C++20 standard library:
add_subdirectory(third_party/shockwave)
target_link_libraries(your_game PRIVATE shockwave::shockwave)#include <shockwave/shockwave.hpp>
using namespace shockwave;
// 1. Query yield-scaled fireball, shock radius & surface coupling
const auto nuc = evaluateNuclearState(/*tier=*/3, /*ageSeconds=*/1.25f, SurfaceKind::Sea);
// 2. Step the ocean blast wave and read vessel elevation + slopes
SeaNuclearWave wave{};
wave.x = 0.0f;
wave.z = 0.0f;
wave.active = true;
wave.Advance(dt);
const SeaNuclearWaveSample sea = EvaluateSeaNuclearWave(wave, shipX, shipZ);
// Use sea.height, sea.slopeX, sea.slopeZ and sea.foam to pitch & highlight ships
// 3. Drive tandem shaped-charge phasing
const auto precursor = tandemPrecursor(age);
const auto mainJet = tandemMain(age);Run the bundled CPU checks, quickstart CLI, and (on macOS with Apple Metal) shader verification:
clang++ -std=c++20 -O2 -Iinclude tests/test_explosions.cpp -o /tmp/shockwave_tests && /tmp/shockwave_tests
clang++ -std=c++20 -O2 -Iinclude examples/quickstart.cpp -o /tmp/shockwave_quick && /tmp/shockwave_quick
clang++ -std=c++20 -fobjc-arc -O2 -Iinclude -framework Metal -framework AppKit tests/test_metal_shaders.mm -o /tmp/shockwave_metal && /tmp/shockwave_metal| Model | Radius | TNT Equiv | Flame Window | Lifetime | Signature Behavior |
|---|---|---|---|---|---|
Nuclear |
220 m · cbrt(tier) |
15 kt (tier 1) | 4.20 s | 9.0 s | Toroidal mushroom cap, Wilson dome & 14 m wave train |
Thermobaric |
27.3 m (3.2×) |
750 kg | 1.35 s | 14.0 s | Sustained fuel-air fireball & expanded pressure dome |
HighExplosive |
18.0 m (2.5×) |
450 kg | 0.84 s | 12.0 s | 5-lobe blast core transitioning to dark soot column |
Cluster |
15.0 m (2.0×) |
18 kg / sub | 0.56 s | 8.5 s | Cascades into coalescing surface ripple rings |
Incendiary |
15.4 m (2.5×) |
280 kg | 2.45 s | 16.5 s | Long burning magnesium fire & dense rising ash |
FocusedJet |
14.0 m (2.6×) |
160 kg | 0.62 s | 12.0 s | Two-stage precursor + Mach diamond plasma lance |
Licensed under Apache-2.0 with NOTICE. Extracted from sea combat VFX and blast-wave physics originally built for Corsairs Remaster.
If you ship a game or simulator with this library, include attribution in your credits or third-party notices:
Explosion VFX & blast wave module by iddictive
https://github.com/iddictive/Shockwave


