Skip to content

Godot winding direction for SurfaceTool, ArrayMesh, and MeshDataTool are incorrect #10757

Open
@Kevin-Jonaitis

Description

@Kevin-Jonaitis

Your Godot version:
v4.4.beta4.official.93d270693

Issue description:

In the documentation for SurfaceTool, ArrayMesh, and MeshDataTool it states:

Note: Godot uses clockwise winding order for front faces of triangle primitive modes.

I've been banging my head against this problem for quite a few hours, googled all around, and I think this is just incorrect in the documentation.

I believe Godot uses counterclockwise winding order when dealing with primitive triangles.

And indeed, in the documentation that the godot docs link to on https://learnopengl.com/ it says

By default, triangles defined with counter-clockwise vertices are processed as front-facing triangles.

And on the official openGL documentation it states:

On a freshly created OpenGL Context, the default front face is GL_CCW.

I tested a project that I'll link below, but I wrote some code to do the winding order as follows:

var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.add_vertex(Vector3(0, 2, 0))
st.add_vertex(Vector3(2, 2, 2))
st.add_vertex(Vector3(0, 2, 2))
var mesh = st.commit()

I think you can agree this is a clockwise winding order, and assuming godot is a right-handed coordinate system, you'd expect the normal face to point "down"(-Y axis in 3D godot).

However, I created a simple project, and that's simply not the case; you can see the triangle from "above" but not below, which implies that the triangle normal is actually facing "up"(+Y). See the yellow triangle below:

Image

Looking "down"(-Y):

Image

Here's the project with the above code:

winding_direction_test.zip

URL to the documentation page:
https://docs.godotengine.org/en/stable/classes/class_surfacetool.html#description
https://docs.godotengine.org/en/stable/classes/class_arraymesh.html
https://docs.godotengine.org/en/stable/classes/class_meshdatatool.html

Maybe I'm misunderstanding something here, so please double check me if I've got this right. I'll attach the sample project with the above code to the issue.

If the docs are wrong, I'm happy to submit a pull request to update the docs.

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