/Vulkan3DModelViewer

A basic 3D model viewer implemented in C++ and Vulkan

Primary LanguageCMIT LicenseMIT

3D Model Viewer in Vulkan

Overview

This repository contains a basic 3D model viewer implemented in C++ using the Vulkan library.

Requirements

The provided source codes were tested in Windows 10 using the following libraries:

  • Vulkan SDK 1.3.211.0;
  • glfw3 3.3.7;
  • glm 0.9.9.8;
  • rapidjson;

To run the application, you need to pass the config.json file path as an argument to it (e.g. main.exe config.json). Also, we suggest you move the shaders folder to the same folder where the executable is located.

If you want to recompile the shaders, please update the compileShaders.bat file (Windows) or create a new one following this tutorial.

Compilation/Building for Windows

To compile the source code and build the application for Windows, you may need to:

  • Install Visual Studio (>= 2019);
  • Install vcpkg:
  • Install Vulkan SDK;
  • Run the following vcpkg commands in the command prompt:
    • vcpkg install vulkan-headers;
    • vcpkg install glfw3;
    • vcpkg install glm;
    • vcpkg install rapidjson;
    • vcpkg integrate install;

Then, you can create a new, empty Visual Studio project, add the source codes, and you may need to change the following properties of the project:

  • Configuration Properties -> General -> C++ Language Standard: to ISO C++17 Standard (/std:c++17);
  • Configuration Properties -> C/C++ -> General -> Additional Include Directories: to <VULKAN_MODEL_VIEWER_PATH>\include;%(AdditionalIncludeDirectories);
  • Configuration Properties -> Linker -> General -> Additional Library Directories: to <VULKAN_SDK_PATH>\Lib;%(AdditionalLibraryDirectories);
  • Configuration Properties -> Linker -> Input -> Additional Dependencies: add vulkan-1.lib,

where:

  • <VULKAN_MODEL_VIEWER_PATH> is the path where the repository is stored;
  • <VULKAN_SDK_PATH> is the path where the Vulkan SDK is installed;

Scene Configuration

By default, this project comes with the Viking Room model by nigeloh updated by the Vulkan tutorial. If you want to load your own models in the application, please keep in mind that the current version of the application only supports the loading of a single .obj file (ideally stored in the models folder), associated with a single texture (ideally stored in the textures folder), that already has precomputed normals (vn items). Then, create a configuration file following the examples available in the configs folder to setup the scene to be loaded.

This application was successfully tested using the following models:

Tips: If you want to set up the camera properly, you can move the camera around the scene and press C to capture the camera data and later insert it in the configuration file. Also, if you want to disable the texture visualization, press 'R'. Conversely, press 'T' to enable the texture visualization.