Helper tool to create geometry.
    public class SurfaceTool : Reference

The SurfaceTool is used to construct a Mesh by specifying vertex attributes individually. It can be used to construct a Mesh from script. All properties except index need to be added before a call to AddVertex(Godot.Vector3). For example adding vertex colors and UVs looks like


var st =


st.add_color(Color(1, 0, 0))

st.add_uv(Vector2(0, 0))

st.add_vertex(Vector3(0, 0, 0))


The SurfaceTool now contains one vertex of a triangle which has a UV coordinate and a specified Color. If another vertex were added without calls to AddUv(Godot.Vector2) or AddColor(Godot.Color) then the last values would be used.

It is very important that vertex attributes are passed before the call to AddVertex(Godot.Vector3), failure to do this will result in an error when committing the vertex information to a mesh.

Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices.

Inheritance Chain


    public SurfaceTool()


    public void AddBones(int[] bones)

Add an array of bones for the next Vertex to use. Array must contain 4 integers.

    public void AddColor(Color color)

Specify a Color for the next Vertex to use.

    public void AddIndex(int index)

Adds an index to index array if you are using indexed Vertices. Does not need to be called before adding Vertex.

    public void AddNormal(Vector3 normal)

Specify a normal for the next Vertex to use.

    public void AddSmoothGroup(bool smooth)

Specify whether current Vertex (if using only Vertex arrays) or current index (if also using index arrays) should utilize smooth normals for normal calculation.

    public void AddTangent(Plane tangent)

Specify a Tangent for the next Vertex to use.

    public void AddTriangleFan(Vector3[] vertices, Vector2[] uvs = null, Color[] colors = null, Vector2[] uv2s = null, Vector3[] normals = null, Godot.Collections.Array tangents = null)

Insert a triangle fan made of array data into Mesh being constructed.

Requires primitive type be set to PRIMITIVE_TRIANGLES.

    public void AddUv(Vector2 uv)

Specify UV Coordinate for next Vertex to use.

    public void AddUv2(Vector2 uv2)

Specify an optional second set of UV coordinates for next Vertex to use.

    public void AddVertex(Vector3 vertex)

Specify position of current Vertex. Should be called after specifying other vertex properties (e.g. Color, UV).

    public void AddWeights(float[] weights)

Specify weight values for next Vertex to use. Array must contain 4 values.

    public void AppendFrom(Mesh existing, int surface, Transform transform)

Append vertices from a given Mesh surface onto the current vertex array with specified Transform.

    public void Begin(Mesh.PrimitiveType primitive)

Called before adding any Vertices. Takes the primitive type as an argument (e.g. Mesh.PRIMITIVE_TRIANGLES).

    public void Clear()

Clear all information passed into the surface tool so far.

    public ArrayMesh Commit(ArrayMesh existing = null, int flags = 97280)

Returns a constructed ArrayMesh from current information passed in. If an existing ArrayMesh is passed in as an argument, will add an extra surface to the existing ArrayMesh.

    public void CreateFrom(Mesh existing, int surface)

Creates a vertex array from an existing Mesh.

    public void Deindex()

Removes index array by expanding Vertex array.

    public void GenerateNormals(bool flip = false)

Generates normals from Vertices so you do not have to do it manually.

Setting “flip” true inverts resulting normals.

Requires primitive type to be set to PRIMITIVE_TRIANGLES.

    public void GenerateTangents()

Generates a tangent vector for each vertex.

Requires that each vertex have UVs and normals set already.

    public void Index()

Shrinks Vertex array by creating an index array. Avoids reusing Vertices.

    public void SetMaterial(Material material)

Sets Material to be used by the Mesh you are constructing.