From 4c77f7ee7b138adc220f4acc06fade6b690a62e4 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 5 Feb 2026 23:51:50 -0800 Subject: [PATCH] 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. --- src/rendering/character_renderer.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/rendering/character_renderer.cpp b/src/rendering/character_renderer.cpp index 122bf9be..8b9fe937 100644 --- a/src/rendering/character_renderer.cpp +++ b/src/rendering/character_renderer.cpp @@ -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);