I’m running into some unexpected behavior and was hoping someone could point me to an explanation or official doc about what is happening here…
Quick backstory: I have a model defined in a right-handed coordinate system that I load into a Mesh. This mesh gets attached to a MeshFilter which is then rendered by a MeshRenderer. Because Unity is a left handed coordinate system and my model is in a right handed system, in order to render the mesh correctly I will need to flip the triangle winding and apply a scaling to the Transform which flips the x-axis. Otherwise, the model will be flipped and front faces will get culled.
Although my expectation is that Unity will cull back faces by default, when rendering this aforementioned GameObject with the negated x-axis scaling, the render pipeline switches to culling front faces instead. I’ve verified this by capturing a graphics trace. The D3D11 rasterizer state indeed gets set to culling front faces instead of back faces. This switch in cull mode is done implicitly and likely seems to be based somehow on the transform. This flipped x-axis is probably detected somehow by the MeshRenderer. Clarity about what is happening here though would be nice…
I could work around the issue by not inverting the triangle winding (such that culling front faces is what I need). That is certainly an option, but I want my front faces of the mesh to be the actual front faces. I want to avoid any weird effects this may have in say physics or navigation.
Rather than living with the flipped front faces, instead of using the MeshRenderer, I could issue draw calls manually by using Graphics.DrawMesh. I’ve found this keeps the culling as back face as expected. (Hence why it seems that the MeshRenderer is the source of this implicit culling flip.) But, I’d rather not have to rely on DrawMesh.
Preferably, I’d like the MeshRenderer to not perform this implicit culling flip. Is there a way to disable it?