Viewport texture returns blank data
I'm trying to make an image of the content of a viewport, but fail. It appears to be a bug with ViewportTexture.get_data(). Before I post it in the issue tracker, I'll just check if someone else has had the same problem.
extends Node2D func _ready(): # Setting sprite texture directly to the viewport's texture works var vp_texture = $Viewport.get_texture() $ViaTextureSprite.texture = vp_texture # works, the content from the viewport shows up in the sprite # Getting the data doesn't work var image = vp_texture.get_data() # returns blank data print(image.data["data"].hex_encode()) # prints all zeros # Creating an image texture in this way works (I have tested by creating an Image from scratch) # However, here it gets feed a blank image var image_texture = ImageTexture.new() image_texture.create_from_image(image) $ViaGetDataSprite.texture = image_texture # blank image in sprite pass