Additional Texture Formats/Extensions Support#25
Conversation
…ts when building map/meshes. # - Users can add or remove texture formats using the exposed 'Texture Import Extensions' PackedStringArray variable in the editor. When loading, extensions are checked in ascending order.
…g them multiple times. # - Map textures are now attempted to be loaded during the start of 'load_map'. These textures are then cached in a dictionary so that they can be retrieved later.
…e textures cannot be loaded. # - Added additional error messages regarding this.
- Moved 'filter_nearest' functions to match the position like in the property inspector.
|
Thanks for the PR! 🎉 I like the idea of using Godot's supported texture list for this! We would need to check if all those texture formats are actually supported by TrenchBroom, too. I guess depending on that we can decide if we want to hardcode a specific supported set, or just use whatever Godot tells us it can use. |
|
Alrighty, I did some research,
FreeImage Library Supported Formats So theoretically, that would mean that all supported texture formats/extensions overlap besides As for the PR, I would then indeed just use the Godot's supported extension list and then remove all the bits with the exposed property. On a sidenote, if we want to support more texture formats/extensions in the workflow, the 'textures' field in GameConfig.cfg that is provided with TBLoader, would have to be updated as well to accommodate this. |
|
Thanks for taking the time to look into this! I think I would have a preference for hardcoding the list to take into account the (unlikely?) scenario that Godot adds another format that is unsupported by Trenchbroom, or one that could be something other than an image (like And yes indeed, the default |
|
Yeah, no problem! ^^ I have removed the 'Texture Import Extensions' property entirely and replaced it with a hardcoded list instead like we talked about. Let me know if there is anything else that could be improved or changed. |
codecat
left a comment
There was a problem hiding this comment.
I just have a couple little style nitpicks, otherwise it looks great! 👍
| const LMTextureData* tex; | ||
| String tex_path; |
There was a problem hiding this comment.
These 2 variables could be scoped inside of the for loop below, I think.
There was a problem hiding this comment.
Yeah, that would work fine, but I thought since we are looping a lot for every texture and extension, it would be better to overwrite them instead of allocating/deallocating them constantly. However, if you prefer otherwise, that's cool too as it is pretty minor.
There was a problem hiding this comment.
Agreed! Probably not super important for the pointer though, but for the string it does make sense.
| String tex_path; | ||
|
|
||
| for (int tex_i = 0; tex_i < m_map->texture_count; tex_i++) { | ||
| bool has_loaded_texture(false); |
There was a problem hiding this comment.
This might look nicer? 😊
bool has_loaded_texture = false;There was a problem hiding this comment.
Oops! That slipped through, will correct that.
| auto res_texture = texture_from_name(name); | ||
|
|
||
| auto res_texture = texture_from_name(tex.name); | ||
…instead of customizable. # - Reverted changes in tb_loader.h/.cpp, removing the "Texture Import Extensions" property. - Added hardcoded texture extensions list that both godot and trenchbroom support.
…ormats/extensions. # - Updating the GameConfig as tbloader now supports more texture formats.
dd881f0 to
0fb486b
Compare
|
Alrighty, I have made the adjustments and have amended the commit, so that should be it. 🎉 |
|
Looks good to me! Thank you! 🎉 |

Heya!
I was messing around with the tool, but noticed that textures other then '.png' were not supported. From what I can gather from the code, this is just because the texture file format when loading is hard-coded to '.png'. Changing the extension to '.tga', for instance, worked perfectly fine. So because of this, I have added support for other file extensions.
I decided to let the user control the array of strings/extensions, so that they order, remove, or add the ones they needed for their map. (Not sure if this really needed though and I am not convinced that is the greatest UI/UX experience, however, it works fine.)
Alternatively, we could:
Anyhow, this is how you can use it in the editor.
additional-texture-extensions-support.mp4
I have also made a change regarding "texture_from_name" so that we don't have to; check for file extensions, check if it exists, and then call the load function for every texture. (This would be done twice for setting the texture size and then later for the mesh building.) It now fetches the resource from "m_loaded_map_textures" dictionary, which gets filled once at the start of map load.
Of course, feel free to suggest anything and let me know what you think. :)