Hi Robert,
I'm trying to convert my existing code to use vsg::Lights and StateComposer. I think I understand most of it, but I'm confused about the lights. As an example, I've modified the vsgstatecomposer example (see attached) in an attempt to use a modifiable directionalLight.
Firstly, I added the light:
auto directionalLight = vsg::DirectionalLight::create();
directionalLight->name = "Sun Directional";
directionalLight->color.set(1.0, 1.0, 1.0);
directionalLight->intensity = 0.15;
directionalLight->direction.set(-0.58, -0.58, -0.58);
scenegraph->addChild(directionalLight);
Then I added a define:
auto& defines = graphicsPipelineConfig->shaderHints->defines;
defines.push_back("VSG_VIEW_LIGHT_DATA");
It already uses createPhongShaderSet, so the shader should be OK.
This results in the following errors after running ./vsgstatecomposer --debug
UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotBound(ERROR / SPEC): msgNum: -840888189 - Validation Error: [ UNASSIGNED-CoreValidation-DrawState-DescriptorSetNotBound ] Object 0: handle = 0x55555719fbe0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0xcde11083 | vkCmdDrawIndexed(): VkPipeline 0xe7713700000000ae[] uses set #1 but that set is not bound.
Objects: 1
[0] 0x55555719fbe0, type: 6, name: NULL
VUID-vkCmdDrawIndexed-None-02697(ERROR / SPEC): msgNum: -1735852301 - Validation Error: [ VUID-vkCmdDrawIndexed-None-02697 ] Object 0: handle = 0xe7713700000000ae, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0xed367200000000ab, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; Object 2: handle = 0xed367200000000ab, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x9888fef3 | vkCmdDrawIndexed(): VkPipeline 0xe7713700000000ae[] defined with VkPipelineLayout 0xed367200000000ab[] is not compatible for maximum set statically used 1 with bound descriptor sets, last bound with VkPipelineLayout 0xed367200000000ab[] The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (
https://vulkan.lunarg.com/doc/view/1.2.189.0/linux/1.2-extensions/vkspec.html#VUID-vkCmdDrawIndexed-None-02697)
Most errors in the modified vsgstatecomposer and my own application refer to the shader using light data in slot 1 that isn't in the layout. The lighting data uses slot 1, whereas everything else uses slot 0. Am I missing something in the layout? Or, completely off track?
Thanks for your help.
Regards,
Roland