mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Fix lamp posts rendering as glass by using texture name for window detection
Instead of relying on material flag 0x40 (F_CLAMP_S, not F_WINDOW) to identify glass materials, detect windows by checking for "window" in the texture path. This correctly applies glass to window textures while leaving lamp posts and other geometry opaque.
This commit is contained in:
parent
a7cf0d0c4e
commit
4511de8d38
2 changed files with 17 additions and 2 deletions
|
|
@ -445,6 +445,7 @@ private:
|
||||||
|
|
||||||
// Texture handles for this model (indexed by texture path order)
|
// Texture handles for this model (indexed by texture path order)
|
||||||
std::vector<VkTexture*> textures; // non-owning, from cache
|
std::vector<VkTexture*> textures; // non-owning, from cache
|
||||||
|
std::vector<std::string> textureNames; // lowercase texture paths (parallel to textures)
|
||||||
|
|
||||||
// Material texture indices (materialId -> texture index)
|
// Material texture indices (materialId -> texture index)
|
||||||
std::vector<uint32_t> materialTextureIndices;
|
std::vector<uint32_t> materialTextureIndices;
|
||||||
|
|
|
||||||
|
|
@ -427,6 +427,11 @@ bool WMORenderer::loadModel(const pipeline::WMOModel& model, uint32_t id) {
|
||||||
core::Logger::getInstance().debug(" Loading texture ", i, ": ", texPath);
|
core::Logger::getInstance().debug(" Loading texture ", i, ": ", texPath);
|
||||||
VkTexture* tex = loadTexture(texPath);
|
VkTexture* tex = loadTexture(texPath);
|
||||||
modelData.textures.push_back(tex);
|
modelData.textures.push_back(tex);
|
||||||
|
// Store lowercase texture name for material detection
|
||||||
|
std::string lowerPath = texPath;
|
||||||
|
std::transform(lowerPath.begin(), lowerPath.end(), lowerPath.begin(),
|
||||||
|
[](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||||
|
modelData.textureNames.push_back(lowerPath);
|
||||||
}
|
}
|
||||||
core::Logger::getInstance().debug(" Loaded ", modelData.textures.size(), " textures for WMO");
|
core::Logger::getInstance().debug(" Loaded ", modelData.textures.size(), " textures for WMO");
|
||||||
}
|
}
|
||||||
|
|
@ -588,8 +593,17 @@ bool WMORenderer::loadModel(const pipeline::WMOModel& model, uint32_t id) {
|
||||||
unlit = (matFlags & 0x01) != 0;
|
unlit = (matFlags & 0x01) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// F_WINDOW = 0x40, renders as transparent glass.
|
// Detect window/glass materials by texture name.
|
||||||
bool isWindow = (matFlags & 0x40) != 0;
|
// Flag 0x10 (F_SIDN) marks night-glow materials (windows AND lamps),
|
||||||
|
// so we additionally check for "window" in the texture path to
|
||||||
|
// distinguish actual glass from lamp post geometry.
|
||||||
|
bool isWindow = false;
|
||||||
|
if (batch.materialId < modelData.materialTextureIndices.size()) {
|
||||||
|
uint32_t ti = modelData.materialTextureIndices[batch.materialId];
|
||||||
|
if (ti < modelData.textureNames.size()) {
|
||||||
|
isWindow = (modelData.textureNames[ti].find("window") != std::string::npos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BatchKey key{ reinterpret_cast<uintptr_t>(tex), alphaTest, unlit, isWindow };
|
BatchKey key{ reinterpret_cast<uintptr_t>(tex), alphaTest, unlit, isWindow };
|
||||||
auto& mb = batchMap[key];
|
auto& mb = batchMap[key];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue