Skip to content

adrien-ben/gltf-viewer-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • Mesh vertices, normals, colors and two uv channels
  • Tangents generation
  • Material
    • Base color factor and texture
    • Metallic/Roughness factors and textures
    • Emissive factor and texture
    • Ambient occlusion
    • Normal maps
    • Alpha
      • Opaque
      • Mask
      • Blend
    • Double sided surfaces
  • IBL
  • Animations
    • Node animation
    • Skinning
    • Interpolation
      • Step
      • Linear
      • Cubicspline
  • Extensions
    • KHR_lights_punctual
    • KHR_materials_unlit
    • KHR_materials_pbrSpecularGlossiness
    • KHR_materials_emissive_strength
    • KHR_materials_clearcoat
    • KHR_texture_transform
    • KHR_materials_ior
    • KHR_draco_mesh_compression
  • Camera controls
    • Orbital
    • First Person
  • Drag and drop
  • Background loading
  • Post processing
    • Gamma correction
    • Tone mapping
    • Ambient occlusion
    • Bloom
    • Depth of field
  • egui integration
    • Model description
    • Animation controller
    • Camera details
    • Renderer settings
  • HDR display
    • Allow enabling HDR (if supported by the device)
    • Add HDR specific tonemapping

Requirements

  • Vulkan 1.0
  • VK_KHR_dynamic_rendering

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

Controls

  • 'H' to toggle UI

Orbital camera:

  • Left click and move to rotate camera around origin
  • Right click and move to move camera
  • Mouse wheel to un/zoom

FPS camera:

  • WASD to move
  • Left Ctrl to go down
  • Space to go up
  • Left click to rotate

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

Woods Sand Night
Indoor Env Corset
MG08 Flight Junkrat
Wicker

About

glTF 2.0 file viewer written in Rust using Vulkan

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages