Skip to content

PortableCompressedTexture2D loaded from disk has null tex #108040

Closed
@nyte-owl

Description

@nyte-owl

Tested versions

  • Reproducible in v4.4.1.stable.official [49a5bc7]

System information

Godot v4.4.1.stable - Windows 11 (build 26100) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.6094) - Intel(R) Core(TM) i9-14900K (32 threads)

Issue description

I am trying to create PortableCompressedTexture2D from an image at runtime and save them to disk. Loading the resource, either later in the code or manually in the inspector results in an error:

Parameter "tex" is null.

It's worth noting that using the texture directly after loading from image in a Sprite2D works as expected and displays properly.

Steps to reproduce

Create a simple Node2D scene with a Sprite2D.
Attach this script to it:

extends Node2D

@onready var sprite_2d: Sprite2D = $Sprite2D

func create_texture() -> void :
    var image:Image = Image.create(32,32,false, Image.FORMAT_RGBA8)
    image.fill(Color.BLACK)

    var texture:PortableCompressedTexture2D = PortableCompressedTexture2D.new()
    texture.create_from_image(image, PortableCompressedTexture2D.COMPRESSION_MODE_LOSSLESS)
    sprite_2d.texture = texture
    ResourceSaver.save(texture, "res://img.res")

    texture = load("res://img.res")

func _ready():
    create_texture()

The load line throws an error:

E 0:00:02:635   node_2d.gd:14 @ create_texture(): Parameter "tex" is null.
  <C++ Source>  servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:1592 @ texture_set_size_override()
  <Stack Trace> node_2d.gd:14 @ create_texture()
                node_2d.gd:17 @ _ready()

Also, attempting to open the img.res file in the Godot inspector causes the same error message to be displayed.

Minimal reproduction project (MRP)

portable_tex_bug.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions