godot 4.3.dev5 warning on project loading
yythlj opened this issue · 5 comments
WARNING: Loaded resource as image file, this will not work on export: 'res://storage/maps/terrain_map/ice_map/normal.png'. Instead, import the image file as an Image resource and load it normally as a resource.
at: load_from_file (core/io/image.cpp:2505)
WARNING: Loaded resource as image file, this will not work on export: 'res://storage/maps/terrain_map/ice_map/splat.png'. Instead, import the image file as an Image resource and load it normally as a resource.
at: load_from_file (core/io/image.cpp:2505)
WARNING: Loaded resource as image file, this will not work on export: 'res://storage/maps/terrain_map/ice_map/color.png'. Instead, import the image file as an Image resource and load it normally as a resource.
at: load_from_file (core/io/image.cpp:2505)
WARNING: Loaded resource as image file, this will not work on export: 'res://storage/maps/terrain_map/ice_map/detail.png'. Instead, import the image file as an Image resource and load it normally as a resource.
at: load_from_file (core/io/image.cpp:2505)
WARNING: hterrain_data.gd: Map detail[0] loaded as format 4, expected 2. Will be converted.
at: push_warning (core/variant/variant_utility.cpp:1111)
These warnings have been there forever. Godot is being overly pedantic and prints that everytime some code tries to load an Image
from res://
. This is supposed to help you in game code, but that isn't considering plugins which would legitimally need to do this.
This happens because the plugin needs to allow you to edit terrain data, which requires to load files as an image and not just an imported texture resource.
This only happens in the editor, and is sometimes necessary for loading terrains created in older versions in case formats change.
I don't know how I'm supposed to not have these warnings print in such situation.
Edit: I've opened a PR #443 to fix this.
@Zylann I just tested here, you can remove all the warnings by using ProjectSettings.globalize_path()
on all
image.load and image.load_from_file calls. As suggested by Calinou godotengine/godot#24222 (comment)
Its all working. And I got no more warning messages.
- On Godot 4.2.2.
- Plugin version 1.7.2 (Latest from AssetLibrary)
I'm still getting:
core/variant/variant_utility.cpp:1112 - hterrain_data.gd: Map detail[0] loaded as format 4, expected 2. Will be converted.
core/variant/variant_utility.cpp:1112 - hterrain_data.gd: Map detail[1] loaded as format 4, expected 2. Will be converted.
... on Godot v4.3.stable.official [77dcf97d8].
Just FYI -- it sounds like this isn't a critical problem, but it is kinda annoying to see.
If you keep getting this it just means that for some reason, Godot has imported detail layer image files as RGB8, when they should actually be R8. This is a warning because it means exported project size and VRAM will be wasted.
The causes could be:
- A bug in the plugin? Godot to this day still doesnt offer a clean API to generate texture files with specific desired import settings, so the only way the plugin had for years was to manually write an
.import
file with the right magic numbers in it. But that also means it's possible Godot has changed these numbers around over versions without notice and that the plugin would have to be patched? - You modified the import settings
- Godot has somehow changed the way import settings work for whatever reason
- You had this terrain for a very long time, updated Godot, and now import setting numbers are supposed to be different but since the file is old it didn't get updated and now imports incorrectly?
This could also be fixed by changing import settings manually, but...
I asked devs and unfortunately it appears this importing issue cannot be fixed with the way Godot 4.3 works now.
If you find a combination of import settings on detail.png
that imports it as non-VRAM-compressed R8 or L8 textures, let me know, because for now the plugin pretty much is forced to waste resources, hence the warning.
There are even problems with saving PNG images in the first place. Because for some reason, when you save an R8
image, Godot will save an RGB8 image, making it bigger than it should be. Leading to this comment:
Of course like written I could make the plugin stop relying on Godot's import pipeline entirely and create a custom format, but I don't have frequent enough involvement in this plugin to do yet another huge change like that... and being able to access terrain maps as regular image formats instead of reinventing ways to save and import images is a feature I desired to keep in the plugin.
After some confusing trial and error, I found that there is actually a way to generate a PNG that will import to a suitable format, but that requires changing import settings slightly.
I made some changes in 465e9a5
The issue is two-fold:
- Godot was saving R8 images as an RGB8 PNG, but a single-channel 8-bit format is desired
- Godot was importing the PNG image as RGB8 when R8/L8 is what's desired
Now if you open your terrain it might still print the warning because the file is still in the old format. If you modify detail layers (paint a bit) and save the scene, it should write a new image file, fixing the first issue. Next time you reopen the editor and open the terrain, the warning might no longer print. But if at this point it still prints, make sure the import settings of detail.png
(and subsequently numbered files) are like so: