+2 votes

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.

in Engine by (14 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.