Godot Version
4.3.stable
Question
I currently have a MultiMeshInstance2D set up that accepts color as the instance data, and I know it works if I set the instance color upon the MultiMeshes creation or in _ready()
.
However, if I try setting instance data in the _process()
function, nothing visually changes, even if i do a queue_redraw()
right after. Is updating MultiMesh instance data in the render step not something that you’re supposed to do?
Example Psuedocode:
(Not my actual code, just showing what I’m trying to do and the fact that it doesn’t work.)
## Given that $MM is a MultiMeshInstance2D
## and $MM.multimesh.use_colors == true...
func _ready():
# works, color is set to red
$MM.multimesh.set_instance_color(0, Color.RED)
# also works, color is set to blue
$MM.multimesh.set_instance_color(0, Color.BLUE)
func _process(_delta : float):
# doesn't seem to work, unless I'm doing this wrong?
# in this example, instance 0 would still visually be blue.
$MM.multimesh.set_instance_color(0, Color.GREEN)
# neither of these do anything to resolve the issue
queue_redraw()
$MM.queue_redraw()
shader_type canvas_item;
varying vec3 i_color;
void vertex() {
i_color = COLOR.rgb;
}
void fragment() {
COLOR.rgb = texture(TEXTURE, UV).rgb * i_color.rgb);
}
Many thanks to whoever can help me figure this out!