Modern Vulkan-based 3D engine featuring procedural shape generation, scene management, and ImGui integration
Find a file
2016-03-26 13:46:49 +01:00
android Streamlined Android build process and install/uninstall batch files (#97) 2016-03-26 11:49:37 +01:00
base Android application state handling (#97) 2016-03-26 12:58:35 +01:00
bin Added missing assimp dll 2016-02-16 21:12:25 +01:00
bloom Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
cmake Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00
computeparticles Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
computeshader Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
data Added android support for parallax mapping, pipelines, push constants, radial blur, skeletal animation and tessellation examples (#97) 2016-03-25 21:08:59 +01:00
deferred Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
displacement Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
distancefieldfonts Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
documentation Added additional documentatiomn for the swap chain class 2016-02-23 22:22:59 +01:00
external Updated Vulkan headers from SDK 1.0.5.1 2016-03-13 10:56:12 +01:00
gears Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
geometryshader Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
images Rephrased paragraph on building the examples for the supported platforms 2016-03-26 13:46:49 +01:00
instancing Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
libs Removed libassimp.dll.a 2016-03-26 13:45:54 +01:00
mesh Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
models Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00
multithreading Force glm clip space to 0..1 (Fixes #18, Fixes #45) 2016-03-08 21:52:40 +01:00
occlusionquery Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
offscreen Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
parallaxmapping Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
particlefire Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
pipelines Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
pushconstants Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
radialblur Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
screenshots Particle fire system minor changes, added screenshot 2016-03-19 20:02:30 +01:00
shadowmapping Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
shadowmappingomni Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
skeletalanimation Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
sphericalenvmapping Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
tessellation Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
texture Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
texturearray Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
texturecubemap Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
triangle Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
vulkanscene Call example destructor on Android (Fixes #97) 2016-03-26 13:21:19 +01:00
.gitattributes gitattributes 2016-02-18 12:03:13 +01:00
.gitignore Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00
cleanup.bat Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00
CMakeLists.txt Added particle fire example to cmakelists 2016-03-16 20:58:11 +01:00
LICENSE.md Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00
README.md Rephrased paragraph on building the examples for the supported platforms 2016-03-26 13:46:49 +01:00
vulkanExamples.sln Added cpu based fire particle system (wip) 2016-03-15 22:38:32 +01:00
vulkanExamples.vcxproj Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00
vulkanExamples.vcxproj.filters Added Vulkan examples sources! 2016-02-16 15:07:25 +01:00

Vulkan examples and demos

Vulkan demo scene

Assorted C++ examples for Vulkan(tm), the new graphics and compute API from Khronos.

Building

The repository contains everything required to compile and build the examples on Windows, Linux and Android. All required dependencies are included.

Windows

A Visual Studio solution file for compiling all examples is included with the repository, examples will compile with VS2015 out of the box.

If you're using a different IDE or compiler you can use the provided CMakeLists.txt for use with CMake to generate a build configuration for your toolchain.

Linux

Use the provided the provided CMakeLists.txt for use with CMake to generate a build configuration for your favorite IDE or compiler.

Note that you need assimp in order to compile the examples for Linux. Either compile and install from the repository, or install libassimp-dev. The example require version 3.2 and up.

Android

Building on Android is done using the Android NDK and requires adevice that supports Vulkan. Please see the Android readme on how to build these and a few notes on the platform.

Binaries

Precompiled binaries for Windows (x64), Linux (x64) and Android can be found here. I'll try keep them up-to-date with the repositry.

Note that these only contain the binaries, you still need the repository for the data (shaders, models, textures) and put the binaries into to bin subfolder. Except for Android, where this is stored inside of the apk.

API-Version

The examples are build against API Version 1.0.5 and support implementations starting with 1.0.2. This ensures that beta drivers not updated to the most recent API-Version can run the examples.

Additional documentation

Additional documentation for several base classes and functionality (e.g. the swap chain) can be found in this directory.

Examples

Triangle

Most basic example. Renders a colored triangle using an indexed vertex buffer. Vertex and index data are uploaded to device local memory using so-called "staging buffers". Uses a single pipeline with basic shaders loaded from SPIR-V and and single uniform block for passing matrices that is updated on changing the view.

This example is far more explicit than the other examples and is meant to be a starting point for learning Vulkan from the ground up. Much of the code is boilerplate that you'd usually encapsulate in helper functions and classes (which is what the other examples do).

Texture mapping

Loads a single texture and displays it on a simple quad. Shows how to upload a texture including mip maps to the gpu in an optimal (tiling) format. Also demonstrates how to display the texture using a combined image sampler with anisotropic filtering enabled.

Cubemap

Building on the basic texture loading example a cubemap is loaded into host visible memory and then transformed into an optimal format for the GPU. The demo uses two different pipelines (and shader sets) to display the cubemap as a skybox (background) and as a source for reflections.

Texture array

Texture arrays allow storing of multiple images in different layers without any interpolation between the layers. This example demonstrates the use of a 2D texture array with instanced rendering. Each instance samples from a different layer of the texture array.

Distance field fonts

Instead of just sampling a bitmap font texture, a texture with per-character signed distance fields is used to generate high quality glyphs in the fragment shader. This results in a much higher quality than common bitmap fonts, even if heavily zoomed.

Distance field font textures can be generated with tools like Hiero.

Pipelines

Pipelines replace the huge (and cumbersome) state machine of OpenGL. This example creates different pipelines with different states and shader setups.

Gears

Vulkan interpretation of glxgears. Procedurally generates separate meshes for each gear, with every mesh having it's own uniform buffer object for animation. Also demonstrates how to use different descriptor sets.

Mesh loading and rendering

Uses assimp to load and a mesh from a common 3D format including a color map. The mesh data is then converted to a fixed vertex layout matching the pipeline (and shader) layout descriptions.

Mesh instancing

Shows the use of instancing for rendering the same mesh with differing uniforms with one single draw command. This saves performance if the same mesh has to be rendered multiple times.

Skeletal animation

Based on the mesh loading example, this example loads and displays a rigged COLLADA model including animations. Bone weights are extracted for each vertex and are passed to the vertex shader together with the final bone transformation matrices for vertex position calculations.

Particle system

Point sprite based particle system simulating a fire. Particles and their attributes are stored in a host visible vertex buffer that's updated on the CPU on each frame. Also makes use of pre-multiplied alpha for rendering particles with different blending modes (smoke and fire) in one single pass.

Push constants

Demonstrates the use of push constants for updating small blocks of shader data with high speed (and without having to use a uniform buffer). Displays several light sources with position updates through a push constant block in a separate command buffer.

Occlusion queries

Shows how to use occlusion queries to determine object visibility depending on the number of passed samples for a given object. Does an occlusion pass first, drawing all objects (and the occluder) with basic shaders, then reads the query results to conditionally color the objects during the final pass depending on their visibility.

Offscreen rendering

Uses a separate framebuffer (that is not part of the swap chain) and a texture target for offscreen rendering. The texture is then used as a mirror.

Radial blur

Demonstrates basic usage of fullscreen shader effects. The scene is rendered offscreen first, gets blitted to a texture target and for the final draw this texture is blended on top of the 3D scene with a radial blur shader applied.

Bloom

Implements a bloom effect to simulate glowing parts of a 3D mesh. A two pass gaussian blur (horizontal and then vertical) is used to generate a blurred low res version of the scene only containing the glowing parts of th the 3D mesh. This then gets blended onto the scene to add the blur effect.

Deferred shading

Demonstrates the use of multiple render targets to fill a G-Buffer for deferred shading.

Deferred shading collects all values (color, normal, position) into different render targets in one pass thanks to multiple render targets, and then does all shading and lighting calculations based on these in scree space, thus allowing for much more light sources than traditional forward renderers.

Shadowmapping

Shows how to implement directional dynamic shadows with a single shadow map in two passes. Pass one renders the scene from the light's point of view and copies the depth buffer to a depth texture. The second pass renders the scene from the camera's point of view using the depth texture to compare the depth value of the texels with the one stored in the depth texture to determine whether a texel is shadowed or not and also applies a PCF filter for smooth shadow borders. To avoid shadow artifacts the dynamic depth bias state (vkCmdSetDepthBias) is used to apply a constant and slope dept bias factor.

Omnidirectional shadow mapping

Uses a dynamic 32 bit floating point cube map for a point light source that casts shadows in all directions (unlike projective shadow mapping). The cube map faces contain the distances from the light sources, which are then used in the scene rendering pass to determine if the fragment is shadowed or not.

Spherical environment mapping

Uses a (spherical) material capture texture containing environment lighting and reflection information to fake complex lighting. The example also uses a texture array to store (and select) several material caps that can be toggled at runtime.

The technique is based on this article.

Parallax mapping

Like normal mapping, parallax mapping simulates geometry on a flat surface. In addition to normal mapping a heightmap is used to offset texture coordinates depending on the viewing angle giving the illusion of added depth.

(Tessellation shader) PN-Triangles

Generating curved PN-Triangles on the GPU using tessellation shaders to add details to low-polygon meshes, based on this paper, with shaders from this tutorial.

(Tessellation shader) Displacement mapping

Uses tessellation shaders to generate additional details and displace geometry based on a displacement map (heightmap).

(Compute shader) Particle system

Attraction based particle system. A shader storage buffer is used to store particle data and updated by a compute shader. The buffer is then used by the graphics pipeline for rendering.

(Compute shader) Image processing

Demonstrates the use of a separate compute queue (and command buffer) to apply different convolution kernels on an input image.

(Geometry shader) Normal debugging

Renders the vertex normals of a complex mesh with the use of a geometry shader. The mesh is rendered solid first and the a geometry shader that generates lines from the face normals is used in the second pass.

Vulkan demo scene

More of a playground than an actual example. Renders multiple meshes with different shaders (and pipelines) including a background.


## [Android](android/)

This repository also contains a few Android examples that are (for now) separated from the rest of the examples. See the Android readme for details on what is included and how to build the examples.

The examples already share a few source files with existing examples and might be integrated into them at some point.

Credits

Thanks to the authors of these libraries :

And a huge thanks to the Vulkan Working Group, Vulkan Adivsory Panel, the fine people at LunarG and everyone from the different IHVs that helped me get the examples up and working on their hardware!

Attributions / Licenses

Please note that (some) models and textures use separate licenses. Please comply to these when redistributing or using them in your own projects :

External resources