How are the front and back of a face decided?

I have this custom polysphere mesh - I have asked questions about it a few days ago - that I can manipulate to become a globe terrain.

When I started out with it, I accidentally copied some code for the material that had the following line in it:
mat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off );

It turns back-face culling off. I can ignore this line and leaf it. My globe will keep looking nice. But when I remove it, the default is taken and the back faces are culled.

I tried that, and first was puzzled by the weird effect. But I now know what is happening: the model somehow is defining the inner side of the polysphere to be the front.

I tried to turn around the triangle definitions, knowing that in most 3D engines culling uses the order the vertices are defined in the triangle to determine what is the front and what is the back. The well known Left-hand and Right-hand rule.

But that did not do the trick in this case, making me wonder how JME3 determines the front side of a face. What am I missing here?

1 Like

Im not sure why the order of the verticies didn’t work for you. That is indeed how Jmonkey determines the front side. Vertextes are anticlockwise wound when viewed from the front.

See Custom Mesh Shapes :: jMonkeyEngine Docs for more details

3 Likes

There are 2 defintions of “front” and “back”:

  • For face culling, JME uses the “winding order” of the vertices, with a right-hand rule.
  • Normals are used to cull backward-facing fragments in some JME shaders.

In poorly-constructed meshes, its possible for the winding order to disagree with the normals for some or all faces.

5 Likes