Skip to content

set_color doesn't work in SurfaceTool #2001

Description

@JekSun97

Godot version

4.5

godot-cpp version

4.5 stable

System information

Godot v4.6.3.stable - Windows 10 (build 19045) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - Radeon RX 560 Series (Advanced Micro Devices, Inc.; 31.0.21912.14) - Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 threads) - 15.93 ГиБ memory

Issue description

I can't set the vertex color in SurfaceTool, I did the same process with GDScript and it worked, but with GDExtension (Godot C++) I can't change the vertex color, here is my code:

Ref<SurfaceTool> st;
st.instantiate();
st->begin(Mesh::PRIMITIVE_TRIANGLES);
    for (int i = 0; i < tree.mVertCount; i++)
	{
		st->set_color(Color(0.0, 1.0, 0.0, 1.0));
		st->add_vertex(Vector3(tree.mVert[i].x, tree.mVert[i].y, tree.mVert[i].z));
	}
	
	for (int i = 0; i < tree.mFaceCount; i++)
	{
		st->add_index(tree.mFace[i].x);
		st->add_index(tree.mFace[i].y);
		st->add_index(tree.mFace[i].z);
	}
st->optimize_indices_for_cache();
trunk_inst->set_mesh(st->commit());

To test this I used a standard material with "Use As Albedo" enabled and also Unshaded in Shading Mode, could anyone check this?

Steps to reproduce

Try coloring the vertices and displaying them using a material, using approximately the method described above.

Minimal reproduction project

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions