Giter Site home page Giter Site logo

vulkan-gltf-pbr's Introduction

Vulkan physically-Based Rendering using glTF 2.0 models

YouTube Vulkan glTF 2.0 playlist

About

Physically-Based Rendering example implementation with image based lighting in Vulkan using glTF 2.0 models. The lighting equation is based on the reference glTF PBR implementation from Khronos.

glTF 2.0 Model loading

Model loading is implemented in the vkglTF::Model class, using tiny glTF library to import the glTF 2.0 files, so e.g. all file formats supported by tinyglTF are suported. This class converts the glTF structures into Vulkan compatible structures used for setup and rendering.

The following major glTF 2.0 features are currently supported by the vkglTF::Model class:

  • Loading arbitrary glTF 2.0 models
    • Full node hierarchy
    • Full PBR material support
      • Metallic-Roughness workflow
      • Specular-Glossiness workflow (extension)
    • Animations
      • Articulated (translate, rotate, scale)
      • Skinned
      • Morph targets
    • Support for Draco mesh compression (see instructions)

Note that the model loader does not fully implement all aspects of the glTF 2.0 standard, and as such there is no guarantee that all glTF 2.0 models work properly.

Supported extensions:

  • KHR_materials_pbrSpecularGlossiness
  • KHR_materials_unlit
  • KHR_materials_emissive_strength

Loading different scenes

The repository only includes a basic scene setup with the static "damaged helmet" pbr sample model. The official collection of glTF 2.0 sample models can be found at here.

To load a different scene instead, specify the glTF model file name as a command line argument, e.g.:

Vulkan-glTF-pbr "PATH-TO-glTF-Sample-Models\2.0\BrainStem\glTF\brainstem.gltf"

Texture map generation

The physical based render model uses multiple source images for the lighting equation. Instead of relying on offline tools to generate those, this example will generate all required texture maps during startup using the GPU.

BRDF lookup table

This pass generates a 2D BRDF lookup table based on the formulas used in the pbr implementation. The lookup table contains BRDF values for roughness and view angle and is stored as a 16-bit per component floating point texture to provide proper precision.

See VulkanExample::generateBRDFLUT()

Irradiance cube map

(left: front face environment cube map / right: front face irradiance cube map)

Generates a small (64 x 64 px) irradiance cube map from that stores the light radiated from the surrounding environment. This is sampled for the indirect diffuse part of the lighting equation.

See VulkanExample::generateCubemaps() with target IRRADIANCE

Pre-filtered (mip-mapped radiance) environment cube map

(left: front face environment cube map / right: front face prefiltered cube map)

Generates a pre-filtered radiance cube map that is sampled for the indirect specular part of the lighting equation and stores specular contribution based on roughness. The mip chain stores increasing roughness values with increasing level count and is sampled accordingly when rendering the object.

Complete mip chain from left roughness = 0.0 to right roughness = 1.0:

(note: down/up sized to same size for visualization)

See VulkanExample::generateCubemaps() with target PREFILTEREDENV

Cloning

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/SaschaWillems/Vulkan-glTF-PBR.git

Updating submodules manually:

git submodule init
git submodule update

Building

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.

Windows, Linux

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"

Linux:

cmake .
make

Android

Prerequisites

Building

  • 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

How to enable Draco mesh compression

In order to enable support for loading Draco compressed glTF files you need to:

  • Clone and build https://github.com/google/draco as per their build instructions
  • Copy the Draco decoder library dracodec.lib into libs\draco
  • Copy the src folder contents into external\draco, make sure the draco_features.h is also present
  • If everything is in place, running CMake will output Draco mesh compression enabled and loading Draco compressed meshes will work out of the box

Links

vulkan-gltf-pbr's People

Contributors

artyomd avatar daemyung avatar ludwigfriedmann avatar peach1 avatar rmstyrczula avatar saschawillems avatar spirrwell avatar stromaster avatar syoyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vulkan-gltf-pbr's Issues

How to pass (GLTF)model name to main.cpp

Hi SaschaWillems,
I want to pass the model name from activity to main.cpp.
In the example, defualt give (std::string sceneFile = assetpath + "models/DamagedHelmet/glTF-Embedded/Box.gltf")

I like to pass (GLTF) model name from the activity. KIndly let me know how to do this.

Crash in Model::destroy, vkFreeMemory when unloading specific model

Steps to reproduce:

1.) Load fox model from gltf sample models:
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Fox
Note that the model itself works, animations play just fine.

2.) Now load any other model e.g BoomBox - The viewer crashes upon unloading the fox model in line 407 of VulkanglTFModel.cpp -> vkFreeMemory(device, indices.memory, nullptr);

Note that the fox model is the only model I have noticed this behaviour with. Also, I have tested the fox model using the dilligent engine gltf viewer, which they claim is based on your pbr gltf implementation and it works fine there - if this is of any help.
https://github.com/DiligentGraphics/DiligentFX/tree/master/GLTF_PBR_Renderer

I haven't looked further into the issue myself, but I thought it might interest you.

How to make the backgrund sharp?

On all examples the background is blurred. What is the correct way to make it sharp for using in a game?

Also, for some reason my converted hdr image appears in the demo upside-down. What would be the correct way to make it right side up again?

Best regards,

-Alexandre

questions about shading and input parameters

Hello!
I have some questions.

  1. I read source code of pbr_khr.frag and I see
    layout (location = 0) in vec3 inWorldPos;
    layout (location = 1) in vec3 inNormal;
    layout (location = 2) in vec2 inUV0;
    layout (location = 3) in vec2 inUV1;
    can you describe what about this parameters?
  2. How to get in shader which triangle id in pixel coordinate?
  3. Is refraction is not supported?
  4. file pbr.vert
    layout (location = 4) in vec4 inJoint0;
    layout (location = 5) in vec4 inWeight0;
    layout (set = 2, binding = 0) uniform UBONode {
    mat4 matrix;
    mat4 jointMatrix[MAX_NUM_JOINTS];
    float jointCount;
    } node;
    What is inJoint0, inWeight0, jointMatrix, jointCount?

Thank you
Dmitry

Problem with animations

Hello Sascha,

Animations are not working correctly in the viewer. For instance, when I load the AnimatedMorphCube model from the official glTF sample models repo, nothing is animating! Same with the AnimatedMorphSphere model - I believe I remember them animating a few months back. AnimatedTriangle is still working - haven't checked rest of the models.

Another issue which I encountered is if I hardcode the AnimatedTriangle model to load by default instead of the DamagedHelmet - I get this error:
image

image

I am a big fan of your work and would highly appreciate if you could take some time to fix this!

Thanks,
Rajdeep

Emissive map after tone mapping?

In your pbr.frag shader, you apply the emissive texture after tone mapping, just adding what you read out of the texture.

Shouldn't the emissive map be applied before tone mapping and when you read the texture don't you have to transform it from sRGB to linear RGB (since the standard mentions the emissive texture to be in sRGB space)?

Animation Samplers CubicSpline & Step

Vulkan-glTF-PBR is the best C++ animated glTF viewer implementation so far!

For animations, can CubicSpline and Step interpolation support be added?

Cubicspline animation doesn't currently animate because glTF cubicspline animation sampler data layout is different from linear/step (cubicspline uses additional in-tangent and out-tangent vectors)

Step animation animates, Step just needs frame interpolation turned off

Cubicspline animation expects output*3 vectors total to store the cubicspline intangent and out tangent

  • "CUBICSPLINE" The animation's interpolation is computed using a cubic spline with specified tangents.
    The number of output elements must equal three times the number of input elements. For each input element, the output stores three elements, an in-tangent, a spline vertex, and an out-tangent. There must be at least two keyframes when using this interpolation.

(From: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation )


Here's a suggestion for cubicspline animation support:

Vulkan-glTF-PBR needs to write in-tangent and out-tangent when loading cubicspline animations

void loadAnimations
https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanglTFModel.hpp#L1064
should export extra intange and outtangent for the cubicspline interpolation,
in addition to outputsVec4

In updateAnimation
https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanglTFModel.hpp#L1346

Interpolation update can change to support all 3 styles

if cubicspline
   cubic bezier interpolation
else if linear
   mix/lerp
else if step
  like linear, just without mix/lerp

  • "LINEAR" The animated values are linearly interpolated between keyframes.
    When targeting a rotation, spherical linear interpolation (slerp) should be used to interpolate quaternions. The number output of elements must equal the number of input elements.
  • "STEP" The animated values remain constant to the output of the first keyframe, until the next keyframe. The number of output elements must equal the number of input elements.

Here's a similar glTF cubicspline animation issue for reference: mrdoob/three.js#12907


attached is a zip of the 3 animation sample types in glTF

glTF_3_animation_types.zip

Segmentation fault when failed to load a texture.

https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanTexture.hpp#L89

Creating gli::texture2d or gli::texture_cube directly from gli::load triggers assertion(debug build) or gives undefined behaviour(usually this results to a Vulkan error) in the constructor when failed to load a texture file.
(It does not create empty gli texture)

Here is an example when failed to load a texture.

Fatal : VkResult is "-2" in /mnt/data/work/Vulkan-glTF-PBR/base/VulkanglTFModel.hpp at line 184
Vulkan-glTF-PBR: /mnt/data/work/Vulkan-glTF-PBR/base/VulkanglTFModel.hpp:184: void vkglTF::Texture::fromglTfImage(tinygltf::Image&, vkglTF::TextureSampler, vks::VulkanDevice*, VkQueue): Assertion `res == VK_SUCCESS' failed.
Aborted (core dumped)

Tthis is an issue of gli, so it should be fixed in gli library. For a while, we can use the following workaround:

  gli::texture tex(gli::load(filename.c_str());
  // will create empty texture when failed to load a texture.

  if (!tex.empty()) {
    // trigger assertion or return false
  }
  gli::texture2d tex2D(tex);

  ...

Related to: https://github.com/g-truc/gli/issues/174

MacOS build might be easy to achieve

Hi!

I'm trying to build Vulkan-glTF-PBR on MacOS, and, although you are not listing the Mac as a supported platform, I think the build should be quite easy to achieve. I just installed the Vulkan SDK on my Mac, and set all the environment variables. When invoking cmake with Vulkan-glTF-PBR it successfully detects the SDK, as well as the draco compression (which I built in advance as you suggest in the docs.

I tried to tweak CMakeLists.txt (adding -DVK_USE_PLATFORM_MACOS_MVK and removing the xcb dependency within the USE_D2D_WSI block, which is the block that is being executed on my Mac), and then added a VK_USE_PLATFORM_MACOS_MVK block to main.cpp, but then of course the build fails anyway, because the Mac platform is not implemented in the VulkanExample class. I looked at your Vulkan demos repository, and it does support the Mac, and you have a more complete VulkanExample class there, but I guess it's not a matter of just copying a couple of files, or maybe is it?

weird cone-shaped shading illusion

screenshot

I'm using your renderer in my game engine, and currently am having a few weird visual artifacts.

Ths scene is just a green plane with a hi-color skybox. FIrst of all, there is this conic shape around the 0,0,0 coordinate. Do you haven any idea why is it formed and how to fix it?

Also, the direction of the highlight is not in the direction of the sun for some weird reason.

And also, there is a blue dot in the middle of the Sun, i'm not sure what's the deal there. Can it be a bug in the shader code?

the scene: https://wizstaff.com/test.glb
the skybox: https://wizstaff.com/mountain.ktx

Best regards,

-Alexandre Kharlamov

[Question] Using this code as a guide to writing a glTF scene loader

While following this code as an example of loading glTF files to write a glTF loader in mine, I have encountered one problem and one question.

The problem represents hitting an area of Vulkan that is new to me: multiple descriptor sets, specifically where the second is dynamically formed and complex (glTF). I already have a descriptor set 0 used to render other objects. I know I need to have the first point to the new sets generated while loading the glTF scene, but I'm struggling with the details of doing that. Any advice would be greatly appreciated, even just pointing me to a good example showing this sort of multiple descriptor set use.

Descriptor sets seem a lot like Latin grammar: everything has a place and everything must be in its place... 😀

@SaschaWillems My question is regarding the difference between this repo and the glTF examples (the simpler ones) in your main samples repo. In this more complex example, you use gli and the main example repo uses KTX. It would seem to my inexperienced Vulkan eyes that KTX would be a better choice. What motivated you to use gli over KTX?

Not seen the model

The SkyBox is visible, but the model is not visible.

Platform is windows 10, using vulkan sdk version (1.0.68.0) and built with visual studio 2017.
GPU GTX1060.

Any ideas what might be going on?

Thanks!

main.cpp build error

screenshot 2019-01-31 at 2 42 30 pm

I have cloned and update the module
(git submodule init
git submodule update)

But showing error in all cpp files.

Using copyCmd instead of blitCmd, when blitting mipmaps

In base/VulkanglTFModel.hpp, 233, 247 and 263 vkCmdPipelineBarrier() is used with copyCmd, that has been freed in device->flushCommandBuffer(copyCmd, copyQueue, true);, line 194. It should use blitCmd. It runs on Nvidia though, but on Android, MotoZ crashes. When using blitCmd, then it works nicely.

Thanks,
Mete

Effect of SRGBtoLinear

Question:
I am experimenting with PBR using glTF, using this project as a reference(pbr_khr.frag shader specifically).
The straightforward task of displaying the colorMap of the model with and without SRGBtoLINEAR() yields inconsistent results between mine and this project:
This Project
Without SRGBtoLINEAR
SWnoSRGB2Lin
With SRGBtoLINEAR
SWwithSRGB2Lin

My Project
Without SRGBtoLINEAR
YTnoSRGB2Lin
With SRGBtoLINEAR
YTwithSRGB2Lin

This project's With SRGBtoLINEAR is similar to my projects Without SRGBtoLINEAR.
What could be the reason(s) behind this behaviour?
Again, this is just sampling the colorMap texture and sending it as fragment output.

Crashes when displaying multi animation glTF

An assert fails when importing this low poly glTF model with multiple animations:

fox.gltf.zip

The same gltf works fine in other viewers: https://gltf-viewer.donmccurdy.com/

The glTF appears to parse correctly but it asserts and crashes with vertex buffer out of range before the glTF is rendered to the screen.

This project is one of the few C++ glTF viewers that displays animation, so I find it a very valuable reference for animated glTF implementation, is it possible to fix this import?

android studio build error

In file included from /home/hlw/Demo/Vulkan-glTF-PBR/base/VulkanglTFModel.cpp:16:
In file included from /home/hlw/Demo/Vulkan-glTF-PBR/base/VulkanglTFModel.h:18:
/home/hlw/Demo/Vulkan-glTF-PBR/base/VulkanDevice.hpp:58:4: error: use of undeclared identifier 'vkGetPhysicalDeviceProperties'

Invalid Joint Indices/Broken Animation

Hello!

So I have no idea whether the problem is here, in tinygltf, or in Blender's exporter, so sorry.

But if you take say CesiumMan from the sample models repo and import him to Blender and re-export, the joint indices stored in Vertex::joint0 go way out of bounds and the animation dies horribly.
image

The console output is the Vertex::joint0 values.

Blender can re-import its own gltf models just fine and throwing them through a gltf validator doesn't give off any issues.

I don't know much about animation in general, tinygltf or the gltf spec, so I'm hoping somebody has some insight. I don't think I can figure this out.

Skin weight with (0, 0, 0, 0)

Sometimes skin weights become all zeros(0, 0, 0, 0)
(e.g. Maya2glTF https://github.com/WonderMediaProductions/Maya2glTF exported glTF model)

For such weight input, output vertex position in vertex shader become NaN or invalid, resulting no display of a skinned mesh.

Possible solution is...

Set weights to (1, 0, 0, 0) for (0, 0, 0, 0) in VulkanglTFModel.hpp,

vert.joint0 = hasSkin ? glm::vec4(glm::make_vec4(&bufferJoints[v * jointByteStride])) : glm::vec4(0.0f);

(Assuming the first joint id is the root node?)

or add check of weights value in PBR shader.

https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/data/shaders/pbr.vert#L41

FYI, it looks three.js handles this situation well.

Android Build Issue

Android NDK: Found platform level in ./project.properties. Setting APP_PLATFORM to android-23.
Android NDK: WARNING: APP_PLATFORM android-23 is higher than android:minSdkVersion 19 in ./AndroidManifest.xml. NDK binaries will not be comptible with devices older than android-23. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk
Android/Tools/android-sdk-windows/ndk-bundle/build/core/add-application.mk:101: *** Android NDK: Aborting... . Stop.
Error building project!

recompile the vulkan shader

Hi how i can fiddle with the new shader effects?

The environment is windows/visual studio How I can managed to recompile for example, pbr_khr.frag to *.sprv? I clean and recompile does not seem to take effects? The spriv shaders taking effects are the ones in the repo. Any quick hint?

Regards
Yao

Materials PBR loading in VulkanglTFModel.cpp

What is going on in VulkanglTFModel.cpp?

			if (mat.additionalValues.find("emissiveFactor") != mat.additionalValues.end()) {
				material.emissiveFactor = glm::vec4(glm::make_vec3(mat.additionalValues["emissiveFactor"].ColorFactor().data()), 1.0);
				material.emissiveFactor = glm::vec4(0.0f);
			}

first, a vec4 is created, then a new vec4 filled with zeroes is created? Why?

Will the following do the trick?

		material.emissiveFactor = glm::vec4(mat.emissiveFactor[0],
			mat.emissiveFactor[1], mat.emissiveFactor[2], 1.0);

`getMatrix` become too slow when the scene contains deeper node hierarchies.

glm::mat4 getMatrix() {

getMatrix always loop over parent matrices until it reaches the root.

This become quite slow when the scene contains deeper node hierarchies(e.g. 100. such a deeper hierarchies would happen in character skeletons). For example, I get 120 fps(without getMatrix) -> 7 fps(with getMatrix) slowdown on Threadripper 1950X for a glTF model containing roughly 300 nodes.

The solution is obvious. Cache the node's matrix once after updating the matrix of each nodes. Probably we are better to add updateNodeMatrices() API before calling node->update()(If this change is OK, I can send a PR)

‘keyPressed’ was not declared in this scope

calling make raise the following error on Ubuntu 18.10 with XCB


.../Vulkan-glTF-PBR/base/VulkanExampleBase.cpp: In member function ‘void VulkanExampleBase::handleEvent(const xcb_generic_event_t*)’:
.../Vulkan-glTF-PBR/base/VulkanExampleBase.cpp:1534:3: error: ‘keyPressed’ was not declared in this scope
   keyPressed(keyEvent->detail);
   ^~~~~~~~~~

Removing the line fix the problem and everything else still seems to work fine.

glm/glm.hpp not found

Build command failed.
Error while executing process /Users/admin/Library/Android/sdk/cmake/3.10.2.4988404/bin/cmake with arguments {--build /Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/android/app/.externalNativeBuild/cmake/debug/armeabi-v7a --target native-lib}
[1/10] Building C object CMakeFiles/native-app-glue.dir/Users/admin/Library/Android/sdk/ndk-bundle/sources/android/native_app_glue/android_native_app_glue.c.o
[2/10] Linking C static library libnative-app-glue.a
[3/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanAndroid.cpp.o
[4/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/external/imgui/imgui_demo.cpp.o
[5/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/external/imgui/imgui_draw.cpp.o
[6/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp.o
FAILED: CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp.o
/Users/admin/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi19 --gcc-toolchain=/Users/admin/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/admin/Library/Android/sdk/ndk-bundle/sysroot -Dnative_lib_EXPORTS -I../../../../../../base -I../../../../../../external -I../../../../../../external/glm -I../../../../../../external/gli -I/Users/admin/Library/Android/sdk/ndk-bundle/sources/android/native_app_glue -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sources/android/support/include -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -std=c++11 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp.o -MF CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp.o.d -o CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp.o -c /Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp
In file included from /Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/base/VulkanExampleBase.cpp:9:
In file included from ../../../../../../base/VulkanExampleBase.h:46:
../../../../../../base/camera.hpp:12:10: fatal error: 'glm/gtc/quaternion.hpp' file not found
#include <glm/gtc/quaternion.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[7/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp.o
FAILED: CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp.o
/Users/admin/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=armv7-none-linux-androideabi19 --gcc-toolchain=/Users/admin/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/admin/Library/Android/sdk/ndk-bundle/sysroot -Dnative_lib_EXPORTS -I../../../../../../base -I../../../../../../external -I../../../../../../external/glm -I../../../../../../external/gli -I/Users/admin/Library/Android/sdk/ndk-bundle/sources/android/native_app_glue -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sources/android/support/include -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -isystem /Users/admin/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -std=c++11 -std=c++11 -DVK_USE_PLATFORM_ANDROID_KHR -DVK_NO_PROTOTYPES -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp.o -MF CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp.o.d -o CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp.o -c /Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp
In file included from /Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/src/main.cpp:25:
In file included from ../../../../../../base/VulkanExampleBase.h:46:
../../../../../../base/camera.hpp:12:10: fatal error: 'glm/gtc/quaternion.hpp' file not found
#include <glm/gtc/quaternion.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[8/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/external/imgui/imgui_widgets.cpp.o
[9/10] Building CXX object CMakeFiles/native-lib.dir/Users/admin/Desktop/Vulkan/gltfsample/Vulkan-glTF-PBR-master/external/imgui/imgui.cpp.o
ninja: build stopped: subcommand failed.

Strange colors on Intel UHD 620

Hey Sascha,

For some reason, I can't get your PBR examples to work on my intel graphics. The scene ends up looking like this:
image

Any ideas what might be going on?

Thanks!

Compilation error on Linux

FAILED: base/CMakeFiles/base.dir/VulkanglTFModel.cpp.o 
/usr/bin/g++-13 -DVK_EXAMPLE_DATA_DIR=\"/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/data/\" -D_CRT_SECURE_NO_WARNINGS -I/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/external -I/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/external/glm -I/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/external/gli -I/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/external/imgui -I/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/external/tinygltf -I/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/base -DVK_USE_PLATFORM_XCB_KHR -DNOMINMAX -D_USE_MATH_DEFINES -march=native -Ofast -DNDEBUG -w -I/home/dario/usr/include -DGLM_ENABLE_EXPERIMENTAL=1   -std=c++11 -MD -MT base/CMakeFiles/base.dir/VulkanglTFModel.cpp.o -MF base/CMakeFiles/base.dir/VulkanglTFModel.cpp.o.d -o base/CMakeFiles/base.dir/VulkanglTFModel.cpp.o -c /home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/base/VulkanglTFModel.cpp
/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/base/VulkanglTFModel.cpp: In member function ‘void vkglTF::Model::calculateBoundingBox(vkglTF::Node*, vkglTF::Node*)’:
/home/dario/proyectos/Vulkan/Vulkan-glTF-PBR/base/VulkanglTFModel.cpp:1159:49: error: cannot bind non-const lvalue reference of type ‘vkglTF::BoundingBox&’ to an rvalue of type ‘vkglTF::BoundingBox’
 1159 |                 BoundingBox& parentBvh = parent ? parent->bvh : BoundingBox(dimensions.min, dimensions.max);
      |                                          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[8/10] Building CXX object src/CMakeFiles/Vulkan-glTF-PBR.dir/main.cpp.o

Tested with GCC 7, GCC 13 and CLang 17

Relative paths not working on Windows

Using CMake 3.15.2 on Windows 10.

Generating the project inside a build directory

vulkangltfpbr1

So I replaced the relative path strings with the hard coded folder path, for shaders, fonts, and assets. instead of the ./../data string and got it working.

thank you for the project

Warped animation importing from blender

Hey i was playing around with this and tried to load a basic animation of a square. The model loaded correctly but the animation was incorrect, it rotated the square and increased its size where none of that was happening in blender (2.8), all I did was move the cube over a little bit.

Any tips on getting animations loading correctly?


Edit: Ok I fooled around a little more with this and imported the brainstem model from the official glTF sample models to see if exporting it again would produce any errors in the animation. It did not, so I also tried inserting plain location keyframes instead of locationrotationscale keyframes like I had been doing. This time the cube didn't move at all. Im hoping theres just some checkbox i need to check in Blender or something like that.

VulkanActivity onBackpress Crash

Application crashing on clicking back from VulkanActivity

Error Message:

A/libc: Invalid address 0xc7503dc0 passed to free: value not allocated
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 13867 pid 13822

Texture upsidedown

Hi, Sascha,

I guess you haven't finished modifying this example yet. Perhaps you would fix it shortly.

I am writing this message just to remind you that the texture needs to be flipped.

The flipUV in pbr.vert

layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
mat4 view;
vec3 camPos;
float flipUV;
} ubo;

seems orphaned (not controlled).

Hope you would fix it soon.

Cheers
Edward

Spelling mistake in README.txt

Texture map generation

The phyiscal based render model uses multiple source images for the lighting equation. Instead of relying on offline tools to generate those, this example will generate all required texture maps during startup using the GPU.

Build broken?

I am getting a bunch of build errors in VS2017 related to stbi after tinygltf update: db99bb6

1>c:\dev\pbr\base\stb_image.h(764): error C2371: 'stbi__context': redefinition; different basic types
1>c:\dev\pbr\base\stb_image.h(764): note: see declaration of 'stbi__context'
1>c:\dev\pbr\base\stb_image.h(771): error C2084: function 'void stbi__start_mem(stbi__context *,const stbi_uc *,int)' already has a body
1>c:\dev\pbr\base\stb_image.h(770): note: see previous definition of 'stbi__start_mem'
1>c:\dev\pbr\base\stb_image.h(780): error C2084: function 'void stbi__start_callbacks(stbi__context *,stbi_io_callbacks *,void *)' already has a body
1>c:\dev\pbr\base\stb_image.h(779): note: see previous definition of 'stbi__start_callbacks'

BRDF LUT generation uses wrong scissor dimensions?

The scissor extent width and height are set to the general window width and height variables instead of to the dimensions being used to generate the BRDF LUT (the variable "dim").

This is obviously super minor, but it just seemed like not what you'd want to do in general and if for some reason the BRDF LUT was generated after the window size had been changed to something smaller than 512x512 I suppose it would break. Right now it just works because the generation happens before the default window size has a chance to be overwritten with anything too small, I'm guessing.

I'd say they ought to each just be set to "dim" instead.

scissor.extent.width = width;

scissor.extent.height = height;

When I create a offscreen Render pass to save the scene, the program always stucks.

Thanks for this great project.
I want to save the pbr result in a texutre, so I need to add a offscreen render pass. I implement this as follows:

  1. prepare offscreen renderPass as in https://github.com/SaschaWillems/Vulkan/tree/master/examples/offscreen.

  2. prepare a offscreen pipeline

rasterizationStateCI.cullMode = VK_CULL_MODE_FRONT_BIT;
    pipelineCI.renderPass = offscreenPass.renderPass;
    VK_CHECK_RESULT(vkCreateGraphicsPipelines(
        device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.offscreen));
  1. build a command buffer and change the the recordCommandBuffers function.

But, when I run the project, it always stuck. I don't know why. Any suggestion would be appreciated.

Android tiling lag

First off great demo, works right away on both desktop and android like Vulkan should. The only thing I personally noted with my Galaxy S8 is that if I look around too fast I get some strange artifacts. It looks like the tiling rendering on the mobile device is not all finishing before presenting the next image. I didn't see any mishaps in synchronizations, but wanted to point it out formally.

I ran it through GAPID and when capturing the trace I see it looks normal, so might expect it to be for sure a presentation/swapchain issue as the rendering is shown to be correct on GAPID. I plan to hack at it later after I get another phone with a Mali chip to verify later this week.

gltf_pbr_binned

Forget to add reference& on the parentBvh in void Model::calculateBoundingBox(Node *node, Node *parent) ?

`void Model::calculateBoundingBox(Node *node, Node *parent) {
BoundingBox parentBvh = parent ? parent->bvh : BoundingBox(dimensions.min, dimensions.max);

	if (node->mesh) {
		if (node->mesh->bb.valid) {
			node->aabb = node->mesh->bb.getAABB(node->getMatrix());
			if (node->children.size() == 0) {
				node->bvh.min = node->aabb.min;
				node->bvh.max = node->aabb.max;
				node->bvh.valid = true;
			}
		}
	}

	parentBvh.min = glm::min(parentBvh.min, node->bvh.min);
	parentBvh.max = glm::min(parentBvh.max, node->bvh.max);

	for (auto &child : node->children) {
		calculateBoundingBox(child, node);
	}
}`

Here is the code of Model::calculateBoundingBox(Node *node, Node *parent).
On the first line we fetch the variable of parentBvh by
BoundingBox parentBvh = parent ? parent->bvh : BoundingBox(dimensions.min, dimensions.max);
The parentBvh is being modified by
parentBvh.min = glm::min(parentBvh.min, node->bvh.min); parentBvh.max = glm::min(parentBvh.max, node->bvh.max);
So the first shoud be
BoundingBox& parentBvh = parent ? parent->bvh : BoundingBox(dimensions.min, dimensions.max);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.