Winding order for clarity

If you don’t mind, I want to clarify a couple of points.
Chapter 3 says: “For efficiency, you should set winding order and enable back-face culling in the pipeline state.”
However, func setFrontFacing(_ frontFacingWinding: MTLWinding) is not used anywhere in the book. Why is that?
After all, in the Blender, which we use throughout the book, the order of the vertices is counterclockwise. Whereas in Metal, the default winding order is clockwise.

1 Like

For sure, final code should cull front or back facing mesh where necessary.

If you have single sided mesh, however, e.g. leaves on trees, you wouldn’t want to cull the back sides of the mesh, as you wouldn’t see the leaves turned away from you.

So you should pick and choose where to cull your mesh, or sort your models accordingly.

As to winding order, it also ties in with the projection matrix. The projection matrix used in the book is a left handed coordinate system projection matrix.

When used with a left handed projection matrix, you don’t have to change the default winding order.

If you had a right handed projection matrix, then you would set the winding order as counter clockwise.

If you want to have counter clockwise winding order with a left handed projection matrix, then you can invert the vertex z coordinates.