Simplified offscreen sample
This commit is contained in:
parent
0e9ab19fad
commit
526ed2da0e
3 changed files with 2 additions and 33 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
layout (binding = 1) uniform sampler2D samplerColor;
|
layout (binding = 1) uniform sampler2D samplerColor;
|
||||||
layout (binding = 2) uniform sampler2D samplerColorMap;
|
|
||||||
|
|
||||||
layout (location = 0) in vec2 inUV;
|
layout (location = 0) in vec2 inUV;
|
||||||
layout (location = 1) in vec4 inPos;
|
layout (location = 1) in vec4 inPos;
|
||||||
|
|
@ -21,8 +20,7 @@ void main()
|
||||||
// For demonstration purposes only
|
// For demonstration purposes only
|
||||||
const float blurSize = 1.0 / 512.0;
|
const float blurSize = 1.0 / 512.0;
|
||||||
|
|
||||||
vec4 color = texture(samplerColorMap, inUV);
|
outFragColor = vec4(vec3(0.0), 1.);
|
||||||
outFragColor = color * 0.25;
|
|
||||||
|
|
||||||
if (gl_FrontFacing)
|
if (gl_FrontFacing)
|
||||||
{
|
{
|
||||||
|
|
@ -35,6 +33,6 @@ void main()
|
||||||
reflection += texture(samplerColor, vec2(projCoord.s + x * blurSize, projCoord.t + y * blurSize)) / 49.0;
|
reflection += texture(samplerColor, vec2(projCoord.s + x * blurSize, projCoord.t + y * blurSize)) / 49.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outFragColor += reflection * 1.5 * (color.r);
|
outFragColor += reflection;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include "vulkanexamplebase.h"
|
#include "vulkanexamplebase.h"
|
||||||
#include "VulkanTexture.hpp"
|
|
||||||
#include "VulkanModel.hpp"
|
#include "VulkanModel.hpp"
|
||||||
#include "VulkanBuffer.hpp"
|
#include "VulkanBuffer.hpp"
|
||||||
|
|
||||||
|
|
@ -34,10 +33,6 @@ class VulkanExample : public VulkanExampleBase
|
||||||
public:
|
public:
|
||||||
bool debugDisplay = false;
|
bool debugDisplay = false;
|
||||||
|
|
||||||
struct {
|
|
||||||
vks::Texture2D colorMap;
|
|
||||||
} textures;
|
|
||||||
|
|
||||||
// Vertex layout for the models
|
// Vertex layout for the models
|
||||||
vks::VertexLayout vertexLayout = vks::VertexLayout({
|
vks::VertexLayout vertexLayout = vks::VertexLayout({
|
||||||
vks::VERTEX_COMPONENT_POSITION,
|
vks::VERTEX_COMPONENT_POSITION,
|
||||||
|
|
@ -124,9 +119,6 @@ public:
|
||||||
// Clean up used Vulkan resources
|
// Clean up used Vulkan resources
|
||||||
// Note : Inherited destructor cleans up resources stored in base class
|
// Note : Inherited destructor cleans up resources stored in base class
|
||||||
|
|
||||||
// Textures
|
|
||||||
textures.colorMap.destroy();
|
|
||||||
|
|
||||||
// Frame buffer
|
// Frame buffer
|
||||||
|
|
||||||
// Color attachment
|
// Color attachment
|
||||||
|
|
@ -453,20 +445,6 @@ public:
|
||||||
{
|
{
|
||||||
models.plane.loadFromFile(getAssetPath() + "models/plane.obj", vertexLayout, 0.5f, vulkanDevice, queue);
|
models.plane.loadFromFile(getAssetPath() + "models/plane.obj", vertexLayout, 0.5f, vulkanDevice, queue);
|
||||||
models.example.loadFromFile(getAssetPath() + "models/chinesedragon.dae", vertexLayout, 0.3f, vulkanDevice, queue);
|
models.example.loadFromFile(getAssetPath() + "models/chinesedragon.dae", vertexLayout, 0.3f, vulkanDevice, queue);
|
||||||
|
|
||||||
// Textures
|
|
||||||
if (vulkanDevice->features.textureCompressionBC) {
|
|
||||||
textures.colorMap.loadFromFile(getAssetPath() + "textures/darkmetal_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
|
|
||||||
}
|
|
||||||
else if (vulkanDevice->features.textureCompressionASTC_LDR) {
|
|
||||||
textures.colorMap.loadFromFile(getAssetPath() + "textures/darkmetal_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue);
|
|
||||||
}
|
|
||||||
else if (vulkanDevice->features.textureCompressionETC2) {
|
|
||||||
textures.colorMap.loadFromFile(getAssetPath() + "textures/darkmetal_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, vulkanDevice, queue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
vks::tools::exitFatal("Device does not support any compressed texture format!", VK_ERROR_FEATURE_NOT_PRESENT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateQuad()
|
void generateQuad()
|
||||||
|
|
@ -591,12 +569,6 @@ public:
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||||
1,
|
1,
|
||||||
&offscreenPass.descriptor),
|
&offscreenPass.descriptor),
|
||||||
// Binding 2 : Fragment shader texture sampler
|
|
||||||
vks::initializers::writeDescriptorSet(
|
|
||||||
descriptorSets.mirror,
|
|
||||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
|
||||||
2,
|
|
||||||
&textures.colorMap.descriptor)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
|
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
|
||||||
|
|
@ -625,7 +597,6 @@ public:
|
||||||
allocInfo.pSetLayouts = &descriptorSetLayouts.shaded;
|
allocInfo.pSetLayouts = &descriptorSetLayouts.shaded;
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
// No texture
|
|
||||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSets.model));
|
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &allocInfo, &descriptorSets.model));
|
||||||
|
|
||||||
std::vector<VkWriteDescriptorSet> modelWriteDescriptorSets =
|
std::vector<VkWriteDescriptorSet> modelWriteDescriptorSets =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue