This was made to be a proof of concepts for people to reference when hacking at their own project. While almost done, there are many more part I am activly working on atm. PLEASE feel free to drop issues or PR!
- Loads in glTF 2.0 Morph Target files
- Dynamic shaders via SSBO and Push Constants
- Specular based lighting
- Get more testing models
- Interpolation of timing - LINEAR, STEP, CUBICSPLINE
- Allow loading of multiple models
- Allow glTF with more then 1 morph mesh
- Allow glTF with more then 1 morph mesh and 1 non-morph mesh
- Allow glTF with more then 1 primative
- Allow glTF with child nodes
- UV Texture
- Materials
- Use tangents in morph
A future blog post will be up shortly with more details of how it works so you can implement it for your own use
Most of the template is from Sascha Willem's Vulkan-glTF-PBR demo so huge shout out to him! I wanted to use morph targets for my own purpose, knew glTF had it in its specification and decided to create a demo since no one else seems to have for Vulkan.
For info how to read in morph targets from a glTF file check out the great two tutorials from the KhronosGroup/glTF-Tutorials repo
Model loading and rendering is implemented in the vkglTF::Model class and uses the tiny glTF library to import the glTF 2.0 files.
Note that this is not a full glTF model class implementation, this was to show the steps for morph target rendering/parsing.
All the "targets"
bufferViews are found and then all the morph target data is packed in a VAO style format to a storage buffer in ther vertex shader with position then normal then tangent
vec3[] = {POS_0, POS_1, POS_2, ..., POS_N}
// or
vec3[] = {POS_0, POS_1, ..., POS_N, NORMAL_0, NORMAL_1, ..., NORMAL_N}
// or
vec3[] = {POS_0, POS_1, NORMAL_0, NORMAL_1, TANGENT_0, TANGENT_1}
All the weights and offset are passed in via Push Constants witha max of 8 right now, can be adjusted in morph.vert
and in pushConstantRange.size
.
This repository contains submodules for some of the external dependencies, so when doing a fresh clone you need to clone recursively:
git clone --recursive https://github.com/sjfricke/Vulkan-glTF-Morph-Target.git
Updating submodules manually:
git submodule init
git submodule update
The repository contains everything required to compile and build the examples on Windows, Linux and Android using a C++ compiler that supports C++11. All required dependencies are included.
Use the provided CMakeLists.txt with CMake to generate a build configuration for your favorite IDE or compiler, e.g.:
Windows:
cmake -G "Visual Studio 14 2015 Win64"
cd bin
Vulkan-glTF-Morph-Target.exe
Linux:
cmake .
make
cd bin
./Vulkan-glTF-Morph-Target
- Android Studio 3.0 or higher
- Android NDK
- Android API 24+
- In Android Studio, select
Import project
- Select the
android
sub folder of the repository - Once import has finished the project can be build, run and debugged from Android Studio