22 lines
627 B
GDScript
22 lines
627 B
GDScript
extends Sprite2D
|
|
|
|
@export var export_path = ""
|
|
|
|
|
|
func _ready() -> void:
|
|
if texture and export_path:
|
|
var image = texture.get_image()
|
|
if image:
|
|
var converted_image = Image.create_empty(
|
|
image.get_width(), image.get_height(), false, Image.FORMAT_RGBA8
|
|
)
|
|
# convert to transparent BG point light image
|
|
for y in range(image.get_height()):
|
|
for x in range(image.get_width()):
|
|
var color = image.get_pixel(x, y)
|
|
converted_image.set_pixel(x, y, Color(1.0, 1.0, 1.0, color.r))
|
|
converted_image.save_png(export_path)
|
|
print("Exported to: " + export_path)
|
|
else:
|
|
print("No image found in texture")
|