-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResourceSaver does not correctly save ImageTexture #18801
Comments
Also it is not possible to do this with the inspector. Tested on master (224d537). |
Here's the console output when running the code:
|
I've done some debugging which revealed the root cause of the issue. godot/scene/resources/scene_format_text.cpp Line 1460 in a0ea57b
which calls: godot/scene/resources/scene_format_text.cpp Line 1482 in a0ea57b
which calls for both the ImageTexture (= Image::get_data() ) and the referenced Image object:godot/scene/resources/scene_format_text.cpp Line 1417 in a0ea57b
So far so good. Now back to godot/scene/resources/scene_format_text.cpp Lines 1555 to 1589 in a0ea57b
The next for loop now saves the resources' properties. It will first do so for the Image object, which it does correctly. Then comes the ImageTexture .godot/scene/resources/scene_format_text.cpp Lines 1594 to 1614 in a0ea57b
It calls VariantWriter::write_to_string (line 1611) for the image property of the ImageTexture . This is where it should write image = SubResource( 1 ) , but instead writes image = null and prints
The godot/scene/resources/scene_format_text.cpp Lines 1353 to 1375 in a0ea57b
And here's why: godot/scene/resources/texture.cpp Lines 243 to 246 in a0ea57b
which calls
which always creates a new Image objectgodot/drivers/gles3/rasterizer_storage_gles3.cpp Lines 959 to 961 in a0ea57b
That means two calls to godot/scene/resources/texture.cpp Lines 243 to 246 in a0ea57b
by Ref<Image> ImageTexture::get_data() const {
static auto data = VisualServer::get_singleton()->texture_get_data(texture);
return data;
} and now the resource is indeed saved correctly. This "solution" is obviously just a hack and probably breaks 100 other things, but shows that this really is the problem. |
Oh man, 2 days on this and now that i found your work, this bug is REALLY a problem to me, cause its breaking the BakedLightMap generated by code. I will try your hack |
Is there anything else I can do to help fix this? I noticed that this issue hasn't received any labels yet. |
I tried to debug but i'm not able to do so, its simple to test, just create a imagetexture in code and use ResourceSaver to save it. If anyone can solve this, the game my team is creating will get very happy. |
I've also run into this issue in my texture painter. I'm trying to create a save format and I thought I'd just create a I was thinking maybe just loading the |
That's also been my workaround, but, as you said, the |
I'd the same problem. For me just saving the Image from the TextureImage with In my case that was enough. If you're using more information from the Texture like flags, you can do |
possibly related vnen/godot-tiled-importer#97 (but with .tmx) |
related #20178 One more example: ResourceSaver saves nothing
|
Godot version: 3.0.2
OS/device including version: Ubuntu 18.04
Issue description: The ResourceSaver is not correctly saving ImageTextures (at least I think so). The
[resource]
section'simage
is set tonull
, but should be set toSubResource( 1 )
.Minimal reproduction script: This is a simple script you can run. The asserts will not trigger. However, in the generated
.tres
files,image
is set tonull
. (I hope it's okay to attach a script instead of a full project. I can also create a project, if you want me to.)Generated
.tres
files:The text was updated successfully, but these errors were encountered: