Home

Awesome

gltf-viewer-rs

This project is a glTF 2.0 viewer written in Rust. Rendering is done using the Vulkan API using Ash. It runs on Window, Linux and MacOS.

Screenshot

Features

Requirements

You can check your Vulkan feature set using Sascha Willems' Vulkan Caps Viewer

Controls

Orbital camera:

FPS camera:

Build it

cargo build

By default, building the project will trigger shader compilation for all shaders in ./assets/shaders. You can either skip this step altogether by setting the environnement variable SKIP_SHADER_COMPILATION to true, or you can change the default by setting SHADERS_DIR. Compiled shaders will be generated at the same location as the shader source, with the same name suffixed by .spv.

To compile the shaders you'll need to have glslangValidator on your PATH.

Run it

Just type the following command and drag and drop and gltf/glb file in the window.

RUST_LOG=gltf_viewer_rs=warn cargo run

You can provide a yaml configuration file with --config (or -c). Check this example file. And you can specify a file to load at startup with --file (or -f)

RUST_LOG=gltf_viewer_rs=warn,vulkan=warn cargo run -- --config config.yml --file C:\\dev\\assets\\glTF-Sample-Models\\2.0\\Triangle\\glTF\\Triangle.gltf

Validation layers

You can set up validation layers by running the following commands.

export VK_LAYER_PATH=$VULKAN_SDK/Bin
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation

# Then running the app with the --debug (-d) flag.
RUST_LOG=gltf_viewer_rs=warn cargo run -- --debug

You can also use the run.sh and debug.sh scripts

Known issues

On linux, enabling v-sync causes the system to freeze with some hardware configuration (tested on a laptop running Pop_os 19.04, with a GTX 1050Ti). It seems to be an issue related with PRIME sync.

Credits

Most of the shader code for BRDF lookup and pre-filtered map generation come from the excellent Sasha Willems' vulkan samples repository.

Cubemap faces have been generated using matheowis' HDRi to cubemap tool.

HDRi textures have been downloaded from hdriheaven.

SSAO tutorial from John Chapman's blog.

Bloom tutorial on Learn OpenGL

Screenshots

Cesium

WoodsSandNight
IndoorEnvCorset
MG08FlightJunkrat
Wicker