From 0b687311be4fc1babe148df8b7510ee36abd3878 Mon Sep 17 00:00:00 2001 From: Shadow Date: Mon, 26 Sep 2022 17:32:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E9=94=99,=20?= =?UTF-8?q?=E5=88=A0=E6=8E=89=20VK=5FDYNAMIC=5FSTATE=5FDEPTH=5FBIAS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Vulkan/sample/shadowmapping/shadowmapping.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Vulkan/Vulkan_Sample/Vulkan/sample/shadowmapping/shadowmapping.cpp b/Vulkan/Vulkan_Sample/Vulkan/sample/shadowmapping/shadowmapping.cpp index cd63e5a..c5e62af 100644 --- a/Vulkan/Vulkan_Sample/Vulkan/sample/shadowmapping/shadowmapping.cpp +++ b/Vulkan/Vulkan_Sample/Vulkan/sample/shadowmapping/shadowmapping.cpp @@ -46,6 +46,12 @@ void ShadowMapping::clear() vkDestroyRenderPass(m_device, m_offscreenRenderPass, nullptr); vkDestroyFramebuffer(m_device, m_offscreenFrameBuffer, nullptr); + + vkDestroyImageView(m_device, m_offscreenColorImageView, nullptr); + vkDestroyImage(m_device, m_offscreenColorImage, nullptr); + vkFreeMemory(m_device, m_offscreenColorMemory, nullptr); + vkDestroySampler(m_device, m_offscreenColorSampler, nullptr); + vkDestroyImageView(m_device, m_offscreenDepthImageView, nullptr); vkDestroyImage(m_device, m_offscreenDepthImage, nullptr); vkFreeMemory(m_device, m_offscreenDepthMemory, nullptr); @@ -171,7 +177,7 @@ void ShadowMapping::createGraphicsPipeline() std::vector dynamicStates = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, - VK_DYNAMIC_STATE_DEPTH_BIAS +// VK_DYNAMIC_STATE_DEPTH_BIAS }; VkPipelineDynamicStateCreateInfo dynamic = Tools::getPipelineDynamicStateCreateInfo(dynamicStates); @@ -194,6 +200,11 @@ void ShadowMapping::createGraphicsPipeline() createInfo.pStages = shaderStages.data(); // createInfo.pVertexInputState = vkglTF::Vertex::getPipelineVertexInputState({vkglTF::VertexComponent::Position, vkglTF::VertexComponent::Normal, vkglTF::VertexComponent::Color}); + +// vkCmdSetDepthBias(commandBuffer, 1.25f, 0.0f, 1.75f); + rasterization.depthBiasConstantFactor = 1.25f; + rasterization.depthBiasClamp = 0.0f; + rasterization.depthBiasSlopeFactor = 1.75; createInfo.pVertexInputState = m_sceneLoader.getPipelineVertexInputState(); createInfo.pInputAssemblyState = &inputAssembly; @@ -448,7 +459,7 @@ void ShadowMapping::createOtherRenderPass(const VkCommandBuffer& commandBuffer) vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_shadowPipelineLayout, 0, 1, &m_shadowDescriptorSet, 0, nullptr); - vkCmdSetDepthBias(commandBuffer, 1.25f, 0.0f, 1.75f); +// vkCmdSetDepthBias(commandBuffer, 1.25f, 0.0f, 1.75f); vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, m_shadowPipeline); m_sceneLoader.bindBuffers(commandBuffer); m_sceneLoader.draw(commandBuffer);