godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.23k stars 21.04k forks source link

[4.4.dev 2] ufbx importer does not find Synty textures #97600

Open ChildLearningClub opened 2 weeks ago

ChildLearningClub commented 2 weeks ago

Tested versions

4.4.dev 2

System information

Windows 11 Vulkan Forward +

Issue description

I saw a similar report/post somewhere, but could not find it so I apologize if this is repeated somewhere.

The Synty assets that are released as their "Sources Files" contain .FBX files that reference links to Dropbox or the .psd image textures rather then the same file name with the .png extension that is actually contained in the files.

  Resource file not found: res:// (expected type: Texture2D)
  Can't open file from path 'res://Dropbox/SyntyStudios/PolygonHorrorMansion/_Working/_Textures/PolygonHorror_Texture_01.psd'.
  modules/fbx/fbx_document.cpp:1088 - FBX: Image index '1' couldn't be loaded from path: res://Dropbox/SyntyStudios/PolygonHorrorMansion/_Working/_Textures/PolygonHorror_Texture_01.psd because there was no data to load. Skipping it.
  Resource file not found: res:// (expected type: Texture2D)
  Can't open file from path 'res://_Textures/PolygonHorror_Texture_01.psd'.
  modules/fbx/fbx_document.cpp:1088 - FBX: Image index '0' couldn't be loaded from path: res://_Textures/PolygonHorror_Texture_01.psd because there was no data to load. Skipping it.
  Resource file not found: res:// (expected type: Texture2D)
  Can't open file from path 'res://PolygonShops/_Working/_Textures/PolygonShops_Walls_Texture_01.psd'.
  modules/fbx/fbx_document.cpp:1088 - FBX: Image index '1' couldn't be loaded from path: res://PolygonShops/_Working/_Textures/PolygonShops_Walls_Texture_01.psd because there was no data to load. Skipping it.
  Resource file not found: res:// (expected type: Texture2D)
  Can't open file from path 'res://_Textures/Glass.psd'.

the ufbx importer does not appear, as a fallback, to look through the filesystem and find the matching filename with other extension types that can be used in place of the ones referenced that it is unable to find.

Additionally there appears to be no way to disable the ufbx importer so that the FBXState and FBXDocument classes can be used to override and "handle" the .fbx files.

Steps to reproduce

I was importing .fbx files from their PolygonHorrorMansion Pack sourcefiles.

Minimal reproduction project (MRP)

NA

AThousandShips commented 2 weeks ago

Without an MRP this isn't going to be easy to test, please upload a minimal project that replicates this problem

ChildLearningClub commented 2 weeks ago

MRP Thank you.

fire commented 2 weeks ago

Due to various reasons Godot Engine does not have a psd importer.

PolygonHorror_Texture_01.psd

I personally think we should but there's not clear agreement on that so it's in limbo.

https://github.com/godotengine/godot/pull/73417 (Initial .psd support implementation)

fire commented 2 weeks ago

The fbx importer falls back to the engine list of texture importers so maybe if there's a psd importer at some point even as gdextension it'll work.

ChildLearningClub commented 2 weeks ago

Hi @fire thank you for taking a look. Oddly the texture that Synty references, the PolygonHorror_Texture_01.psd file is not even included in the source files. What is included is the PolygonHorror_Texture_01.png file, which is the one that I want anyway, so there is no need to import the .psd. I’m just trying to figure out a way to “handle” the .fbx import before the ufbx does or for the ufbx importer to effectively grab the filename without the extension and find that within the file system.

fire commented 2 weeks ago

I forgot the details but we store the original image path internally

ChildLearningClub commented 2 weeks ago

At first I was using the post import script to try and get the files myself, but that of course runs after all the warning and error messages get printed from the ufbx importer that can’t find the referenced textures, so then I attempted to create a new FBXDocument and FBXState And run those before the ufbx imported did so that I could somehow grab the path reference that the errors were spitting out and convert them to the actual.png file that was in the project. Is there some way to accomplish this?

bqqbarbhg commented 2 weeks ago

Back when we were doing the texture resolving code, I think I was suggesting doing automatic search by extension as well, as the code is already searching multiple folders for the right texture, so I thought attempting "file.png", "file.jpg", "file.jpeg", ... etc. to find the texture wouldn't be that bad in comparison.

I think the consensus back then was that this behavior would be too magical in comparison to searching the files from other paths, but it might be worth it to reconsider the issue.

ChildLearningClub commented 1 week ago

Could something like the contains() function be used?

If performance is a consideration a recursive search can be started at the folder that the mesh is contained in and work it's way up to the res:// root directory No? I was not even considering including the extension but rather just contains("PolygonHorror_Texture_01")?

If the concern is mistakenly applying an incorrect texture with the same filename (which I do think would be a rare case, and also considering this is a fallback if it can not find it using the current method) a warning can be emitted. With this we would get a texture applied, that is more then likely the correct one and a warning letting us know. Currently however the ufbx imported emits what I think was 2 errors and a warning and no texture applied.

  Resource file not found: res:// (expected type: Texture2D)
  Can't open file from path 'res://Dropbox/SyntyStudios/PolygonHorrorMansion/_Working/_Textures/PolygonHorror_Texture_01.psd'.
  modules/fbx/fbx_document.cpp:1088 - FBX: Image index '1' couldn't be loaded from path: res://Dropbox/SyntyStudios/PolygonHorrorMansion/_Working/_Textures/PolygonHorror_Texture_01.psd because there was no data to load. Skipping it.

I'm not familiar with the creation and export process that most studios use, but I would image there are a lot of Godot users, like myself, that have quite a few Synty assets piled up from the HumbleBundles :) I also contacted Synty and asked that they would consider using gltf, which they responded that they are looking into using it for this exact reason and that the goal would be to embed the materials into the models.

Edit: Sorry I think the contains() function would probably not be the best, as some texture names could be quite short and non-descriptive leading to a lot of matches. So maybe another method/approach?

fire commented 1 week ago

If the concern is mistakenly applying an incorrect texture with the same filename (which I do think would be a rare case, and also considering this is a fallback if it can not find it using the current method) a warning can be emitted. With this we would get a texture applied

I think this was my concern, but I prefer solving real problems like yours rather than hypotheticals.