• Stars
    star
    737
  • Rank 61,490 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Physical based rendering with Vulkan using glTF 2.0 models

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.

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

More Repositories

1

Vulkan

Examples and demos for the new Vulkan API
GLSL
9,133
star
2

VulkanCapsViewer

Vulkan hardware capability viewer
C++
273
star
3

openglcpp

Collection of C++ OpenGL samples and demos
C++
189
star
4

VulkanSponza

Deferred Vulkan rendering playground using Crytek's Sponza scene
C++
168
star
5

glCapsViewer

C++ port of the OpenGL hardware capability viewer
C++
88
star
6

SPIRV-VSExtension

SPIR-V extension for Visual Studio
C#
87
star
7

dglOpenGL

Delphi / Pascal OpenGL header translation (including WGL and GLX)
Pascal
78
star
8

VulkanInfiniteProceduralTerrain

Playground for doing procedurally infinite terrain rendering experiments with Vulkan
C++
64
star
9

vulkan_slim

Trying to trim down the size of my Vulkan repo...
C++
29
star
10

webgl

WebGL demos and samples
HTML
29
star
11

VulkanPathTracer

C++
22
star
12

vulkan.gpuinfo.org

Front-End and Back-End for the Vulkan Hardware Database
PHP
21
star
13

VulkanTemplate

Vulkan template with light abstraction as a base for personal projects
C++
21
star
14

glEsCapsViewer

OpenGL ES hardware capability viewer for Android
Java
20
star
15

VulkanDungeonCrawler

Playing around with Vulkan and random dungeon generation
C++
17
star
16

Vulkan-Assets

Asset pack for the Vulkan samples repository
16
star
17

VulkanPlayground

C++
16
star
18

OpenCLCapsViewer

Client application for populating the community-driven OpenCL database
C++
14
star
19

VulkanWicked

C++
9
star
20

VulkanCapsViewerGenerator

Extension header generator based on the official Vulkan registry xml
PHP
9
star
21

gpuinfo.org

PHP
9
star
22

VulkanInvaders

C++
8
star
23

Vulkan_Test

Testing playground for misc. Vulkan related things
C++
7
star
24

Vulkan-RenderDoc-API

C++
6
star
25

VulkanDeviceSimulation

Example for using the new LunarG Vulkan Device Simulation layer
C++
6
star
26

openglesandroid

Collection of OpenGL ES demos for android using Java
Java
5
star
27

VulkanCapsViewerCmdLine

Command line only version of the Vulkan Hardware Capability Viewer
C++
5
star
28

opengles.gpuinfo.org

Web front-end for the OpenGL ES hardware capability database
PHP
5
star
29

VulkanExamplesLauncher

Android launcher for the C++ Vulkan examples
Java
4
star
30

raytracing

C++
3
star
31

opencl.gpuinfo.org

PHP
3
star
32

delphi

Sources for some of my old Delphi projects
Pascal
2
star
33

VulkanProfiles-TestCase

C++
2
star
34

Vulkan-Samples-Asciidoc

Python
1
star