I have a dodecahedron that i imported from Blender and i want to be able to color each of its faces with a different color. Since each face is made out of three triangles, I have tried changing the colors of vertices based on their normals in ARRAY_COLOR, but this is the result:
As you can see some faces are correctly colored as i wished but some have this gradient that i don't want. I would want every face to have a single solid color. Here's my gdscript:
`@tool
extends MeshInstance3D
var arrays := mesh.surface_get_arrays(0)
var vert_col = arrays[ArrayMesh.ARRAY_COLOR]
var vertices = arrays[ArrayMesh.ARRAY_VERTEX]
var indices = arrays[ArrayMesh.ARRAY_INDEX]
var normals = arrays[ArrayMesh.ARRAY_NORMAL]
var dict = {}
func _ready() -> void:
for i in len(normals):
if dict.has(normals):
vert_col = dict[normals]
else:
dict[normals] = Color(randf(), randf(), randf(), 1)
vert_col = dict[normals]
var new_mesh = ArrayMesh.new()
new_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
mesh = new_mesh
`