How to modify/paint a texture in a 3D model during run-time?

Hi, I posted my question in Godot Forums but I fear it's gone quickly into oblivion but I've been stuck on this for days, would love some help!
https://godotforums.org/d/36536-how-to-use-set-pixel-in-godot-4

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)

I can get the UVs alright, the mesh becomes black when the texture is set in _create_texture() but it never changes color. If I get_pixelv after setting it it does show that it's now (1,0,0,1) so I'm not sure why it's not showing in game. Any clue?

There seem to be quite a few changes from Godot 3 to Godot 4 in this area so most of the info online about it is outdated now.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • godot
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • provamag3
  • ethstaker
  • cisconetworking
  • modclub
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • normalnudes
  • megavids
  • Leos
  • anitta
  • JUstTest
  • lostlight
  • All magazines