Add texture fallback for body parts with white texture

For body part batches (group 0) that resolve to white/fallback texture,
fall back to the first valid texture in the model. This handles humanoid
NPCs where body parts use different texture slots that may not be set.
This commit is contained in:
Kelsi 2026-02-05 23:51:50 -08:00
parent 9de3f2d327
commit 4c77f7ee7b

View file

@ -1240,6 +1240,22 @@ void CharacterRenderer::render(const Camera& camera, const glm::mat4& view, cons
}
}
// For body parts with white/fallback texture, use first valid texture
// This handles humanoid models where some body parts use different texture slots
// that may not be set (e.g., baked NPC textures only set slot 0)
if (texId == whiteTexture) {
uint16_t group = batch.submeshId / 100;
if (group == 0) {
// Find first non-white texture in the model
for (GLuint tid : gpuModel.textureIds) {
if (tid != whiteTexture && tid != 0) {
texId = tid;
break;
}
}
}
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texId);