Hi, I'm working on my first Godot project and I've seen a lot of examples on how to do it for Godot 3 but it seems to have changed and there's not a lot of resources for Godot 4 on that yet unfortunately. Does someone know what am I missing here? I get the UVs alright and it sets the texture but it just remains black the whole time.

func _create_texture():
    var pixels = 256
    #tex = Image.create(pixels, pixels, false, Image.FORMAT_RGBA8)
    imageTexture = ImageTexture.new()
    tex = Image.create(pixels, pixels, false, Image.FORMAT_RGBA8)
    imageTexture.set_image(tex)
    mesh.material_override.set("albedo_texture", imageTexture)

func draw_on_sprite(coords):
    tex.set_pixelv(coords, Color.RED)
    imageTexture.update(tex)

Thanks in advance 🙂

    opponent019 changed it to blend_rect instead (which is what i needed anyway, i was just trying to make it easier for me with set_pixel haha) and got it working!! Here's my working code:

    extends Node
    
    var img : Image
    var tex : ImageTexture
    var mesh : GeometryInstance3D = null
    
    var rect : Rect2i
    var brush : Image = Image.load_from_file("res://Art/Textures/T_TomatoSauce_brush.png")
    var brushSize
    var pixels = 256
    
    func _create_image():
    	img = Image.create(pixels, pixels, false, Image.FORMAT_RGBA8)
    	
    	brushSize = brush.get_height()
    	rect = Rect2i(Vector2i(0,0), Vector2i(brushSize,brushSize))
    	
    	tex = ImageTexture.create_from_image(img)
    	mesh.material_override.set("shader_parameter/Mask_texture", tex)
    
    func _get_mesh():
    	for child in get_children():
    		if child is GeometryInstance3D:
    			mesh = child
    
    func _ready():
    	_get_mesh()
    	_create_image()
    
    func draw_on_sprite(coords):
    	coords = (coords * pixels) - Vector2(brushSize, brushSize)/2
    	img.blend_rect (brush, rect, Vector2i(coords.x,coords.y))
    	tex.update(img)
    	mesh.material_override.set("shader_parameter/Mask_texture", tex)

    for some reason you gotta set the material texture each time? Even though I'm updating the same texture.