Vulkan texture rendering on multiple meshes

后端 未结 2 1732
灰色年华
灰色年华 2020-12-15 10:51

I am in the middle of rendering different textures on multiple meshes of a model, but I do not have much clues about the procedures. Someone suggested for each mesh, create

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 11:36

    The person that suggested the above code fragment was me I guess ;)

    This is only one way of doing it. You don't necessarily have to create one descriptor set per mesh or per texture. If your mesh e.g. uses 4 different textures, you could bind all of them at once to different binding points and select them in the shader.

    And if you a take a look at NVIDIA's chopper sample, they do it pretty much the same way only with some more abstraction.

    The example also sets up descriptor sets for the textures used :

    VkDescriptorSet *textureDescriptors = m_renderer->getTextureDescriptorSets();
    

    binds them a few lines later :

    VkDescriptorSet sets[3] = { sceneDescriptor, textureDescriptors[0], m_transform_descriptor_set };
    vkCmdBindDescriptorSets(m_draw_command[inCommandIndex], VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, 3, sets, 0, NULL);
    

    and then renders the mesh with the bound descriptor sets :

    vkCmdDrawIndexedIndirect(m_draw_command[inCommandIndex], sceneIndirectBuffer, 0, inCount, sizeof(VkDrawIndexedIndirectCommand));
    vkCmdDraw(m_draw_command[inCommandIndex], 1, 1, 0, 0);
    

    If you take a look at initDescriptorSets you can see that they also create separate descriptor sets for the cubemap, the terrain, etc.

    The LunarG examples should work similar, though if I'm not mistaken they never use more than one texture?

提交回复
热议问题