vertex colors with CSGMesh and MeshInstance

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Axciton

I try to use vertex color with meshes. I use following code

func _ready():
var surface_tool = SurfaceTool.new();
surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES);

var mat = SpatialMaterial.new()
mat.vertex_color_use_as_albedo = SpatialMaterial.FLAG_ALBEDO_FROM_VERTEX_COLOR
surface_tool.set_material(mat)	

surface_tool.add_color(Color(1, 0, 0, 1))
surface_tool.add_vertex(Vector3(0.5, 0, 0))	
surface_tool.add_color(Color(0, 1, 0, 1))
surface_tool.add_vertex(Vector3(-0.5, 0, 0))	
surface_tool.add_color(Color(0, 0, 1, 1))
surface_tool.add_vertex(Vector3(0, 1, 0))
surface_tool.generate_normals()

mesh = surface_tool.commit()

When I attach this script to MeshInstance everything works fine. But, when I try to use it with CSGMesh nothing works.

Link to the screenshot https://imghub.io/i/q5ro

Is it intentional or is it a bug? I wasn’t able to find the answer myself.