I ran across this while trying to point some debug text (that had a world position) at the camera, and wanted to make sure I wasn’t misunderstanding something before I opened a bug report/pull request for a fix I have… Matrix.CreateBillboard() seems to orient billboards the wrong direction, such that textures are flipped left-to-right.
In the simplest case, if I create a textured quad at the origin, in the x-y plane, with the camera positioned at positive-z looking toward the origin, and leave the identity matrix as the world transform, I get the expected orientation of the texture:
However, if I change the world matrix to be the one returned by CreateBillboard() for the given object and camera positions, the quad is reversed (same quad and uv coordinates) and becomes a backface (culling disabled for this test):
Interestingly, if I push the camera up very close to the quad and provide an explicit camera-forward vector to CreateBillboard(), it reverses the orientation of the quad, so the texture is now “correct” (with regard to my expectations, anyway) – it looks like there’s a negative sign in one code path that doesn’t exist in others.
Am I simply misunderstanding how Matrix.CreateBillboard() is supposed to behave? Or is something actually wrong here?
Happy to provide code for the above images, if necessary, but as a newbie I’m unsure of the preferred style for doing so… Code snippets in preformatted blocks? The whole Game.cs file?
Thanks for any guidance!
EDIT: Fixed an incorrect statement that the quad became a backface in the near-camera case; it’s actually in the far-camera case. Sorry for any confusion.