Kool
A Vulkan / WebGPU / OpenGL engine for Desktop JVM, Android and Javascript written in Kotlin
Install / Use
/learn @kool-engine/KoolREADME
kool - A Vulkan / WebGPU / OpenGL graphics engine written in Kotlin
A multi-platform Vulkan / WebGPU / OpenGL game engine that works on Desktop Java, Android and browsers.
Get In Touch
Feel free to join the Discord Server!
Web-Demos
The following demos run directly in the browser. Chrome is highly recommended because it's still the only browser
with WebGPU support. Other browsers should work as well but use the WebGL backend, which doesn't support all
features / demos.
The code for all demos is available in
the kool-demo subproject. You can also run them locally by
cloning this repo and running ./gradlew :kool-demo:runDesktop
- Island: Height-map based island incl. some wind-affected vegetation + a basic controllable character.
- Physics - Vehicle: A drivable vehicle (W, A, S, D / cursor keys, R to reset) based on the Nvidia PhysX vehicles SDK. WebGPU only
- Physics - Ragdoll: Ragdoll physics demo.
- Physics - Joints: Physics demo consisting of a chain running over two gears. Uses a lot of multi shapes and revolute joints.
- Physics - Collision: The obligatory collision physics demo with various different shapes.
- 2D Physics: Simple 2D physics demo with quite many dynamic bodies and two kinematic rotors.
- Bloom: Decent looking bloom for (very) bright objects. WebGPU only
- Pathtracing: Compute shader based implementation of the Ray Tracing in One Weekend book. WebGPU only
- Embedded UI: Integrated UI framework implemented completely within
the engine. Fast, highly customizable and easy-to-use. Offers advanced features like compose-style
LaunchedEffect, Animations and more. - Particles: Two teams of bees fighting against each other. Simulation can be toggled between CPU and compute-shader (if available, i.e. on WebGPU).
- Fluffy Bunny: Shell-shading based rendering of animated fur (based on this video).
- Creative Coding: A few relatively simple demos showcasing different techniques of generating procedural geometry.
- Procedural Geometry: Small test-case for procedural geometry; all geometry is generated in code (even the roses! Textures are regular images though). Also, some glass shading (shaft of the wine glass, the wine itself looks quite odd when shaded with refractions and is therefore opaque). WebGPU only
- glTF Models: Various demo models loaded from glTF / glb format
- Flight Helmet from glTF sample models
- Polly from Blender
- Coffee Cart from Poly Haven
- Camera Model also from Poly Haven
- A few feature test models also from the glTF sample model repository
- Deferred Shading: Thousands of dynamic light sources, bloom and ambient occlusion. WebGPU only
- Screen-space Ambient Occlusion: Roughly based on this article by John Chapman with slightly optimized sampling (also shamelessly recreated his demo scene).
- Screen-space Reflections: A simple PBR shaded model with screen-space reflections and up to four spot-lights with dynamic shadows.
- Physical Based Rendering: Interactive PBR demo with image based lighting for various materials and environments (underlying PBR theory from this awesome article series).
- Instanced / LOD Drawing: Instanced rendering demo of the Stanford Bunny. Uses six levels of detail to render up to 8000 instances.
- Mesh Simplification: Interactive mesh simplification demo (based on traditional error-quadrics)
By default, the web demos use the WebGPU backend and fall back to WebGL if WebGPU is not supported by your browser. The
used backend is printed in the extended info-panel in the lower right corner (click on the little +), apart from
that there shouldn't be much visible difference in the WebGL and WebGPU backends. You can also force a certain backend
by appending &backend=webgpu or &backend=webgl to the URL.
I also made an actual game with this: Blocks and Belts. Give it a try (it's free)!
Scene Editor
Check out the web editor! (Chrome recommended).
The engine used to be a code-only engine, but I recently made some progress in implementing a graphical scene editor. The editor still is in an early state and lacks several rather essential features, but the basics already work quite well. It is fully implemented within the engine itself (including the UI).
To unleash the full potential of the editor, you should run it locally. You can either download the editor
directly in the web-version by clicking the Save Project button in the upper right corner (this also preserves any
changes made in the editor) or you can clone the editor template project (see usage below).
More editor related documentation is available in the editor docs.
Platform Support
| Platform | Backend | Implementation Status |
|---------------------|-------------|--------------------------------------------------------|
| Desktop (JVM) | Vulkan | :white_check_mark: Fully working |
| Desktop (JVM) | OpenGL | :white_check_mark: Fully working |
| Desktop (JVM) | WebGPU | :sparkles: Mostly working (using the wgpu4k backend) |
| Browser (JS + WASM) | WebGPU | :white_check_mark: Fully working |
| Browser (JS + WASM) | WebGL 2 | :white_check_mark: Fully working |
| Android | OpenGL ES 3 | :white_check_mark: Fully working |
Supported desktop platforms
- Windows (x64): Vulkan, WebGPU and OpenGL
- Linux (x64): Vulkan, WebGPU and OpenGL
- macOS (ARM + x64): Vulkan and WebGPU (no OpenGL)
JS vs. WASM Performance
Kool supports plain JavaScript as well as WebAssembly (WASM) as browser targets. However, the WASM backend seems to be suffering from the many required JS-interop upcalls to various Web APIs. Therefore, in most cases, the WASM backend is actually slower than the JS backend, and plain JS stays the recommended target for now.
Java Version
On Desktop, Kool currently uses Java 17 as the minimum language level except the kool-backend-wgpu4k module, which
requires Java 22 (because it uses Project Panama features under the hood, which
became stable in Java 22). In case Java 22 is a problem for you, you can exclude kool-backend-wgpu4k from the project.
Android Support
The Android target is disabled by default (to avoid having the Android SDK as a build requirement). You can
enable the Android target by running the gradle task ./gradlew enableAndroidPlatform.
Moreover, the demos are currently not build for Android. However, there's a basic kool-android-template project with a minimal kool Android app.
Usage
You can use kool as a library in your own (multiplatform-) projects. The library is published on maven central:
repositories {
mavenCentral()
// only needed in case you want to use a SNAPSHOT version:
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
implementation("de.fabmax.kool:kool-core:0.19.0")
implementation("de.fabmax.kool:kool-physics:0.19.0")
}
There is also a separate repo containing minimal template projects to get you started:
https://github.com/kool-engine/kool-templates
The demos mentioned above and examples shown below should give you a rough idea on how to do stuff (documentation is still a bit of a weak spot).
