v0.1.0 · Rust · wgpu
Build 3D games in Rust. Ship them native on every phone.
Rusthycs is a mobile-first 3D game SDK. Implement one Game trait and run it with Metal on iOS, Vulkan on Android, a native window on desktop and WebGPU in the browser. Shared WGSL shaders, no scripting layer in between.
- iOS
- Android
- macOS
- Web (WebGPU)
const JUMP: Action = Action(1);
const JUMP_SPEED: f32 = 5.4;
const GRAVITY: f32 = 9.81;
#[derive(Default)]
struct Hopper { body: usize, height: f32, speed: f32 }
impl Game for Hopper {
fn scene(&mut self) -> Result<Demo> {
let mut scene = SceneBuilder::default();
let (vertices, indices) = unit_cube();
let cube = scene.mesh(&vertices, &indices, false)?;
let amber = Material {
color: [1.0, 0.58, 0.11, 1.0],
metallic: 0.4,
roughness: 0.2,
};
self.body = scene.instance(cube, Mat4::IDENTITY, amber)?;
Ok(scene.finish())
}
fn configure_input(&self, input: &mut Input) {
input.bind(Button::Key(44), &[JUMP]);
input.bind(Button::gamepad(GamepadButton::South), &[JUMP]);
}
fn fixed_update(
&mut self,
dt: Duration,
input: &StepInput<'_>,
) -> Result<()> {
let dt = dt.as_secs_f32();
if input.pressed(JUMP) && self.height == 0.0 {
self.speed = JUMP_SPEED;
input.haptic(Haptic::Light);
}
self.speed -= GRAVITY * dt;
self.height = (self.height + self.speed * dt).max(0.0);
Ok(())
}
fn prepare_render(
&mut self,
renderer: &mut Renderer,
_: &mut Settings,
_: f32,
) -> Result<()> {
let pose = Mat4::from_translation(Vec3::Y * self.height);
let bounds = sphere_bounds(pose, 3f32.sqrt())?;
renderer.set_transform(self.body, pose, bounds)
}
}
- 60 Hzfixed simulation step with interpolated rendering
- 16,384instances per scene, culled on the GPU
- 0.14 msCPU per frame for 20,000 particles on Apple M5
- 16 KiBAndroid page size support verified at runtime
What is in the box
Everything a mobile 3D game needs. Nothing it does not.
Your game owns its state. Rusthycs provides input, the clock, rendering and native services, without forcing a scene graph or a fixed set of rules on you.
-
runtime::GameOne trait, four platforms
Simulate at a fixed 60 Hz, interpolate when rendering and react to suspension. The same factory boots on iOS, Android, desktop and the Web.
-
config::EngineConfigConfigured in TOML
Every operational parameter lives in one validated file: time step, physics, rendering, audio, input and networking. Unknown keys and out-of-range values are rejected with the section that failed.
-
rendererForward HDR renderer
Clustered lights, cascaded shadows, procedural sky, height fog, water and terrain surfaces and HDR bloom, all from shared WGSL.
-
physicsDeterministic physics
Rapier 3D with enhanced determinism: the same steps produce the same state bit for bit, even across architectures. Raycasts, sensors, contacts and a capsule character controller.
-
inputTouch, gamepads and haptics
Actions with rebindable, persisted bindings. Gamepads on every platform, gestures (tap, double tap, long press, swipe, pinch) and haptic feedback.
-
audioAudio with buses
WAV and streamed OGG music, master, music, sfx, voice and ui buses with fades, voice stealing by priority, 3D audio with doppler, and pausing on calls or route changes.
-
netUDP multiplayer
Signed-token handshake, reliable and unreliable channels, fragmentation, rate limits, client-side prediction, snapshot interpolation and LAN discovery.
-
particles·procgenParticles and procedural worlds
Fixed-capacity SoA particles drawn in a single call. Reproducible PCG32, Perlin and fBm noise, heightmaps whose mesh matches the collider, Poisson disk sampling and mazes.
-
assets·saves·levelAssets, levels and saves
Versioned TOML asset catalog with glTF models, LOD and ASTC or RGBA8 textures. Declarative TOML levels. Typed JSON save slots with schema versions and atomic writes.
The API
Implement the trait. The hosts do the rest.
Every hook has a sensible default except scene and fixed_update. Override only what your game needs.
Hand the host yourconfigEngineConfig, usually loaded from TOML.
Declare the on-screen buttons the iOS and Android hosts show.controls
Build meshes, materials, instances and lights once withsceneSceneBuilder.
Bind keys, gamepad buttons and touch controls to actions.configure_input
Advance your simulation at the fixed step with the frame'sfixed_updateStepInput.
Move instances, lights and the camera, interpolated withprepare_renderalpha.
React when the app goes to the background, a call interrupts audio or the output changes.suspended·audio_event
[runtime]
step_hz = 60
max_catch_up_steps = 5
[render.lighting.atmosphere]
sky = true
fog_density = 0.02
[render.lighting.bloom]
intensity = 0.6
threshold = 1.0
[audio.buses]
music = { gain = 0.8, muted = false }
fn launch(_: Launch<'_>) -> Result<Box<dyn Game>> {
Ok(Box::new(Hopper::default()))
}
#[cfg(all(
feature = "app",
any(target_os = "ios", target_os = "android")
))]
rusthycs::mobile_app!(launch);
#[cfg(all(feature = "app", target_arch = "wasm32"))]
rusthycs::web_app!(launch);
desktop::run(game, Options::default()).Renderer
How a frame gets drawn.
A single forward pass in linear HDR with no depth prepass. No draw call looks up a mesh by name.
- 01
Light clusters
The CPU bins lights into a 12×8×16 grid with logarithmic depth slices.
- 02
Visibility
A compute pass compacts visible instances. No readback to the CPU.
- 03
Shadows
Two Depth32Float cascades with PCF, snapped to the texel grid.
- 04
Forward HDR
RGBA16Float with GGX shading, procedural sky, height fog, water, terrain and sorted transparency.
- 05
Bloom
Thresholded HDR bloom at quarter resolution.
- 06
Post
Edge antialiasing, upscaling, exposure and tone mapping.
The stack
On an Apple M5 desktop, preparing a frame costs 0.497 ms of CPU at P50. The 60 FPS target on physical phones is still being measured, and simulator numbers are never presented as hardware results.
- Language
- Rust 2021
- GPU
- wgpu 24.0.5 · WGSL
- Apple
- Metal · CAMetalLayer · CADisplayLink
- Android
- Vulkan · API 36 · NDK 27.1 · 16 KiB pages
- Web
- WebGPU · wasm-bindgen
- Physics
- rapier3d 0.27 · enhanced-determinism
- Math
- glam 0.30
- Audio
- cpal 0.16 · lewton (OGG)
- Gamepads
- gilrs 0.11
- Assets
- glTF · ASTC with RGBA8 fallback · LOD
Not there yet
These are not in the engine today. We list them so nobody is surprised.
- SSAO and light shafts
- Internet play with NAT traversal, relay servers and matchmaking
- Audio and networking on the Web build
- WebGL2 fallback
- Visual editor
Get started
From an empty crate to a phone.
Package your game for every platform without touching the engine repository. You need rustup, Xcode and XcodeGen for iOS, and the Android SDK and NDK for Android.
-
Install the targets
rustup target add \ aarch64-linux-android \ aarch64-apple-ios \ aarch64-apple-ios-sim \ wasm32-unknown-unknown cargo xtask doctor -
Describe your app
version = 1 name = "Skyline Run" id = "com.northpeak.skyline" release = "0.1.0" build = 1Add
rusthycs.tomlto a crate that depends onrusthycs, has anappfeature and implementsGame. -
Run it on Android
cargo xtask sdk build skyline-run android debug -
Run it on iOS
cargo xtask sdk build skyline-run ios debug simulatorUse
releaseorarchive devicewhen you are ready to ship. Read the engine guide.
Download
Pick your platform.
Tested on the iOS Simulator and on an Android emulator with 16 KiB pages. Sessions on physical phones are still in progress.
-
SDK
Engine, native iOS and Android hosts and build tooling in one zip.
Download SDK -
Android
ARM64 debug APK, signed with the development key.
Get the APK -
iOS
iPhone build through TestFlight.
Open TestFlight -
Source
Repository, documentation and project status.
View on GitHub