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.