2016-07-14 23:45:52 +02:00
|
|
|
/*
|
|
|
|
|
* Vulkan Example - Deferred shading with shadows from multiple light sources using geometry shader instancing
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
|
|
|
|
|
*
|
|
|
|
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "vulkanexamplebase.h"
|
2017-02-12 10:48:46 +01:00
|
|
|
#include "VulkanFrameBuffer.hpp"
|
2020-07-28 20:20:38 +02:00
|
|
|
#include "VulkanglTFModel.h"
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
#define VERTEX_BUFFER_BIND_ID 0
|
|
|
|
|
#define ENABLE_VALIDATION false
|
|
|
|
|
|
|
|
|
|
// Shadowmap properties
|
2016-07-18 21:39:21 +02:00
|
|
|
#if defined(__ANDROID__)
|
2016-07-17 18:34:52 +02:00
|
|
|
#define SHADOWMAP_DIM 1024
|
2016-07-18 21:39:21 +02:00
|
|
|
#else
|
|
|
|
|
#define SHADOWMAP_DIM 2048
|
|
|
|
|
#endif
|
2016-07-14 23:45:52 +02:00
|
|
|
// 16 bits of depth is enough for such a small scene
|
|
|
|
|
#define SHADOWMAP_FORMAT VK_FORMAT_D32_SFLOAT_S8_UINT
|
|
|
|
|
|
2016-07-18 21:39:21 +02:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
|
// Use max. screen dimension as deferred framebuffer size
|
2020-05-29 16:08:53 +01:00
|
|
|
#define FB_DIM std::max(width,height)
|
2016-07-18 21:39:21 +02:00
|
|
|
#else
|
2016-07-14 23:45:52 +02:00
|
|
|
#define FB_DIM 2048
|
2016-07-18 21:39:21 +02:00
|
|
|
#endif
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Must match the LIGHT_COUNT define in the shadow and deferred shaders
|
|
|
|
|
#define LIGHT_COUNT 3
|
|
|
|
|
|
|
|
|
|
class VulkanExample : public VulkanExampleBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-07-28 20:20:38 +02:00
|
|
|
int32_t debugDisplayTarget = 0;
|
2016-07-17 18:34:52 +02:00
|
|
|
bool enableShadows = true;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Keep depth range as small as possible
|
|
|
|
|
// for better shadow map precision
|
|
|
|
|
float zNear = 0.1f;
|
|
|
|
|
float zFar = 64.0f;
|
2016-07-17 18:34:52 +02:00
|
|
|
float lightFOV = 100.0f;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-08-08 13:59:58 +02:00
|
|
|
// Depth bias (and slope) are used to avoid shadowing artifacts
|
2016-07-14 23:45:52 +02:00
|
|
|
float depthBiasConstant = 1.25f;
|
|
|
|
|
float depthBiasSlope = 1.75f;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct {
|
2017-02-09 21:55:35 +01:00
|
|
|
vks::Texture2D colorMap;
|
|
|
|
|
vks::Texture2D normalMap;
|
2016-07-14 23:45:52 +02:00
|
|
|
} model;
|
|
|
|
|
struct {
|
2017-02-09 21:55:35 +01:00
|
|
|
vks::Texture2D colorMap;
|
|
|
|
|
vks::Texture2D normalMap;
|
2016-07-14 23:45:52 +02:00
|
|
|
} background;
|
|
|
|
|
} textures;
|
2020-05-29 16:08:53 +01:00
|
|
|
|
2016-07-14 23:45:52 +02:00
|
|
|
struct {
|
2020-07-28 20:20:38 +02:00
|
|
|
vkglTF::Model model;
|
|
|
|
|
vkglTF::Model background;
|
2017-02-11 14:18:24 +01:00
|
|
|
} models;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
glm::mat4 projection;
|
|
|
|
|
glm::mat4 model;
|
|
|
|
|
glm::mat4 view;
|
|
|
|
|
glm::vec4 instancePos[3];
|
|
|
|
|
int layer;
|
2020-07-28 20:20:38 +02:00
|
|
|
} uboOffscreenVS;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// This UBO stores the shadow matrices for all of the light sources
|
|
|
|
|
// The matrices are indexed using geometry shader instancing
|
|
|
|
|
// The instancePos is used to place the models using instanced draws
|
|
|
|
|
struct {
|
|
|
|
|
glm::mat4 mvp[LIGHT_COUNT];
|
|
|
|
|
glm::vec4 instancePos[3];
|
2020-07-28 20:20:38 +02:00
|
|
|
} uboShadowGeometryShader;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
struct Light {
|
|
|
|
|
glm::vec4 position;
|
|
|
|
|
glm::vec4 target;
|
|
|
|
|
glm::vec4 color;
|
|
|
|
|
glm::mat4 viewMatrix;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
glm::vec4 viewPos;
|
|
|
|
|
Light lights[LIGHT_COUNT];
|
2016-07-17 18:34:52 +02:00
|
|
|
uint32_t useShadows = 1;
|
2020-07-28 20:20:38 +02:00
|
|
|
int32_t debugDisplayTarget = 0;
|
|
|
|
|
} uboComposition;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
struct {
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::Buffer offscreen;
|
|
|
|
|
vks::Buffer composition;
|
|
|
|
|
vks::Buffer shadowGeometryShader;
|
2016-12-24 12:48:01 +01:00
|
|
|
} uniformBuffers;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
VkPipeline deferred;
|
|
|
|
|
VkPipeline offscreen;
|
|
|
|
|
VkPipeline shadowpass;
|
|
|
|
|
} pipelines;
|
2020-07-28 20:20:38 +02:00
|
|
|
VkPipelineLayout pipelineLayout;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
VkDescriptorSet model;
|
|
|
|
|
VkDescriptorSet background;
|
|
|
|
|
VkDescriptorSet shadow;
|
|
|
|
|
} descriptorSets;
|
|
|
|
|
|
|
|
|
|
VkDescriptorSet descriptorSet;
|
|
|
|
|
VkDescriptorSetLayout descriptorSetLayout;
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
// Framebuffer resources for the deferred pass
|
2017-02-12 10:27:40 +01:00
|
|
|
vks::Framebuffer *deferred;
|
2016-07-14 23:45:52 +02:00
|
|
|
// Framebuffer resources for the shadow pass
|
2017-02-12 10:27:40 +01:00
|
|
|
vks::Framebuffer *shadow;
|
2016-07-14 23:45:52 +02:00
|
|
|
} frameBuffers;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
VkCommandBuffer deferred = VK_NULL_HANDLE;
|
|
|
|
|
} commandBuffers;
|
|
|
|
|
|
|
|
|
|
// Semaphore used to synchronize between offscreen and final scene rendering
|
|
|
|
|
VkSemaphore offscreenSemaphore = VK_NULL_HANDLE;
|
|
|
|
|
|
2016-12-14 20:17:15 +01:00
|
|
|
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
2016-07-14 23:45:52 +02:00
|
|
|
{
|
2017-11-01 14:22:10 +01:00
|
|
|
title = "Deferred shading with shadows";
|
2016-07-14 23:45:52 +02:00
|
|
|
camera.type = Camera::CameraType::firstperson;
|
2016-07-18 21:39:21 +02:00
|
|
|
#if defined(__ANDROID__)
|
|
|
|
|
camera.movementSpeed = 2.5f;
|
|
|
|
|
#else
|
2016-07-14 23:45:52 +02:00
|
|
|
camera.movementSpeed = 5.0f;
|
|
|
|
|
camera.rotationSpeed = 0.25f;
|
2016-07-18 21:39:21 +02:00
|
|
|
#endif
|
2016-07-14 23:45:52 +02:00
|
|
|
camera.position = { 2.15f, 0.3f, -8.75f };
|
|
|
|
|
camera.setRotation(glm::vec3(-0.75f, 12.5f, 0.0f));
|
|
|
|
|
camera.setPerspective(60.0f, (float)width / (float)height, zNear, zFar);
|
2016-07-16 23:27:39 +02:00
|
|
|
timerSpeed *= 0.25f;
|
|
|
|
|
paused = true;
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~VulkanExample()
|
|
|
|
|
{
|
|
|
|
|
// Frame buffers
|
2016-07-16 23:27:39 +02:00
|
|
|
if (frameBuffers.deferred)
|
|
|
|
|
{
|
|
|
|
|
delete frameBuffers.deferred;
|
|
|
|
|
}
|
|
|
|
|
if (frameBuffers.shadow)
|
|
|
|
|
{
|
|
|
|
|
delete frameBuffers.shadow;
|
|
|
|
|
}
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
vkDestroyPipeline(device, pipelines.deferred, nullptr);
|
|
|
|
|
vkDestroyPipeline(device, pipelines.offscreen, nullptr);
|
|
|
|
|
vkDestroyPipeline(device, pipelines.shadowpass, nullptr);
|
|
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
|
|
|
|
|
|
|
|
|
// Uniform buffers
|
2020-07-28 20:20:38 +02:00
|
|
|
uniformBuffers.composition.destroy();
|
|
|
|
|
uniformBuffers.offscreen.destroy();
|
|
|
|
|
uniformBuffers.shadowGeometryShader.destroy();
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Textures
|
2017-02-09 21:55:35 +01:00
|
|
|
textures.model.colorMap.destroy();
|
|
|
|
|
textures.model.normalMap.destroy();
|
|
|
|
|
textures.background.colorMap.destroy();
|
|
|
|
|
textures.background.normalMap.destroy();
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
vkDestroySemaphore(device, offscreenSemaphore, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-29 16:08:53 +01:00
|
|
|
// Enable physical device features required for this example
|
2017-03-11 11:39:05 +01:00
|
|
|
virtual void getEnabledFeatures()
|
|
|
|
|
{
|
|
|
|
|
// Geometry shader support is required for writing to multiple shadow map layers in one single pass
|
|
|
|
|
if (deviceFeatures.geometryShader) {
|
|
|
|
|
enabledFeatures.geometryShader = VK_TRUE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2018-01-21 18:28:17 +01:00
|
|
|
vks::tools::exitFatal("Selected GPU does not support geometry shaders!", VK_ERROR_FEATURE_NOT_PRESENT);
|
2017-03-11 11:39:05 +01:00
|
|
|
}
|
2017-06-07 22:44:29 +02:00
|
|
|
// Enable anisotropic filtering if supported
|
|
|
|
|
if (deviceFeatures.samplerAnisotropy) {
|
|
|
|
|
enabledFeatures.samplerAnisotropy = VK_TRUE;
|
|
|
|
|
}
|
2020-05-29 16:08:53 +01:00
|
|
|
// Enable texture compression
|
2017-06-07 22:44:29 +02:00
|
|
|
if (deviceFeatures.textureCompressionBC) {
|
|
|
|
|
enabledFeatures.textureCompressionBC = VK_TRUE;
|
|
|
|
|
}
|
|
|
|
|
else if (deviceFeatures.textureCompressionASTC_LDR) {
|
|
|
|
|
enabledFeatures.textureCompressionASTC_LDR = VK_TRUE;
|
|
|
|
|
}
|
|
|
|
|
else if (deviceFeatures.textureCompressionETC2) {
|
|
|
|
|
enabledFeatures.textureCompressionETC2 = VK_TRUE;
|
|
|
|
|
}
|
2017-03-11 11:39:05 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-14 23:45:52 +02:00
|
|
|
// Prepare a layered shadow map with each layer containing depth from a light's point of view
|
|
|
|
|
// The shadow mapping pass uses geometry shader instancing to output the scene from the different
|
2020-05-29 16:08:53 +01:00
|
|
|
// light sources' point of view to the layers of the depth attachment in one single pass
|
2016-07-14 23:45:52 +02:00
|
|
|
void shadowSetup()
|
|
|
|
|
{
|
2017-02-12 10:27:40 +01:00
|
|
|
frameBuffers.shadow = new vks::Framebuffer(vulkanDevice);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2016-07-16 23:27:39 +02:00
|
|
|
frameBuffers.shadow->width = SHADOWMAP_DIM;
|
|
|
|
|
frameBuffers.shadow->height = SHADOWMAP_DIM;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2016-07-16 23:27:39 +02:00
|
|
|
// Create a layered depth attachment for rendering the depth maps from the lights' point of view
|
|
|
|
|
// Each layer corresponds to one of the lights
|
|
|
|
|
// The actual output to the separate layers is done in the geometry shader using shader instancing
|
|
|
|
|
// We will pass the matrices of the lights to the GS that selects the layer by the current invocation
|
2017-02-12 10:27:40 +01:00
|
|
|
vks::AttachmentCreateInfo attachmentInfo = {};
|
2016-09-03 11:21:06 +02:00
|
|
|
attachmentInfo.format = SHADOWMAP_FORMAT;
|
|
|
|
|
attachmentInfo.width = SHADOWMAP_DIM;
|
|
|
|
|
attachmentInfo.height = SHADOWMAP_DIM;
|
|
|
|
|
attachmentInfo.layerCount = LIGHT_COUNT;
|
|
|
|
|
attachmentInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
|
|
|
|
frameBuffers.shadow->addAttachment(attachmentInfo);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-05-29 16:08:53 +01:00
|
|
|
// Create sampler to sample from to depth attachment
|
2016-07-14 23:45:52 +02:00
|
|
|
// Used to sample in the fragment shader for shadowed rendering
|
2016-07-16 23:27:39 +02:00
|
|
|
VK_CHECK_RESULT(frameBuffers.shadow->createSampler(VK_FILTER_LINEAR, VK_FILTER_LINEAR, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE));
|
|
|
|
|
|
|
|
|
|
// Create default renderpass for the framebuffer
|
|
|
|
|
VK_CHECK_RESULT(frameBuffers.shadow->createRenderPass());
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prepare the framebuffer for offscreen rendering with multiple attachments used as render targets inside the fragment shaders
|
|
|
|
|
void deferredSetup()
|
|
|
|
|
{
|
2017-02-12 10:27:40 +01:00
|
|
|
frameBuffers.deferred = new vks::Framebuffer(vulkanDevice);
|
2016-07-16 23:27:39 +02:00
|
|
|
|
|
|
|
|
frameBuffers.deferred->width = FB_DIM;
|
|
|
|
|
frameBuffers.deferred->height = FB_DIM;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Four attachments (3 color, 1 depth)
|
2017-02-12 10:27:40 +01:00
|
|
|
vks::AttachmentCreateInfo attachmentInfo = {};
|
2016-09-03 11:21:06 +02:00
|
|
|
attachmentInfo.width = FB_DIM;
|
|
|
|
|
attachmentInfo.height = FB_DIM;
|
|
|
|
|
attachmentInfo.layerCount = 1;
|
|
|
|
|
attachmentInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Color attachments
|
|
|
|
|
// Attachment 0: (World space) Positions
|
2016-09-03 11:21:06 +02:00
|
|
|
attachmentInfo.format = VK_FORMAT_R16G16B16A16_SFLOAT;
|
|
|
|
|
frameBuffers.deferred->addAttachment(attachmentInfo);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Attachment 1: (World space) Normals
|
2016-09-03 11:21:06 +02:00
|
|
|
attachmentInfo.format = VK_FORMAT_R16G16B16A16_SFLOAT;
|
|
|
|
|
frameBuffers.deferred->addAttachment(attachmentInfo);
|
2016-07-16 23:27:39 +02:00
|
|
|
|
|
|
|
|
// Attachment 2: Albedo (color)
|
2016-09-03 11:21:06 +02:00
|
|
|
attachmentInfo.format = VK_FORMAT_R8G8B8A8_UNORM;
|
|
|
|
|
frameBuffers.deferred->addAttachment(attachmentInfo);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Depth attachment
|
|
|
|
|
// Find a suitable depth format
|
|
|
|
|
VkFormat attDepthFormat;
|
2017-02-12 13:10:05 +01:00
|
|
|
VkBool32 validDepthFormat = vks::tools::getSupportedDepthFormat(physicalDevice, &attDepthFormat);
|
2016-07-14 23:45:52 +02:00
|
|
|
assert(validDepthFormat);
|
|
|
|
|
|
2016-09-03 11:21:06 +02:00
|
|
|
attachmentInfo.format = attDepthFormat;
|
|
|
|
|
attachmentInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
|
|
|
|
frameBuffers.deferred->addAttachment(attachmentInfo);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Create sampler to sample from the color attachments
|
2016-09-26 22:04:54 +02:00
|
|
|
VK_CHECK_RESULT(frameBuffers.deferred->createSampler(VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE));
|
2016-07-16 23:27:39 +02:00
|
|
|
|
|
|
|
|
// Create default renderpass for the framebuffer
|
|
|
|
|
VK_CHECK_RESULT(frameBuffers.deferred->createRenderPass());
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Put render commands for the scene into the given command buffer
|
|
|
|
|
void renderScene(VkCommandBuffer cmdBuffer, bool shadow)
|
|
|
|
|
{
|
|
|
|
|
VkDeviceSize offsets[1] = { 0 };
|
|
|
|
|
|
|
|
|
|
// Background
|
2020-07-28 20:20:38 +02:00
|
|
|
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, shadow ? &descriptorSets.shadow : &descriptorSets.background, 0, NULL);
|
|
|
|
|
models.background.draw(cmdBuffer);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Objects
|
2020-07-28 20:20:38 +02:00
|
|
|
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, shadow ? &descriptorSets.shadow : &descriptorSets.model, 0, NULL);
|
|
|
|
|
models.model.bindBuffers(cmdBuffer);
|
|
|
|
|
vkCmdDrawIndexed(cmdBuffer, models.model.indices.count, 3, 0, 0, 0);
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Build a secondary command buffer for rendering the scene values to the offscreen frame buffer attachments
|
|
|
|
|
void buildDeferredCommandBuffer()
|
|
|
|
|
{
|
|
|
|
|
if (commandBuffers.deferred == VK_NULL_HANDLE)
|
|
|
|
|
{
|
2020-04-20 22:13:51 +02:00
|
|
|
commandBuffers.deferred = vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create a semaphore used to synchronize offscreen rendering and usage
|
2017-02-12 11:12:42 +01:00
|
|
|
VkSemaphoreCreateInfo semaphoreCreateInfo = vks::initializers::semaphoreCreateInfo();
|
2016-07-14 23:45:52 +02:00
|
|
|
VK_CHECK_RESULT(vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &offscreenSemaphore));
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
|
2016-07-14 23:45:52 +02:00
|
|
|
std::array<VkClearValue, 4> clearValues = {};
|
|
|
|
|
VkViewport viewport;
|
|
|
|
|
VkRect2D scissor;
|
|
|
|
|
|
2016-08-12 22:13:37 +02:00
|
|
|
// First pass: Shadow map generation
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
2020-05-29 16:08:53 +01:00
|
|
|
|
2016-07-14 23:45:52 +02:00
|
|
|
clearValues[0].depthStencil = { 1.0f, 0 };
|
|
|
|
|
|
2016-07-16 23:27:39 +02:00
|
|
|
renderPassBeginInfo.renderPass = frameBuffers.shadow->renderPass;
|
|
|
|
|
renderPassBeginInfo.framebuffer = frameBuffers.shadow->framebuffer;
|
|
|
|
|
renderPassBeginInfo.renderArea.extent.width = frameBuffers.shadow->width;
|
|
|
|
|
renderPassBeginInfo.renderArea.extent.height = frameBuffers.shadow->height;
|
2016-07-14 23:45:52 +02:00
|
|
|
renderPassBeginInfo.clearValueCount = 1;
|
|
|
|
|
renderPassBeginInfo.pClearValues = clearValues.data();
|
|
|
|
|
|
|
|
|
|
VK_CHECK_RESULT(vkBeginCommandBuffer(commandBuffers.deferred, &cmdBufInfo));
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
viewport = vks::initializers::viewport((float)frameBuffers.shadow->width, (float)frameBuffers.shadow->height, 0.0f, 1.0f);
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdSetViewport(commandBuffers.deferred, 0, 1, &viewport);
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
scissor = vks::initializers::rect2D(frameBuffers.shadow->width, frameBuffers.shadow->height, 0, 0);
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdSetScissor(commandBuffers.deferred, 0, 1, &scissor);
|
|
|
|
|
|
|
|
|
|
// Set depth bias (aka "Polygon offset")
|
|
|
|
|
vkCmdSetDepthBias(
|
|
|
|
|
commandBuffers.deferred,
|
|
|
|
|
depthBiasConstant,
|
|
|
|
|
0.0f,
|
|
|
|
|
depthBiasSlope);
|
|
|
|
|
|
|
|
|
|
vkCmdBeginRenderPass(commandBuffers.deferred, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
|
vkCmdBindPipeline(commandBuffers.deferred, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.shadowpass);
|
|
|
|
|
renderScene(commandBuffers.deferred, true);
|
|
|
|
|
vkCmdEndRenderPass(commandBuffers.deferred);
|
|
|
|
|
|
2016-08-12 22:13:37 +02:00
|
|
|
// Second pass: Deferred calculations
|
2016-07-14 23:45:52 +02:00
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
2020-08-09 14:39:32 +02:00
|
|
|
// Clear values for all attachments written in the fragment shader
|
2016-07-14 23:45:52 +02:00
|
|
|
clearValues[0].color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
|
|
|
|
|
clearValues[1].color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
|
|
|
|
|
clearValues[2].color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
|
|
|
|
|
clearValues[3].depthStencil = { 1.0f, 0 };
|
|
|
|
|
|
2016-07-16 23:27:39 +02:00
|
|
|
renderPassBeginInfo.renderPass = frameBuffers.deferred->renderPass;
|
|
|
|
|
renderPassBeginInfo.framebuffer = frameBuffers.deferred->framebuffer;
|
|
|
|
|
renderPassBeginInfo.renderArea.extent.width = frameBuffers.deferred->width;
|
|
|
|
|
renderPassBeginInfo.renderArea.extent.height = frameBuffers.deferred->height;
|
2016-07-14 23:45:52 +02:00
|
|
|
renderPassBeginInfo.clearValueCount = static_cast<uint32_t>(clearValues.size());
|
|
|
|
|
renderPassBeginInfo.pClearValues = clearValues.data();
|
|
|
|
|
|
|
|
|
|
vkCmdBeginRenderPass(commandBuffers.deferred, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
viewport = vks::initializers::viewport((float)frameBuffers.deferred->width, (float)frameBuffers.deferred->height, 0.0f, 1.0f);
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdSetViewport(commandBuffers.deferred, 0, 1, &viewport);
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
scissor = vks::initializers::rect2D(frameBuffers.deferred->width, frameBuffers.deferred->height, 0, 0);
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdSetScissor(commandBuffers.deferred, 0, 1, &scissor);
|
|
|
|
|
|
|
|
|
|
vkCmdBindPipeline(commandBuffers.deferred, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.offscreen);
|
|
|
|
|
renderScene(commandBuffers.deferred, false);
|
|
|
|
|
vkCmdEndRenderPass(commandBuffers.deferred);
|
|
|
|
|
|
|
|
|
|
VK_CHECK_RESULT(vkEndCommandBuffer(commandBuffers.deferred));
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-09 21:55:35 +01:00
|
|
|
void loadAssets()
|
2016-07-14 23:45:52 +02:00
|
|
|
{
|
2020-07-28 20:20:38 +02:00
|
|
|
const uint32_t glTFLoadingFlags = vkglTF::FileLoadingFlags::PreTransformVertices | vkglTF::FileLoadingFlags::PreMultiplyVertexColors | vkglTF::FileLoadingFlags::FlipY;
|
|
|
|
|
models.model.loadFromFile(getAssetPath() + "models/armor/armor.gltf", vulkanDevice, queue, glTFLoadingFlags);
|
|
|
|
|
models.background.loadFromFile(getAssetPath() + "models/deferred_box.gltf", vulkanDevice, queue, glTFLoadingFlags);
|
|
|
|
|
textures.model.colorMap.loadFromFile(getAssetPath() + "models/armor/colormap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
|
|
|
|
|
textures.model.normalMap.loadFromFile(getAssetPath() + "models/armor/normalmap_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
|
|
|
|
|
textures.background.colorMap.loadFromFile(getAssetPath() + "textures/stonefloor02_color_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
|
|
|
|
|
textures.background.normalMap.loadFromFile(getAssetPath() + "textures/stonefloor02_normal_rgba.ktx", VK_FORMAT_R8G8B8A8_UNORM, vulkanDevice, queue);
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void buildCommandBuffers()
|
|
|
|
|
{
|
2017-02-12 11:12:42 +01:00
|
|
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
VkClearValue clearValues[2];
|
|
|
|
|
clearValues[0].color = { { 0.0f, 0.0f, 0.2f, 0.0f } };
|
|
|
|
|
clearValues[1].depthStencil = { 1.0f, 0 };
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
|
2016-07-14 23:45:52 +02:00
|
|
|
renderPassBeginInfo.renderPass = renderPass;
|
|
|
|
|
renderPassBeginInfo.renderArea.offset.x = 0;
|
|
|
|
|
renderPassBeginInfo.renderArea.offset.y = 0;
|
|
|
|
|
renderPassBeginInfo.renderArea.extent.width = width;
|
|
|
|
|
renderPassBeginInfo.renderArea.extent.height = height;
|
|
|
|
|
renderPassBeginInfo.clearValueCount = 2;
|
|
|
|
|
renderPassBeginInfo.pClearValues = clearValues;
|
|
|
|
|
|
|
|
|
|
for (int32_t i = 0; i < drawCmdBuffers.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
// Set target frame buffer
|
|
|
|
|
renderPassBeginInfo.framebuffer = VulkanExampleBase::frameBuffers[i];
|
|
|
|
|
|
|
|
|
|
VK_CHECK_RESULT(vkBeginCommandBuffer(drawCmdBuffers[i], &cmdBufInfo));
|
|
|
|
|
|
|
|
|
|
vkCmdBeginRenderPass(drawCmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
VkViewport viewport = vks::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
|
|
|
|
|
|
2017-02-12 11:12:42 +01:00
|
|
|
VkRect2D scissor = vks::initializers::rect2D(width, height, 0, 0);
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor);
|
|
|
|
|
|
|
|
|
|
VkDeviceSize offsets[1] = { 0 };
|
2020-07-28 20:20:38 +02:00
|
|
|
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Final composition as full screen quad
|
2020-07-28 20:20:38 +02:00
|
|
|
// Note: Also used for debug display if debugDisplayTarget > 0
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.deferred);
|
2020-07-28 20:20:38 +02:00
|
|
|
vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2018-08-30 21:08:02 +02:00
|
|
|
drawUI(drawCmdBuffers[i]);
|
|
|
|
|
|
2016-07-14 23:45:52 +02:00
|
|
|
vkCmdEndRenderPass(drawCmdBuffers[i]);
|
|
|
|
|
|
|
|
|
|
VK_CHECK_RESULT(vkEndCommandBuffer(drawCmdBuffers[i]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setupDescriptorPool()
|
|
|
|
|
{
|
|
|
|
|
std::vector<VkDescriptorPoolSize> poolSizes =
|
|
|
|
|
{
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 12), //todo: separate set layouts
|
|
|
|
|
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 16)
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::descriptorPoolCreateInfo(
|
2016-07-14 23:45:52 +02:00
|
|
|
static_cast<uint32_t>(poolSizes.size()),
|
|
|
|
|
poolSizes.data(),
|
|
|
|
|
4);
|
|
|
|
|
|
|
|
|
|
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolInfo, nullptr, &descriptorPool));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setupDescriptorSetLayout()
|
|
|
|
|
{
|
2020-07-28 20:20:38 +02:00
|
|
|
// // Deferred shading layout
|
|
|
|
|
std::vector<VkDescriptorSetLayoutBinding> setLayoutBindings = {
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 0: Vertex shader uniform buffer
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT, 0),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 1: Position texture
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 1),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 2: Normals texture
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 2),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 3: Albedo texture
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 3),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 4: Fragment shader uniform buffer
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_SHADER_STAGE_FRAGMENT_BIT, 4),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 5: Shadow map
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, 5),
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
2020-07-28 20:20:38 +02:00
|
|
|
VkDescriptorSetLayoutCreateInfo descriptorLayout = vks::initializers::descriptorSetLayoutCreateInfo(setLayoutBindings);
|
2016-07-14 23:45:52 +02:00
|
|
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout));
|
|
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
// Shared pipeline layout used by all pipelines
|
|
|
|
|
VkPipelineLayoutCreateInfo pPipelineLayoutCreateInfo = vks::initializers::pipelineLayoutCreateInfo(&descriptorSetLayout, 1);
|
|
|
|
|
VK_CHECK_RESULT(vkCreatePipelineLayout(device, &pPipelineLayoutCreateInfo, nullptr, &pipelineLayout));
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setupDescriptorSet()
|
|
|
|
|
{
|
|
|
|
|
std::vector<VkWriteDescriptorSet> writeDescriptorSets;
|
2020-07-28 20:20:38 +02:00
|
|
|
VkDescriptorSetAllocateInfo allocInfo = vks::initializers::descriptorSetAllocateInfo(descriptorPool, &descriptorSetLayout, 1);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Image descriptors for the offscreen color attachments
|
|
|
|
|
VkDescriptorImageInfo texDescriptorPosition =
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::descriptorImageInfo(
|
2016-07-16 23:27:39 +02:00
|
|
|
frameBuffers.deferred->sampler,
|
|
|
|
|
frameBuffers.deferred->attachments[0].view,
|
2016-12-14 20:17:15 +01:00
|
|
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
VkDescriptorImageInfo texDescriptorNormal =
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::descriptorImageInfo(
|
2016-07-16 23:27:39 +02:00
|
|
|
frameBuffers.deferred->sampler,
|
|
|
|
|
frameBuffers.deferred->attachments[1].view,
|
2016-12-14 20:17:15 +01:00
|
|
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
VkDescriptorImageInfo texDescriptorAlbedo =
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::descriptorImageInfo(
|
2016-07-16 23:27:39 +02:00
|
|
|
frameBuffers.deferred->sampler,
|
|
|
|
|
frameBuffers.deferred->attachments[2].view,
|
2016-12-14 20:17:15 +01:00
|
|
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
VkDescriptorImageInfo texDescriptorShadowMap =
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::descriptorImageInfo(
|
2016-07-16 23:27:39 +02:00
|
|
|
frameBuffers.shadow->sampler,
|
|
|
|
|
frameBuffers.shadow->attachments[0].view,
|
2017-02-21 12:53:27 +01:00
|
|
|
VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
// Deferred composition
|
|
|
|
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSet));
|
2016-07-14 23:45:52 +02:00
|
|
|
writeDescriptorSets = {
|
|
|
|
|
// Binding 1: World space position texture
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &texDescriptorPosition),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 2: World space normals texture
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2, &texDescriptorNormal),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 3: Albedo texture
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 3, &texDescriptorAlbedo),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 4: Fragment shader uniform buffer
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 4, &uniformBuffers.composition.descriptor),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 5: Shadow map
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 5, &texDescriptorShadowMap),
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
|
|
|
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL);
|
|
|
|
|
|
|
|
|
|
// Offscreen (scene)
|
|
|
|
|
|
|
|
|
|
// Model
|
|
|
|
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSets.model));
|
2020-07-28 20:20:38 +02:00
|
|
|
writeDescriptorSets = {
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 0: Vertex shader uniform buffer
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.model, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBuffers.offscreen.descriptor),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 1: Color map
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.model, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &textures.model.colorMap.descriptor),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 2: Normal map
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.model, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2, &textures.model.normalMap.descriptor)
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
2020-07-28 20:20:38 +02:00
|
|
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Background
|
|
|
|
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSets.background));
|
2020-07-28 20:20:38 +02:00
|
|
|
writeDescriptorSets = {
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 0: Vertex shader uniform buffer
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.background, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBuffers.offscreen.descriptor),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 1: Color map
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.background, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, &textures.background.colorMap.descriptor),
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 2: Normal map
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.background, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2, &textures.background.normalMap.descriptor)
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
2020-07-28 20:20:38 +02:00
|
|
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Shadow mapping
|
|
|
|
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSets.shadow));
|
2020-07-28 20:20:38 +02:00
|
|
|
writeDescriptorSets = {
|
2016-07-14 23:45:52 +02:00
|
|
|
// Binding 0: Vertex shader uniform buffer
|
2020-07-28 20:20:38 +02:00
|
|
|
vks::initializers::writeDescriptorSet(descriptorSets.shadow, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, &uniformBuffers.shadowGeometryShader.descriptor),
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
2020-07-28 20:20:38 +02:00
|
|
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void preparePipelines()
|
|
|
|
|
{
|
2020-07-28 20:20:38 +02:00
|
|
|
VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = vks::initializers::pipelineInputAssemblyStateCreateInfo(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, 0, VK_FALSE);
|
|
|
|
|
VkPipelineRasterizationStateCreateInfo rasterizationState = vks::initializers::pipelineRasterizationStateCreateInfo(VK_POLYGON_MODE_FILL, VK_CULL_MODE_BACK_BIT, VK_FRONT_FACE_COUNTER_CLOCKWISE, 0);
|
|
|
|
|
VkPipelineColorBlendAttachmentState blendAttachmentState = vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE);
|
|
|
|
|
VkPipelineColorBlendStateCreateInfo colorBlendState = vks::initializers::pipelineColorBlendStateCreateInfo(1, &blendAttachmentState);
|
|
|
|
|
VkPipelineDepthStencilStateCreateInfo depthStencilState = vks::initializers::pipelineDepthStencilStateCreateInfo(VK_TRUE, VK_TRUE, VK_COMPARE_OP_LESS_OR_EQUAL);
|
|
|
|
|
VkPipelineViewportStateCreateInfo viewportState = vks::initializers::pipelineViewportStateCreateInfo(1, 1, 0);
|
|
|
|
|
VkPipelineMultisampleStateCreateInfo multisampleState = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
|
|
|
|
|
std::vector<VkDynamicState> dynamicStateEnables = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR};
|
|
|
|
|
VkPipelineDynamicStateCreateInfo dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
|
2016-07-14 23:45:52 +02:00
|
|
|
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
|
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayout, renderPass);
|
|
|
|
|
pipelineCI.pInputAssemblyState = &inputAssemblyState;
|
|
|
|
|
pipelineCI.pRasterizationState = &rasterizationState;
|
|
|
|
|
pipelineCI.pColorBlendState = &colorBlendState;
|
|
|
|
|
pipelineCI.pMultisampleState = &multisampleState;
|
|
|
|
|
pipelineCI.pViewportState = &viewportState;
|
|
|
|
|
pipelineCI.pDepthStencilState = &depthStencilState;
|
|
|
|
|
pipelineCI.pDynamicState = &dynamicState;
|
|
|
|
|
pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
|
|
|
|
|
pipelineCI.pStages = shaderStages.data();
|
|
|
|
|
|
|
|
|
|
// Final fullscreen composition pass pipeline
|
|
|
|
|
rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
|
2020-05-29 16:08:53 +01:00
|
|
|
shaderStages[0] = loadShader(getShadersPath() + "deferredshadows/deferred.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
|
|
|
|
shaderStages[1] = loadShader(getShadersPath() + "deferredshadows/deferred.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
2020-07-28 20:20:38 +02:00
|
|
|
// Empty vertex input state, vertices are generated by the vertex shader
|
|
|
|
|
VkPipelineVertexInputStateCreateInfo emptyInputState = vks::initializers::pipelineVertexInputStateCreateInfo();
|
|
|
|
|
pipelineCI.pVertexInputState = &emptyInputState;
|
|
|
|
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.deferred));
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
// Vertex input state from glTF model for pipeline rendering models
|
|
|
|
|
pipelineCI.pVertexInputState = vkglTF::Vertex::getPipelineVertexInputState({ vkglTF::VertexComponent::Position, vkglTF::VertexComponent::UV, vkglTF::VertexComponent::Color, vkglTF::VertexComponent::Normal, vkglTF::VertexComponent::Tangent });
|
|
|
|
|
rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Offscreen pipeline
|
|
|
|
|
// Separate render pass
|
2020-07-28 20:20:38 +02:00
|
|
|
pipelineCI.renderPass = frameBuffers.deferred->renderPass;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Blend attachment states required for all color attachments
|
|
|
|
|
// This is important, as color write mask will otherwise be 0x0 and you
|
|
|
|
|
// won't see anything rendered to the attachment
|
|
|
|
|
std::array<VkPipelineColorBlendAttachmentState, 3> blendAttachmentStates =
|
|
|
|
|
{
|
2017-02-12 11:12:42 +01:00
|
|
|
vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE),
|
|
|
|
|
vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE),
|
|
|
|
|
vks::initializers::pipelineColorBlendAttachmentState(0xf, VK_FALSE)
|
2016-07-14 23:45:52 +02:00
|
|
|
};
|
|
|
|
|
colorBlendState.attachmentCount = static_cast<uint32_t>(blendAttachmentStates.size());
|
|
|
|
|
colorBlendState.pAttachments = blendAttachmentStates.data();
|
|
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
shaderStages[0] = loadShader(getShadersPath() + "deferredshadows/mrt.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
|
|
|
|
shaderStages[1] = loadShader(getShadersPath() + "deferredshadows/mrt.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
|
|
|
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.offscreen));
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Shadow mapping pipeline
|
2020-05-29 16:08:53 +01:00
|
|
|
// The shadow mapping pipeline uses geometry shader instancing (invocations layout modifier) to output
|
2017-03-11 11:39:05 +01:00
|
|
|
// shadow maps for multiple lights sources into the different shadow map layers in one single render pass
|
2018-09-16 21:39:31 +02:00
|
|
|
std::array<VkPipelineShaderStageCreateInfo, 2> shadowStages;
|
2020-05-29 16:08:53 +01:00
|
|
|
shadowStages[0] = loadShader(getShadersPath() + "deferredshadows/shadow.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
|
|
|
|
shadowStages[1] = loadShader(getShadersPath() + "deferredshadows/shadow.geom.spv", VK_SHADER_STAGE_GEOMETRY_BIT);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
pipelineCI.pStages = shadowStages.data();
|
|
|
|
|
pipelineCI.stageCount = static_cast<uint32_t>(shadowStages.size());
|
2020-05-29 16:08:53 +01:00
|
|
|
|
2016-07-16 23:27:39 +02:00
|
|
|
// Shadow pass doesn't use any color attachments
|
2016-07-14 23:45:52 +02:00
|
|
|
colorBlendState.attachmentCount = 0;
|
|
|
|
|
colorBlendState.pAttachments = nullptr;
|
|
|
|
|
// Cull front faces
|
|
|
|
|
rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
|
|
|
|
|
depthStencilState.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
|
|
|
|
|
// Enable depth bias
|
|
|
|
|
rasterizationState.depthBiasEnable = VK_TRUE;
|
|
|
|
|
// Add depth bias to dynamic state, so we can change it at runtime
|
|
|
|
|
dynamicStateEnables.push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
|
2020-07-28 20:20:38 +02:00
|
|
|
dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
|
2016-07-14 23:45:52 +02:00
|
|
|
// Reset blend attachment state
|
2020-07-28 20:20:38 +02:00
|
|
|
pipelineCI.renderPass = frameBuffers.shadow->renderPass;
|
|
|
|
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.shadowpass));
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Prepare and initialize uniform buffer containing shader uniforms
|
|
|
|
|
void prepareUniformBuffers()
|
|
|
|
|
{
|
2020-07-28 20:20:38 +02:00
|
|
|
// Offscreen vertex shader
|
2016-12-24 12:48:01 +01:00
|
|
|
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
2016-07-14 23:45:52 +02:00
|
|
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
2020-07-28 20:20:38 +02:00
|
|
|
&uniformBuffers.offscreen,
|
2016-12-24 12:48:01 +01:00
|
|
|
sizeof(uboOffscreenVS)));
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Deferred fragment shader
|
2016-12-24 12:48:01 +01:00
|
|
|
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
2016-07-14 23:45:52 +02:00
|
|
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
2020-07-28 20:20:38 +02:00
|
|
|
&uniformBuffers.composition,
|
|
|
|
|
sizeof(uboComposition)));;
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Shadow map vertex shader (matrices from shadow's pov)
|
2016-12-24 12:48:01 +01:00
|
|
|
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
2016-07-14 23:45:52 +02:00
|
|
|
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
|
|
|
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
2020-07-28 20:20:38 +02:00
|
|
|
&uniformBuffers.shadowGeometryShader,
|
|
|
|
|
sizeof(uboShadowGeometryShader)));
|
2016-12-24 12:48:01 +01:00
|
|
|
|
|
|
|
|
// Map persistent
|
2020-07-28 20:20:38 +02:00
|
|
|
VK_CHECK_RESULT(uniformBuffers.offscreen.map());
|
|
|
|
|
VK_CHECK_RESULT(uniformBuffers.composition.map());
|
|
|
|
|
VK_CHECK_RESULT(uniformBuffers.shadowGeometryShader.map());
|
2016-07-14 23:45:52 +02:00
|
|
|
|
|
|
|
|
// Init some values
|
|
|
|
|
uboOffscreenVS.instancePos[0] = glm::vec4(0.0f);
|
|
|
|
|
uboOffscreenVS.instancePos[1] = glm::vec4(-4.0f, 0.0, -4.0f, 0.0f);
|
|
|
|
|
uboOffscreenVS.instancePos[2] = glm::vec4(4.0f, 0.0, -4.0f, 0.0f);
|
|
|
|
|
|
2016-07-16 23:27:39 +02:00
|
|
|
uboOffscreenVS.instancePos[1] = glm::vec4(-7.0f, 0.0, -4.0f, 0.0f);
|
|
|
|
|
uboOffscreenVS.instancePos[2] = glm::vec4(4.0f, 0.0, -6.0f, 0.0f);
|
|
|
|
|
|
2016-07-14 23:45:52 +02:00
|
|
|
// Update
|
2020-07-28 20:20:38 +02:00
|
|
|
updateUniformBufferOffscreen();
|
2016-07-14 23:45:52 +02:00
|
|
|
updateUniformBufferDeferredLights();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
void updateUniformBufferOffscreen()
|
2016-07-14 23:45:52 +02:00
|
|
|
{
|
|
|
|
|
uboOffscreenVS.projection = camera.matrices.perspective;
|
|
|
|
|
uboOffscreenVS.view = camera.matrices.view;
|
2017-09-24 18:17:07 +02:00
|
|
|
uboOffscreenVS.model = glm::mat4(1.0f);
|
2020-07-28 20:20:38 +02:00
|
|
|
memcpy(uniformBuffers.offscreen.mapped, &uboOffscreenVS, sizeof(uboOffscreenVS));
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-03 11:21:06 +02:00
|
|
|
Light initLight(glm::vec3 pos, glm::vec3 target, glm::vec3 color)
|
|
|
|
|
{
|
|
|
|
|
Light light;
|
|
|
|
|
light.position = glm::vec4(pos, 1.0f);
|
|
|
|
|
light.target = glm::vec4(target, 0.0f);
|
|
|
|
|
light.color = glm::vec4(color, 0.0f);
|
|
|
|
|
return light;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void initLights()
|
|
|
|
|
{
|
2020-07-28 20:20:38 +02:00
|
|
|
uboComposition.lights[0] = initLight(glm::vec3(-14.0f, -0.5f, 15.0f), glm::vec3(-2.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.5f, 0.5f));
|
|
|
|
|
uboComposition.lights[1] = initLight(glm::vec3(14.0f, -4.0f, 12.0f), glm::vec3(2.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
|
|
|
|
uboComposition.lights[2] = initLight(glm::vec3(0.0f, -10.0f, 4.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f));
|
2016-09-03 11:21:06 +02:00
|
|
|
}
|
|
|
|
|
|
2016-07-14 23:45:52 +02:00
|
|
|
// Update fragment shader light position uniform block
|
|
|
|
|
void updateUniformBufferDeferredLights()
|
|
|
|
|
{
|
2016-07-16 23:27:39 +02:00
|
|
|
// Animate
|
2020-07-28 20:20:38 +02:00
|
|
|
uboComposition.lights[0].position.x = -14.0f + std::abs(sin(glm::radians(timer * 360.0f)) * 20.0f);
|
|
|
|
|
uboComposition.lights[0].position.z = 15.0f + cos(glm::radians(timer *360.0f)) * 1.0f;
|
2016-07-16 23:27:39 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
uboComposition.lights[1].position.x = 14.0f - std::abs(sin(glm::radians(timer * 360.0f)) * 2.5f);
|
|
|
|
|
uboComposition.lights[1].position.z = 13.0f + cos(glm::radians(timer *360.0f)) * 4.0f;
|
2016-07-16 23:27:39 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
uboComposition.lights[2].position.x = 0.0f + sin(glm::radians(timer *360.0f)) * 4.0f;
|
|
|
|
|
uboComposition.lights[2].position.z = 4.0f + cos(glm::radians(timer *360.0f)) * 2.0f;
|
2016-07-16 23:27:39 +02:00
|
|
|
|
2016-09-03 11:21:06 +02:00
|
|
|
for (uint32_t i = 0; i < LIGHT_COUNT; i++)
|
2016-07-14 23:45:52 +02:00
|
|
|
{
|
|
|
|
|
// mvp from light's pov (for shadows)
|
|
|
|
|
glm::mat4 shadowProj = glm::perspective(glm::radians(lightFOV), 1.0f, zNear, zFar);
|
2020-07-28 20:20:38 +02:00
|
|
|
glm::mat4 shadowView = glm::lookAt(glm::vec3(uboComposition.lights[i].position), glm::vec3(uboComposition.lights[i].target), glm::vec3(0.0f, 1.0f, 0.0f));
|
2017-09-24 18:17:07 +02:00
|
|
|
glm::mat4 shadowModel = glm::mat4(1.0f);
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
uboShadowGeometryShader.mvp[i] = shadowProj * shadowView * shadowModel;
|
|
|
|
|
uboComposition.lights[i].viewMatrix = uboShadowGeometryShader.mvp[i];
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
memcpy(uboShadowGeometryShader.instancePos, uboOffscreenVS.instancePos, sizeof(uboOffscreenVS.instancePos));
|
|
|
|
|
memcpy(uniformBuffers.shadowGeometryShader.mapped, &uboShadowGeometryShader, sizeof(uboShadowGeometryShader));
|
2016-07-14 23:45:52 +02:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
uboComposition.viewPos = glm::vec4(camera.position, 0.0f) * glm::vec4(-1.0f, 1.0f, -1.0f, 1.0f);;
|
|
|
|
|
uboComposition.debugDisplayTarget = debugDisplayTarget;
|
2020-05-29 16:08:53 +01:00
|
|
|
|
2020-07-28 20:20:38 +02:00
|
|
|
memcpy(uniformBuffers.composition.mapped, &uboComposition, sizeof(uboComposition));
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void draw()
|
|
|
|
|
{
|
|
|
|
|
VulkanExampleBase::prepareFrame();
|
|
|
|
|
|
|
|
|
|
// Offscreen rendering
|
|
|
|
|
|
|
|
|
|
// Wait for swap chain presentation to finish
|
|
|
|
|
submitInfo.pWaitSemaphores = &semaphores.presentComplete;
|
|
|
|
|
// Signal ready with offscreen semaphore
|
|
|
|
|
submitInfo.pSignalSemaphores = &offscreenSemaphore;
|
|
|
|
|
|
|
|
|
|
// Submit work
|
|
|
|
|
|
|
|
|
|
// Shadow map pass
|
|
|
|
|
submitInfo.commandBufferCount = 1;
|
|
|
|
|
submitInfo.pCommandBuffers = &commandBuffers.deferred;
|
|
|
|
|
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
|
|
|
|
|
|
|
|
|
// Scene rendering
|
|
|
|
|
|
|
|
|
|
// Wait for offscreen semaphore
|
|
|
|
|
submitInfo.pWaitSemaphores = &offscreenSemaphore;
|
2020-08-08 18:22:10 +02:00
|
|
|
// Signal ready with render complete semaphore
|
2016-07-14 23:45:52 +02:00
|
|
|
submitInfo.pSignalSemaphores = &semaphores.renderComplete;
|
|
|
|
|
|
|
|
|
|
// Submit work
|
|
|
|
|
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
|
|
|
|
VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE));
|
|
|
|
|
|
|
|
|
|
VulkanExampleBase::submitFrame();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void prepare()
|
|
|
|
|
{
|
|
|
|
|
VulkanExampleBase::prepare();
|
2017-02-09 21:55:35 +01:00
|
|
|
loadAssets();
|
2016-07-14 23:45:52 +02:00
|
|
|
deferredSetup();
|
|
|
|
|
shadowSetup();
|
2016-09-03 11:21:06 +02:00
|
|
|
initLights();
|
2016-07-14 23:45:52 +02:00
|
|
|
prepareUniformBuffers();
|
|
|
|
|
setupDescriptorSetLayout();
|
|
|
|
|
preparePipelines();
|
|
|
|
|
setupDescriptorPool();
|
|
|
|
|
setupDescriptorSet();
|
|
|
|
|
buildCommandBuffers();
|
|
|
|
|
buildDeferredCommandBuffer();
|
|
|
|
|
prepared = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void render()
|
|
|
|
|
{
|
|
|
|
|
if (!prepared)
|
|
|
|
|
return;
|
|
|
|
|
draw();
|
2016-09-03 11:21:06 +02:00
|
|
|
updateUniformBufferDeferredLights();
|
2020-07-28 20:20:38 +02:00
|
|
|
if (camera.updated)
|
|
|
|
|
{
|
|
|
|
|
updateUniformBufferOffscreen();
|
|
|
|
|
}
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-01 14:22:10 +01:00
|
|
|
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
|
2016-07-14 23:45:52 +02:00
|
|
|
{
|
2017-11-01 14:22:10 +01:00
|
|
|
if (overlay->header("Settings")) {
|
2020-07-28 20:20:38 +02:00
|
|
|
if (overlay->comboBox("Display", &debugDisplayTarget, { "Final composition", "Shadows", "Position", "Normals", "Albedo", "Specular" }))
|
|
|
|
|
{
|
|
|
|
|
updateUniformBufferDeferredLights();
|
2017-11-01 14:22:10 +01:00
|
|
|
}
|
2020-07-28 20:20:38 +02:00
|
|
|
bool shadows = (uboComposition.useShadows == 1);
|
2017-11-01 14:22:10 +01:00
|
|
|
if (overlay->checkBox("Shadows", &shadows)) {
|
2020-07-28 20:20:38 +02:00
|
|
|
uboComposition.useShadows = shadows;
|
2017-11-01 14:22:10 +01:00
|
|
|
updateUniformBufferDeferredLights();
|
|
|
|
|
}
|
2016-07-14 23:45:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-11 13:15:49 +02:00
|
|
|
VULKAN_EXAMPLE_MAIN()
|