diff --git a/projects/voxelization/resources/shaders/bloomFlaresComposite.comp b/projects/voxelization/resources/shaders/bloomFlaresComposite.comp index 190bed0657d70e0217bf654820d0b2b2c58f12c2..eb17ea90d62ca17ccd37b4e651b8469c73620b49 100644 --- a/projects/voxelization/resources/shaders/bloomFlaresComposite.comp +++ b/projects/voxelization/resources/shaders/bloomFlaresComposite.comp @@ -16,7 +16,7 @@ void main() } ivec2 pixel_coord = ivec2(gl_GlobalInvocationID.xy); - vec2 pixel_size = vec2(1.0f) / textureSize(sampler2D(blurImage, linearSampler), 0); + vec2 pixel_size = vec2(1.0f) / imageSize(colorBuffer); vec2 UV = pixel_coord.xy * pixel_size; vec4 composite_color = vec4(0.0f); diff --git a/projects/voxelization/src/BloomAndFlares.cpp b/projects/voxelization/src/BloomAndFlares.cpp index 4e69e5595107b435de05b177b586e61ac7a7cacb..aa077ef5f4a089bfe226328a183789e1d6bb3890 100644 --- a/projects/voxelization/src/BloomAndFlares.cpp +++ b/projects/voxelization/src/BloomAndFlares.cpp @@ -9,14 +9,14 @@ BloomAndFlares::BloomAndFlares( p_Core(p_Core), m_ColorBufferFormat(colorBufferFormat), - m_Width(width), - m_Height(height), + m_Width(width / 2), + m_Height(height / 2), m_LinearSampler(p_Core->createSampler(vkcv::SamplerFilterType::LINEAR, vkcv::SamplerFilterType::LINEAR, vkcv::SamplerMipmapMode::LINEAR, vkcv::SamplerAddressMode::CLAMP_TO_EDGE)), - m_Blur(p_Core->createImage(colorBufferFormat, width, height, 1, true, true, false)), - m_LensFeatures(p_Core->createImage(colorBufferFormat, width, height, 1, true, true, false)) + m_Blur(p_Core->createImage(colorBufferFormat, m_Width, m_Height, 1, true, true, false)), + m_LensFeatures(p_Core->createImage(colorBufferFormat, m_Width, m_Height, 1, true, true, false)) { vkcv::shader::GLSLCompiler compiler; @@ -264,8 +264,8 @@ void BloomAndFlares::execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStr } } -void BloomAndFlares::execCompositePipe(const vkcv::CommandStreamHandle &cmdStream, - const vkcv::ImageHandle &colorAttachment) +void BloomAndFlares::execCompositePipe(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle& colorAttachment, + const uint32_t attachmentWidth, const uint32_t attachmentHeight) { p_Core->prepareImageForSampling(cmdStream, m_Blur.getHandle()); p_Core->prepareImageForSampling(cmdStream, m_LensFeatures.getHandle()); @@ -279,8 +279,8 @@ void BloomAndFlares::execCompositePipe(const vkcv::CommandStreamHandle &cmdStrea compositeWrites.storageImageWrites = {vkcv::StorageImageDescriptorWrite(3, colorAttachment)}; p_Core->writeDescriptorSet(m_CompositeDescSet, compositeWrites); - float dispatchCountX = static_cast<float>(m_Width) / 8.0f; - float dispatchCountY = static_cast<float>(m_Height) / 8.0f; + float dispatchCountX = static_cast<float>(attachmentWidth) / 8.0f; + float dispatchCountY = static_cast<float>(attachmentHeight) / 8.0f; uint32_t compositeDispatchCount[3] = { static_cast<uint32_t>(glm::ceil(dispatchCountX)), @@ -297,19 +297,19 @@ void BloomAndFlares::execCompositePipe(const vkcv::CommandStreamHandle &cmdStrea vkcv::PushConstantData(nullptr, 0)); } -void BloomAndFlares::execWholePipeline(const vkcv::CommandStreamHandle &cmdStream, - const vkcv::ImageHandle &colorAttachment) +void BloomAndFlares::execWholePipeline(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment, + const uint32_t attachmentWidth, const uint32_t attachmentHeight) { execDownsamplePipe(cmdStream, colorAttachment); execUpsamplePipe(cmdStream); execLensFeaturePipe(cmdStream); - execCompositePipe(cmdStream, colorAttachment); + execCompositePipe(cmdStream, colorAttachment, attachmentWidth, attachmentHeight); } void BloomAndFlares::updateImageDimensions(uint32_t width, uint32_t height) { - m_Width = width; - m_Height = height; + m_Width = width / 2; + m_Height = height / 2; p_Core->getContext().getDevice().waitIdle(); m_Blur = p_Core->createImage(m_ColorBufferFormat, m_Width, m_Height, 1, true, true, false); diff --git a/projects/voxelization/src/BloomAndFlares.hpp b/projects/voxelization/src/BloomAndFlares.hpp index 71ec21ebfd3dbca6cbb751772a97b7e492157676..7f0c523696f8f37bf2b70eabbfae10afe36077cb 100644 --- a/projects/voxelization/src/BloomAndFlares.hpp +++ b/projects/voxelization/src/BloomAndFlares.hpp @@ -9,7 +9,8 @@ public: uint32_t width, uint32_t height); - void execWholePipeline(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment); + void execWholePipeline(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment, + const uint32_t attachmentWidth, const uint32_t attachmentHeight); void updateImageDimensions(uint32_t width, uint32_t height); @@ -27,10 +28,10 @@ private: vkcv::PipelineHandle m_DownsamplePipe; std::vector<vkcv::DescriptorSetHandle> m_DownsampleDescSets; // per mip desc set + std::vector<vkcv::DescriptorSetHandle> m_UpsampleLensFlareDescSets; // per mip desc set vkcv::PipelineHandle m_UpsamplePipe; std::vector<vkcv::DescriptorSetHandle> m_UpsampleDescSets; // per mip desc set - std::vector<vkcv::DescriptorSetHandle> m_UpsampleLensFlareDescSets; // per mip desc set vkcv::PipelineHandle m_LensFlarePipe; vkcv::DescriptorSetHandle m_LensFlareDescSet; @@ -41,7 +42,8 @@ private: void execDownsamplePipe(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment); void execUpsamplePipe(const vkcv::CommandStreamHandle &cmdStream); void execLensFeaturePipe(const vkcv::CommandStreamHandle &cmdStream); - void execCompositePipe(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment); + void execCompositePipe(const vkcv::CommandStreamHandle &cmdStream, const vkcv::ImageHandle &colorAttachment, + const uint32_t attachmentWidth, const uint32_t attachmentHeight); }; diff --git a/projects/voxelization/src/main.cpp b/projects/voxelization/src/main.cpp index 9ba4b8b78ba0d982f9c560e27a83326959a24320..bafcc45c054c5ebc8fe3afd91eef85c6a9f41f08 100644 --- a/projects/voxelization/src/main.cpp +++ b/projects/voxelization/src/main.cpp @@ -654,7 +654,7 @@ int main(int argc, const char** argv) { } } - bloomFlares.execWholePipeline(cmdStream, resolvedColorBuffer); + bloomFlares.execWholePipeline(cmdStream, resolvedColorBuffer, windowWidth, windowHeight); core.prepareImageForStorage(cmdStream, swapchainInput); core.prepareImageForSampling(cmdStream, resolvedColorBuffer);