Skip to content
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

LargeTexture.get_data() always returns null #22457

Closed
pfertyk opened this issue Sep 26, 2018 · 6 comments · Fixed by #48269
Closed

LargeTexture.get_data() always returns null #22457

pfertyk opened this issue Sep 26, 2018 · 6 comments · Fixed by #48269

Comments

@pfertyk
Copy link
Contributor

pfertyk commented Sep 26, 2018

Godot version: v3.0.6.stable.official.8314054

OS/device including version: Linux Pop!OS 17.10 (artful)

Issue description:

I've created a LargeTexture instance and added 2 textures to it. Then I've tried to set this texture as camera's environment panorama. I got a black panorama instead. When I've set a StreamTexture (load()) it worked fine.

Steps to reproduce:
Here is a code sample from my project (scene with a camera, method _ready):

	var lt = LargeTexture.new()
	lt.set_size(Vector2(1000, 1000))
	lt.add_piece(Vector2(0, 0), load("res://assets/images/space.jpg"))
	lt.add_piece(Vector2(0, 0), load("res://assets/images/planet_transparent.png"))
	print(lt.get_piece_count())
	print(lt.get_size())
	print(lt.get_data())
	print(lt)
	camera.environment.background_sky.panorama = lt
#	this works
#	camera.environment.background_sky.panorama = load("res://assets/images/planet_transparent.png")
	var tex = camera.environment.background_sky.get_panorama()
	print(tex)

Output:

2
(1000, 1000)
[Object:null]
[LargeTexture:1007]
[LargeTexture:1007]

Note: camera uses its own environment (overwriting the default environment of the project). As you can see, lt.get_data() returns null, but that was not a problem before (I've created another project, where I use the same setup for LargeTexture and use it for a TextureRect; there I've also got a null, but the texture worked as expected).

Minimal reproduction project:

@KoBeWi
Copy link
Member

KoBeWi commented Jun 27, 2020

Can anyone still reproduce this bug in Godot 3.2.2 or any later release?

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

@pfertyk
Copy link
Contributor Author

pfertyk commented Jul 1, 2020

I forgot that I submitted this one ;) I remember that eventually I've found a workaround, which later turned out to be a correct solution (my experiments with merging textures would produce a wrong result).

I will try to recreate this in the next couple of days. If you don't hear back from me, consider it fixed ;)

@miskatonicstudio
Copy link

Unfortunately, it still doesn't work, just checked on Godot v3.2.2.stable.official on Linux. I think I figured out a simpler example:

	var lt = LargeTexture.new()
	lt.set_size(Vector2(2048, 2048))
	lt.add_piece(Vector2(0, 0), load("res://color.png"))
	var image = lt.get_data()
#	var image = lt.get_piece_texture(0).get_data()  # this works
	image.save_png("texture.png")

This causes Attempt to call function 'save_png' in base 'null instance' on a null instance. The problem seems to be that get_data on LargeTexture always returns null.

@akien-mga akien-mga changed the title LargeTexture doesn't work with camera's panorama sky LargeTexture.get_data() always returns null Apr 28, 2021
@akien-mga
Copy link
Member

We were discussing this with @reduz but it's unclear what use case LargeTexture still has in Godot 3.x. Is there a specific reason why you were attempting to use it instead of a plain StreamTexture?

Removing LargeTexture would be a simple way to solve this for 4.0 :)

@miskatonicstudio
Copy link

The idea here was to combine several textures into a single one. While eventually I figured out that this is not a correct solution (instead, I should create a 3D sprite with the smaller texture), the problem in general remains. I've used LargeTexture because it's the only one that had add_piece method which, as far as I know, adds another texture to the current one. StreamTexture doesn't have this method, so it didn't seem the right choice for this job ;)

Is there another way to combine several textures in Godot? If the method add_piece is there, it should work, but last time I checked it didn't (as described above). If LargeTexture will be removed in Godot 4.0, then what should I use for combining textures?

@KoBeWi
Copy link
Member

KoBeWi commented Apr 29, 2021

You can use blit_rect() in Image class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants