this post was submitted on 29 Sep 2023
3 points (100.0% liked)

Godot

18 readers
1 users here now

A community for discussion and support in development with the Godot game engine.

founded 1 year ago
 

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.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here