bug fix : crush when loading model with no material
parent
e1a8de6147
commit
5aeb1c1efc
|
@ -454,21 +454,37 @@ void VulkanglTFModel::drawNode(VkCommandBuffer commandBuffer, VkPipelineLayout p
|
||||||
if (primitive.indexCount > 0) {
|
if (primitive.indexCount > 0) {
|
||||||
// Get the texture index for this primitive
|
// Get the texture index for this primitive
|
||||||
if (textures.size() > 0)
|
if (textures.size() > 0)
|
||||||
|
{
|
||||||
|
//binding base color texture
|
||||||
|
if (materials[primitive.materialIndex].baseColorTextureIndex < textures.size())
|
||||||
{
|
{
|
||||||
VulkanglTFModel::Texture texture = textures[materials[primitive.materialIndex].baseColorTextureIndex];
|
VulkanglTFModel::Texture texture = textures[materials[primitive.materialIndex].baseColorTextureIndex];
|
||||||
auto normalMap = textures[materials[primitive.materialIndex].normalMapTextureIndex];
|
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &images[texture.imageIndex].descriptorSet, 0, nullptr);
|
||||||
auto roughMetalMap = textures[materials[primitive.materialIndex].matalicRoughTextureIndex];
|
|
||||||
|
|
||||||
if (materials[primitive.materialIndex].emissiveTextureIndex >= 0)
|
}
|
||||||
|
|
||||||
|
//normal map binding
|
||||||
|
if (materials[primitive.materialIndex].normalMapTextureIndex < textures.size())
|
||||||
|
{
|
||||||
|
auto normalMap = textures[materials[primitive.materialIndex].normalMapTextureIndex];
|
||||||
|
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 2, 1, &images[normalMap.imageIndex].descriptorSet, 0, nullptr);
|
||||||
|
}
|
||||||
|
//rough map binding
|
||||||
|
if (materials[primitive.materialIndex].matalicRoughTextureIndex < textures.size())
|
||||||
|
{
|
||||||
|
auto roughMetalMap = textures[materials[primitive.materialIndex].matalicRoughTextureIndex];
|
||||||
|
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 3, 1, &images[roughMetalMap.imageIndex].descriptorSet, 0, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//emissive texture binding
|
||||||
|
if (materials[primitive.materialIndex].emissiveTextureIndex >= 0 && materials[primitive.materialIndex].emissiveTextureIndex < textures.size())
|
||||||
{
|
{
|
||||||
auto emissiveMap = textures[materials[primitive.materialIndex].emissiveTextureIndex];
|
auto emissiveMap = textures[materials[primitive.materialIndex].emissiveTextureIndex];
|
||||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 4, 1, &images[emissiveMap.imageIndex].descriptorSet, 0, nullptr);
|
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 4, 1, &images[emissiveMap.imageIndex].descriptorSet, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind the descriptor for the current primitive's texture
|
// Bind the descriptor for the current primitive's texture
|
||||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &images[texture.imageIndex].descriptorSet, 0, nullptr);
|
|
||||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 2, 1, &images[normalMap.imageIndex].descriptorSet, 0, nullptr);
|
|
||||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 3, 1, &images[roughMetalMap.imageIndex].descriptorSet, 0, nullptr);
|
|
||||||
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 5, 1, &materials[primitive.materialIndex].materialData.descriptorSet, 0, nullptr);
|
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 5, 1, &materials[primitive.materialIndex].materialData.descriptorSet, 0, nullptr);
|
||||||
}
|
}
|
||||||
vkCmdDrawIndexed(commandBuffer, primitive.indexCount, 1, primitive.firstIndex, 0, 0);
|
vkCmdDrawIndexed(commandBuffer, primitive.indexCount, 1, primitive.firstIndex, 0, 0);
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <ktx.h>
|
||||||
|
#include <ktxvulkan.h>
|
||||||
|
|
||||||
#define GLM_FORCE_RADIANS
|
#define GLM_FORCE_RADIANS
|
||||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
|
@ -1674,7 +1674,16 @@ PlumageRender::PlumageRender():
|
||||||
strFilePath = guiFunc.openFileFolderDialog();
|
strFilePath = guiFunc.openFileFolderDialog();
|
||||||
filePath.modelVertShaderPath = strFilePath;
|
filePath.modelVertShaderPath = strFilePath;
|
||||||
loadAssets();
|
loadAssets();
|
||||||
|
updateUniformBuffers();
|
||||||
|
}
|
||||||
|
if (overlay->button("select fragment Shader"))
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string strFilePath;
|
||||||
|
strFilePath = guiFunc.openFileFolderDialog();
|
||||||
|
filePath.modelFragShaderPath = strFilePath;
|
||||||
|
loadAssets();
|
||||||
|
updateUniformBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue