QodotPlugin / qodot-plugin

(LEGACY) Quake .map support for Godot 3.x
MIT License
960 stars 70 forks source link

WAD textures with name containing upper case characters are not applied to mesh materials #157

Open puzzud opened 1 year ago

puzzud commented 1 year ago

Given

When

Then

It seems to be a convention that WAD texture names are lowercase but I suspect it is not a rule. Both Trenchbroom & TexMex support such. I encountered this problem when trying to use Valve's cs_dust.wad, which contains texture names like "SandRoad".

I have a fix for this problem by modifying qodot_texture_loader.gd::load_texture to not apply "to_lower" to the texture_name parameter before searching for this name as a key in texture_wad_resources' textures. I think this fix is sound because observing the dictionaries of loaded WADs in Godot show that the texture names are still in their original form (not forced into their lowercase form).

I don't know if there is some other use case which requires this string manipulation. Perhaps an earlier developer was catering to a case where a MAP file contained a texture name with mixed case whereas the WAD file did not and it was expected that they should match up. At any rate, that's not a valid normalization of naming because as I mentioned before, Qodot in the least is allowing texture names to be mixed case when loading a WAD. It's also worth mentioning that TexMex allows another texture in the same WAD to have the same name in a different case. However, I didn't text if Quake had a problem with such a thing--I don't know what client, editor, or compiler that may have created this precedent. Skimming the WAD2 specification, I didn't see anything that indicated such.

But if this behavior is to be retained, first a check for texture_name in texture_wad.textures can be performed prior to texture_name_lower.