I've just discovered that far away objects in my world don't seem to clip like they should with a perspective projection matrix.
When I fly far away from my main landscape, so that I am much more than 10 units (if not hundreds) away, it won't disappear. This is weird, because I thought objects should clip/disappear once they hit the far plane.
Here's a photo that demonstrates the issue:
I have defined the projection with my own custom function. The field of view is
60 degrees and the aspect ratio is 1.3333 (although those shouldn't matter), the near plane is
0.1 and the far plane is
10. I have experimented with adjusting the far plane and even when it is
0.2 nothing is ever clipped. When it is 0.1 or below I get a blank screen. (which makes sense)
The matrix is calculated like so:
projectionMatrix.setIdentity(); float yScale = MathHelper.coTangent((float) Math.toRadians(fieldOfView / 2f)); float xScale = yScale / aspectRatio; float frustumLength = farPlane - nearPlane; projectionMatrix.m00 = xScale; projectionMatrix.m11 = yScale; projectionMatrix.m22 = -((farPlane - nearPlane) / frustumLength); projectionMatrix.m23 = -1; projectionMatrix.m32 = -((2 * nearPlane * farPlane) / frustumLength); projectionMatrix.m33 = 0;
This produces a perspective projection like so:
1.299038 0.0 0.0 0.0 0.0 1.7320508 0.0 0.0 0.0 0.0 -1.0 -0.20202021 0.0 0.0 -1.0 0.0
Thanks very much if you could help with this annoying issue/benefit.