1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-06-07 05:37:45 +00:00

Load the index texture, instead of falling back to the normal texture

This commit is contained in:
Joshua Goins 2025-06-02 21:48:26 -04:00
parent b8b448ce55
commit 87e4188d9f
3 changed files with 21 additions and 22 deletions

View file

@ -307,29 +307,24 @@ RenderMaterial MDLPart::createMaterial(const physis_Material &material)
qInfo() << "Loading" << t; qInfo() << "Loading" << t;
char type = t[t.length() - 5]; const auto type = t.substr(t.find_last_of('_') + 1, t.find_last_of('.') - t.find_last_of('_') - 1);
auto texture = physis_texture_parse(cache.lookupFile(QLatin1String(material.textures[i]))); auto texture = physis_texture_parse(cache.lookupFile(QLatin1String(material.textures[i])));
if (texture.rgba != nullptr) { if (texture.rgba != nullptr) {
switch (type) { auto gameTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
case 'm': { renderer->device().nameTexture(gameTexture, material.textures[i]);
newMaterial.multiTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
renderer->device().nameTexture(*newMaterial.multiTexture, material.textures[i]); if (type == "m") {
} break; newMaterial.multiTexture = gameTexture;
case 'd': { } else if (type == "d") {
newMaterial.diffuseTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture); newMaterial.diffuseTexture = gameTexture;
renderer->device().nameTexture(*newMaterial.diffuseTexture, material.textures[i]); } else if (type == "n") {
} break; newMaterial.normalTexture = gameTexture;
case 'n': { } else if (type == "s") {
newMaterial.normalTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture); newMaterial.specularTexture = gameTexture;
renderer->device().nameTexture(*newMaterial.normalTexture, material.textures[i]); } else if (type == "id") {
} break; newMaterial.indexTexture = gameTexture;
case 's': { } else {
newMaterial.specularTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture); qWarning() << "Unknown texture type" << type;
renderer->device().nameTexture(*newMaterial.specularTexture, material.textures[i]);
} break;
default:
qDebug() << "unhandled type" << type;
break;
} }
} else { } else {
qInfo() << "Failed to load" << t; qInfo() << "Failed to load" << t;

View file

@ -27,6 +27,7 @@ struct RenderMaterial {
std::optional<Texture> normalTexture; std::optional<Texture> normalTexture;
std::optional<Texture> specularTexture; std::optional<Texture> specularTexture;
std::optional<Texture> multiTexture; std::optional<Texture> multiTexture;
std::optional<Texture> indexTexture;
std::optional<Texture> tableTexture; std::optional<Texture> tableTexture;

View file

@ -1302,9 +1302,12 @@ GameRenderer::createDescriptorFor(const DrawObject *object, const CachedPipeline
info->imageView = m_viewPositionBuffer.imageView; info->imageView = m_viewPositionBuffer.imageView;
} else if (strcmp(name, "g_SamplerDepth") == 0) { } else if (strcmp(name, "g_SamplerDepth") == 0) {
info->imageView = m_depthBuffer.imageView; info->imageView = m_depthBuffer.imageView;
} else if ((strcmp(name, "g_SamplerNormal") == 0 || strcmp(name, "g_SamplerIndex") == 0) && material->normalTexture.has_value()) { } else if (strcmp(name, "g_SamplerNormal") == 0 && material->normalTexture.has_value()) {
Q_ASSERT(material); Q_ASSERT(material);
info->imageView = material->normalTexture->imageView; info->imageView = material->normalTexture->imageView;
} else if (strcmp(name, "g_SamplerIndex") == 0 && material->indexTexture.has_value()) {
Q_ASSERT(material);
info->imageView = material->indexTexture->imageView;
} else if (strcmp(name, "g_SamplerLightDiffuse") == 0) { } else if (strcmp(name, "g_SamplerLightDiffuse") == 0) {
Q_ASSERT(material); Q_ASSERT(material);
info->imageView = m_lightBuffer.imageView; info->imageView = m_lightBuffer.imageView;