Skip to content

Textures created with ImageTexture.create_from_image are ignoring custom provided mipmaps #66848

Closed
@Zylann

Description

Godot version

Godot 4 beta2

System information

Windows 10 64 bits NVIDIA GeForce GTX 1060

Issue description

I created an Image from code, integrating custom mipmaps. The image is successfully created, however when I use it to create an ImageTexture, the resulting texture appears to have no mipmaps.

Steps to reproduce

	var im = Image.new()
	im.create_from_data(size_x, size_y, true, Image.FORMAT_RGB8, pixels_with_mipmaps)
	var tex = ImageTexture.create_from_image(im)
	var sm = ShaderMaterial.new()
	sm.shader = load("res://show_mips.gdshader")
	sm.set_shader_parameter("u_texture", tex)
	_mesh_instance.material_override = sm
shader_type spatial;

uniform sampler2D u_texture;

void fragment() {
	ALBEDO = textureLod(u_texture, UV, fract(TIME) * 10.0).rgb;
}

Minimal reproduction project

ImageMipmaps.zip

In this project, every mip is a different random color. The expected result is a cube flickering with multiple colors. However only the first color shows up.

I'm not sure yet if I've done a mistake somewhere, because the way to create custom mipmaps is not documented, mipmaps aren't shown in editor inspector, and currently the remote inspector doesn't seem to work well enough to show remote textures.

After giving mipmaps to icon.png and testing this:

var tex = ImageTexture.create_from_image(load("res://icon.svg").get_image())

The result appears to have mipmaps. So I'm quite confused what I could have possibly missed.
Maybe Image isn't properly initializing? Maybe mipmaps I provide are completely ignored?

After more tests (adding noise to mip colors) it seems the latter is happening... ImageTexture finds that there are mipmaps, but ignores them and makes its own.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions