Hello everyone. I’m trying to create a camera with a custom projection matrix that will result in the rendering that it produces to be compressed horizontally, preferably by a factor of two. The reason is that I have a head mounted display and two cameras rendering in each eye, and they take up half the screen; as such, they need to produce a horizontally compressed view of the world in order to render correctly in the head mounted display. I’m terrible with matrices, so what kind of Matrix4x4 would I use to solve this problem? Thanks!
I suggest that you use the “off-center projection” example from Unity itself: Unity - Scripting API: Camera.projectionMatrix
It allows you to independently set the opening angles of your rendering cam in the four directions (top, bottom, left and right).
In your particular case, keep left = -right and top = -bottom in all cases, and adjust left and top to match the opening angles you like, in the horizontal and vertical direction. Using a fixed left value, increasing top will compress the rendered image horizontally.
Hope this is what you were looking for…
PS: be aware that using custom projection matrices will prevent you from using the following:
- deferred shadows
- render-to-texture (=> several post-processing image effects)
PPS: A much simpler solution might be to just modify Camera.aspect on your cam (no custom proj matrix involved)…
Let me know…