11/*
22 Vulkan Example - Cascaded shadow mapping for directional light sources
3- Copyright by Sascha Willems - www.saschawillems.de
3+ Copyright (c) 2016-2025 by Sascha Willems - www.saschawillems.de
44 This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
5- */
65
7- /*
86 This example implements projective cascaded shadow mapping. This technique splits up the camera frustum into
97 multiple frustums with each getting its own full-res shadow map, implemented as a layered depth-only image.
108 The shader then selects the proper shadow map layer depending on what split of the frustum the depth value
@@ -175,7 +173,7 @@ class VulkanExample : public VulkanExampleBase
175173 vkCmdBindDescriptorSets (commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0 , 1 , &descriptorSet, 0 , nullptr );
176174
177175 // Floor
178- vkCmdPushConstants (commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0 , sizeof (PushConstBlock), &pushConstBlock);
176+ vkCmdPushConstants (commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT , 0 , sizeof (PushConstBlock), &pushConstBlock);
179177 models.terrain .draw (commandBuffer, vkglTF::RenderFlags::BindImages, pipelineLayout);
180178
181179 // Trees
@@ -189,7 +187,7 @@ class VulkanExample : public VulkanExampleBase
189187
190188 for (auto & position : positions) {
191189 pushConstBlock.position = glm::vec4 (position, 0 .0f );
192- vkCmdPushConstants (commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0 , sizeof (PushConstBlock), &pushConstBlock);
190+ vkCmdPushConstants (commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT , 0 , sizeof (PushConstBlock), &pushConstBlock);
193191 // This will also bind the texture images to set 1
194192 models.tree .draw (commandBuffer, vkglTF::RenderFlags::BindImages, pipelineLayout);
195193 }
@@ -413,7 +411,7 @@ class VulkanExample : public VulkanExampleBase
413411 vkCmdBindPipeline (drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.debugShadowMap );
414412 PushConstBlock pushConstBlock = {};
415413 pushConstBlock.cascadeIndex = displayDepthMapCascadeIndex;
416- vkCmdPushConstants (drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0 , sizeof (PushConstBlock), &pushConstBlock);
414+ vkCmdPushConstants (drawCmdBuffers[i], pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT , 0 , sizeof (PushConstBlock), &pushConstBlock);
417415 vkCmdDraw (drawCmdBuffers[i], 3 , 1 , 0 , 0 );
418416 }
419417
@@ -490,7 +488,7 @@ class VulkanExample : public VulkanExampleBase
490488
491489 // Shared pipeline layout (scene and depth map debug display)
492490 {
493- VkPushConstantRange pushConstantRange = vks::initializers::pushConstantRange (VK_SHADER_STAGE_VERTEX_BIT, sizeof (PushConstBlock), 0 );
491+ VkPushConstantRange pushConstantRange = vks::initializers::pushConstantRange (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT , sizeof (PushConstBlock), 0 );
494492 std::array<VkDescriptorSetLayout, 2 > setLayouts = { descriptorSetLayout, vkglTF::descriptorSetLayoutImage };
495493 VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = vks::initializers::pipelineLayoutCreateInfo (setLayouts.data (), static_cast <uint32_t >(setLayouts.size ()));
496494 pipelineLayoutCreateInfo.pushConstantRangeCount = 1 ;
@@ -500,7 +498,7 @@ class VulkanExample : public VulkanExampleBase
500498
501499 // Depth pass pipeline layout
502500 {
503- VkPushConstantRange pushConstantRange = vks::initializers::pushConstantRange (VK_SHADER_STAGE_VERTEX_BIT, sizeof (PushConstBlock), 0 );
501+ VkPushConstantRange pushConstantRange = vks::initializers::pushConstantRange (VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT , sizeof (PushConstBlock), 0 );
504502 std::array<VkDescriptorSetLayout, 2 > setLayouts = { descriptorSetLayout, vkglTF::descriptorSetLayoutImage };
505503 VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = vks::initializers::pipelineLayoutCreateInfo (setLayouts.data (), static_cast <uint32_t >(setLayouts.size ()));
506504 pipelineLayoutCreateInfo.pushConstantRangeCount = 1 ;
0 commit comments