godot: ImageTextureLayered does not persist its state

Godot version

4.0b1dev (commit c2f66648f1cb7f26adf77cc3cf91052c95be5dbe)

System information

Windows 10, Vulkan

Issue description

ImageTextureLayered and its subclasses do not save their โ€œcontentโ€ when asked by using ResourceSaver.save. No persistable properties are defined, so none are stored.

Steps to reproduce

The following code:

var i := Image.create(1, 1, false, Image.FORMAT_RGB8)
i.set_pixel(0,0, Color(1,0,0))
ResourceSaver.save(i, "res://image.tres")
var l := Texture2DArray.new()
l.create_from_images([ i ])
ResourceSaver.save(l, "res://layered.tres")

Results in layered.tres looking empty like this:

[gd_resource type="Texture2DArray" format=3]

[resource]

while image.tres shows the proper image was created (and saved):

[gd_resource type="Image" format=3]

[resource]
data = {
  "data": PackedByteArray(255, 0, 0),
  "format": "RGB8",
  "height": 1,
  "mipmaps": false,
  "width": 1
}

Minimal reproduction project

See code above.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@Ithamar I just compiled master with your patch and can confirm, it fixed my problem with Texture2DArray saving - worked perfectly! Thanks!

Nice! Iโ€™ll clean it up and post a PR for it as well tonight, so we can get all the Texture2DArray stuff back working again ๐ŸŽŠ

Sounds like you nailed it though, I will keep an eye out for the 4 PR as I can finally continue my porting ๐Ÿ˜ƒ

If you feel experimental enough, the 4.x commit that fixes it for me is here: https://github.com/Game3DEE/godot/commit/68bb829d49afcd4f0bd6516abbed84f1a27df61f, feel free to grab it, but this is only tested with the above script, so YMMV.

so, with the above commit, the layered.tres now looks like:

[gd_resource type="Texture2DArray" load_steps=2 format=3]

[sub_resource type="Image" id="Image_6yw58"]
data = {
"data": PackedByteArray(255, 0, 0),
"format": "RGB8",
"height": 1,
"mipmaps": false,
"width": 1
}

[resource]
_images = [SubResource("Image_6yw58")]

and has the correct (red square) preview in the Inspector.

Okay, I think I have a fix for master too, seems to work here locally, but I want to wait for the results of PR #70212 first, as they share the core changes, and I want to first be sure those are okay to commit.

Anyway, hopefully this will finally be the end of all the TextureLayered woes with Godot, and I can go back to hacking on my game instead of Godot ๐Ÿ˜„