Skip to main content

Reviving Kiss3d - a simple 3D and 2D graphics engine

· 4 min read

The kiss3d crate was one of my very first projects in Rust in 2013! It is an easy-to-use 2D and 3D graphics engine for writing small demos (or even small games if you feel like it). Back in the days, there wasn’t any other easy-to-use graphics library, especially for 3D, and I needed one for showcasing my work on physics simulation; that’s why I created Kiss3d!

I paused its maintenance around 2020 when I switched to Bevy for the testbed of the Rapier physics engine. Some amazing community members helped to maintain Kiss3d since then (huge thanks to @Alex Maiorella and @ alvinhochun among others) but no significant activity happened since 2023.

Fast-forward today, the progressive complexification and frequent breaking of Bevy’s API has made it difficult to keep up and update the testbed every few months. Moreover, I needed an easier access to async functions and latest wgpu versions for experiments involving GPU computing. So it was time to switch back to kiss3d but with a deep refresh:

  • It is now based of glam (or rather glamx which is built on top of glam) instead of nalgebra to simplify its API.
  • It is based on wgpu (WebGpu) instead glow (OpenGL) for rendering to align with community standards and for easier compatibility with advanced compute shaders.
  • It now has a unified interface when targeting native and the web (you control the main loop in both cases) thanks to an async main function, inspired from a similar approach in macroquad.
  • Many of the functions for manipulating scene nodes have been renamed to something simpler. (For example append_local_translation is renamed translate).
  • Addition of a few convenience and performance-oriented features like support for egui, instancing and polylines rendering. (Disclaimer: you might notice that the polyline demo is strongly inspired from a similar demo in bevy_polyline)
  • Added support for multiple lights.

3D primitives

Multiple lights

Meshes, lines, points

Obj and textures

Post-processing effects

Instancing 10.000 2D rectangles

Instancing 1.000.000 3D cubes

3D Polylines

egui support

The kiss3d graphics engine is cross-platform (including the web) and aims to remain simple to use. It does not support Android/iOS yet, but we are planning on it. It is based on a scene tree to describe the rendering scene. You keep total control over main and the render loop and ou don’t need to fit everything into a new paradigm like ECS: you organize your data however you want, arrange your function calls yourself (no complex system scheduling declarations). Rendering simple primitives and meshes only takes a few of lines of code to get you started quickly. The following shows how you render a 3D cube and get an interactive camera supporting mouse controls:

use kiss3d::prelude::*;

#[kiss3d::main]
async fn main() {
let mut window = Window::new("Kiss3d: cube").await;
let mut camera = OrbitCamera3d::default();
let mut scene = SceneNode3d::empty();
scene
.add_light(Light::point(100.0))
.set_position(Vec3::new(0.0, 2.0, -2.0));

let mut cube = scene.add_cube(1.0, 1.0, 1.0).set_color(RED);

let rot = Quat::from_axis_angle(Vec3::Y, 0.014); // axis-angle in radians

while window.render_3d(&mut scene, &mut camera).await {
cube.rotate(rot);
}
}

The 2D equivalent follows the same logic:

use kiss3d::prelude::*;

#[kiss3d::main]
async fn main() {
let mut window = Window::new("Kiss3d: rectangle").await;
let mut camera = PanZoomCamera2d::new(Vec2::ZERO, 5.0);
let mut scene = SceneNode2d::empty();
let mut cube = scene.add_rectangle(100.0, 150.0).set_color(RED);

let rot = 0.014; // radians

while window.render_2d(&mut scene, &mut camera).await {
cube.rotate(rot);
}
}

Check out the source-code of all the examples on github. You may also interact with some of them with the online demos compiled to WASM (your browser needs to support WebGpu). Refer to kiss3d’s CHANGELOG for detailed information about these breaking changes.

Unfortunately, I have since then lost control over the kiss3d.org domain name. The (new!) website is now hosted at https://kiss3d.rs.

Acknowledgements

We hope that reviving Kiss3d will help fill a gap in the Rust community for users needing a simple graphics engine with a lower learning curve.

Thanks to all the former, current and new supporters through GitHub sponsors! This helps us tremendously to sustain our Free and Open-Source work. Finally, a huge thanks to the whole community and code contributors!

Help us sustain our open-source work by sponsoring us on GitHub sponsors or by reaching out
Join us on discord!