3d mesh rendering - can't change facing direction

Godot Version

Godot 4

Question

Hi I’m creating two triangles like this:

    var st = SurfaceTool.new()

    st.begin(Mesh.PRIMITIVE_TRIANGLES)

    # Prepare attributes for add_vertex.
    st.set_normal(Vector3(0, 0, 1))
    st.set_uv(Vector2(0, 0))
    # Call last for each vertex, adds the above attributes.
    st.add_vertex(Vector3(-1, -1, 0))

    st.set_normal(Vector3(0, 0, 1))
    st.set_uv(Vector2(0, 1))
    st.add_vertex(Vector3(-1, 1, 0))

    st.set_normal(Vector3(0, 0, 1))
    st.set_uv(Vector2(1, 1))
    st.add_vertex(Vector3(1, 1, 0))


    # Prepare attributes for add_vertex.
    st.set_normal(Vector3(0, 0, 1))
    st.set_uv(Vector2(0, 0))
    # Call last for each vertex, adds the above attributes.
    st.add_vertex(Vector3(-1, -1, 1))

    st.set_normal(Vector3(0, 0, 1))
    st.set_uv(Vector2(0, 1))
    st.add_vertex(Vector3(-1, 1, 1))

    st.set_normal(Vector3(0, 0, 1))
    st.set_uv(Vector2(1, 1))
    st.add_vertex(Vector3(1, 1, 1))
    
    # Commit to a mesh.
    var mesh = st.commit()
    var meshInstance = MeshInstance3D.new();
    meshInstance.mesh = mesh;
    $"/root".add_child.call_deferred(meshInstance);

Creates this:

right-shading

But I’d like for one of the triangles to be facing the opposite direction. I tried to switch normal of one of the triangles to -1 instead, but it just changed the shadow, not direction.

wrong-shading

I have also tried to switch around add_vertex calls so that one of the triangles would be created in the other direction, but that didn’t work either.

I may be a bit stupid, but I couldn’t find anything in the documentation :slight_smile: I’m new to doing stuff with meshes, so I don’t have any prior experience with it either.

I was hoping someone might know what I should do :slight_smile: