Mix texture 2Ds

Is there a Godot plugin/addon that adds a Texture2D class that blends two ImageTextures together? And if not, does anyone know how to make one?
I looked through the API for the classes, but I couldn’t find a way to do this in C# or GDScript, so it’d have to be an addon, which I have absolutely no experience in writing.

Are you wanting something that will take two separate texture resources and draw them on the same surface in some blended way, or do you want to take two separate texture resources and create a new texture resource out of them but blended together?

Maybe something like this can help you.

@export var texture1 : Texture2D
@export var texture2 : Texture2D

func blend_texutres(a_position: Vector2i):
   var image1: Image = texture1.get_image()
   var image2: Image = texture2.get_image()
   image1.blend_rect(image2, image1.get_used_rect(), a_position)

You can use position as a position Vector2i.ZERO (for 0, 0 coordinates)

1 Like

If you need later to create a texture from an image, you can use this:

var texture = ImageTexture.create_from_image(image)
$Sprite2D.texture = texture

You can also save the resulting image to disk:

image.save_png(filename)
1 Like

That’s exactly what I was looking for, thanks!
Is there any documentation on how Godot uses Texture2D to render though? I’d like to implement this as a class that extends Texture2D and applies this blended image.