A hardware-accelerated 3D renderer written in Rust. Runs using OpenGL 4.3 as graphics API on desktop and WebGL2 on WebAssembly.
Click here for C++ version of this project
This project is a demonstration of my expertise to use the Rust programming language to write cross-platform 3D graphical applications that run both on desktop (Windows, Linux) and on the web with WebAssembly. The project showcases confident usage of the following technologies:
- Rust
- 3D graphics programming with OpenGL 4 and WebGL2 (based on OpenGL ES 3.0)
- Immediate mode overlay GUI using egui (as opposed to retained mode GUI frameworks like Qt)
- Building for WebAssembly using webpack
- HTML bindings into Rust binary
- Advanced
cargo
features (crate patching)
Future additions will include Direct3D, Vulkan rendering backends and additional post-processing effects.
- 3D model display from
OBJ
file format - Fly-by FPS camera movement
- Skybox display using cube-map
- Directional light with ADS (Ambient, Diffuse, Specular) lighting (Phong shading)
- Live browser demo
- HTML controls interacting with the 3D scene
- Pure Rust dependencies without relying on C/C++ library bindings
Desktop executable requires an OpenGL 4.3 compatible graphics adapter to run. Check if your hardware supports OpenGL 4.3 and have the latest graphics driver installed.
Web browser live demo requires support of WebGL2.
Dependencies are automatically downloaded by cargo
.
-
Make sure you have the latest stable version of Rust and
cargo
installed, following the instructions on https://www.rust-lang.org/tools/install -
Clone the repository
git clone https://github.com/balintkissdev/3d-renderer-rust.git
cd 3d-renderer-rust
- Compile and execute the release build
cargo run --release
Web build requires Node.js and npm
as package manager. The recommended way to install npm
is using a Node version manager like nvm.
Use npm
to install Node package dependencies:
npm install
Build the web application (there's no need to install wasm-pack
separately, because it is automatically downloaded locally by webpack
):
npm run build
Run the web application by serving it on live server:
npm run serve
You can access the application at http://localhost:8080
.
Use keyboard and mouse to navigate the 3D environment.
- Movement:
W
,A
,S
,D
- Mouse look:
Right-click
and drag - Ascend:
Spacebar
- Descend:
C
Modify UI controls to change properties of the 3D model display. Browser demo also has HTML controls.
- Utah Teapot and Stanford Bunny model meshes are from Stanford Computer Graphics Laboratory
- High poly Stanford Bunny model mesh is from https://www.prinmath.com/csci5229/OBJ/index.html
- Skybox texture images are from learnopengl.com