You can get the root viewport using get_tree().root
, get it’s ViewportTexture by calling get_texture()
. From there, you can convert the ViewportTexture to an Image by calling get_data()
, and then the pixel data by calling get_pixel
. Altogether, it would look something like this:
func _ready():
var root_view = get_tree().root
var root_view_tex = root_view.get_texture()
var root_view_image = root_view_tex.get_data()
# then to access pixels
print (root_view_image.get_pixel(20, 20)
I haven’t tested the code though, so I don’t know if it will work.