1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-06-06 13:17:46 +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;
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])));
if (texture.rgba != nullptr) {
switch (type) {
case 'm': {
newMaterial.multiTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
renderer->device().nameTexture(*newMaterial.multiTexture, material.textures[i]);
} break;
case 'd': {
newMaterial.diffuseTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
renderer->device().nameTexture(*newMaterial.diffuseTexture, material.textures[i]);
} break;
case 'n': {
newMaterial.normalTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
renderer->device().nameTexture(*newMaterial.normalTexture, material.textures[i]);
} break;
case 's': {
newMaterial.specularTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
renderer->device().nameTexture(*newMaterial.specularTexture, material.textures[i]);
} break;
default:
qDebug() << "unhandled type" << type;
break;
auto gameTexture = renderer->addGameTexture(VK_FORMAT_R8G8B8A8_UNORM, texture);
renderer->device().nameTexture(gameTexture, material.textures[i]);
if (type == "m") {
newMaterial.multiTexture = gameTexture;
} else if (type == "d") {
newMaterial.diffuseTexture = gameTexture;
} else if (type == "n") {
newMaterial.normalTexture = gameTexture;
} else if (type == "s") {
newMaterial.specularTexture = gameTexture;
} else if (type == "id") {
newMaterial.indexTexture = gameTexture;
} else {
qWarning() << "Unknown texture type" << type;
}
} else {
qInfo() << "Failed to load" << t;

View file

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

View file

@ -1302,9 +1302,12 @@ GameRenderer::createDescriptorFor(const DrawObject *object, const CachedPipeline
info->imageView = m_viewPositionBuffer.imageView;
} else if (strcmp(name, "g_SamplerDepth") == 0) {
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);
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) {
Q_ASSERT(material);
info->imageView = m_lightBuffer.imageView;