- Home /
RenderTexture, Camera.aspect and Camera.fieldOfView
To start, an explanation of what I'm trying to achieve. It's a flat mirror using a second camera drawing into a RenderTexture. The RenderTexture is then used on the front face of the mirror.
To avoid unnecessary draw calls, I'm placing the second camera behind the mirror as you'd expect but limiting it's field of view and aspect to an approximation of the size and shape of the mirror face as seen from the camera.
Now the maths. The beautifully rendered image below illustrates the camera at the point of the triangles and the face of the mirror in red (it's 8 units across). This is after all coords have been translated into the mirror's object space.
I'm sure there's more elegant ways to solve this but it looks correct to me. The Camera.aspect is found by dividing "i" by the "i" result of the same calculation but for y instead of x. This appears to work perfectly. I end up with a rectangle on the near clip plane that is the same ratio as the mirror face viewed from the camera.
Where it all goes wrong is the camera.fieldOfView. By my understanding this should be the q value derived from the y calculation. However, this works to an extent for movements on the y-axis but as the x value increases (both positively and negatively) the field of view grows in both directions relative to the aspect.
Any help is appreciated.