I am currently working on the camera code of my 2D game project. Now, although I have said "2D", entities have a 3D location, which is to be used both for a free parallax effect, as well as gameplay. I initially had an orthographic projection set up, in the following way :
mProjection = Matrix.CreateOrthographic(mRenderer.backBufferWidth * mDistance, mRenderer.backBufferHeight * mDistance, mNear, mFar);
The code is quite explicit, apart from mDistance maybe. This variable simply represents the distance/scaling factor of the camera, and otherwise expands the projection range to show a bigger part of the screen (in essence, zooming in and out).
I have switched this method to using "CreatePerspective" in the following way :
mProjection = Matrix.CreatePerspective(mRenderer.backBufferWidth, mRenderer.backBufferHeight, mNear, mFar);
The mDistance variable was moved to the actual view matrix computation, which is why it does not appear here. Although it works "visually", I found that the BoundingFrustum I compute for my Camera is no longer valid :
mFrustum.Matrix = this.view * this.projection;
The frustum is used for the culling of my entities, and the algorithm will work with the original orthographic projection, and perspective projection matrices defined in the following way :
mProjection = Matrix.CreatePerspective(1.0f, 1.0f/1.33f, mNear, mFar);
I am slightly confused, and failing to see why my solution fails : shouldn't I be allowed to project coordinates as I like. Essentially, with my setup, I am trying to map a unit to a single pixel. In other words, I would like an object of size 64*64 to be exactly 64*64 pixels on the screen, when it sits on the near plane.
Where have I gone wrong with my thinking process?
Your help and explanations would be appreciated !