- Home /
Calculate approximate or same size and position of an 2d sprite(plane) object so it appears the same rendered with orthographic and perspective camera
Is it somehow possible to calculate a 2D plane object(sprite)'s size and position so it appears approximately or entirely the same rendered either with a perspective or an orthographic(or both for that matter) camera? I should also mention that the perspective camera is not rotated and is looking on the same axis as the orthographic.
It quickly becomes pretty much impossible, since for example a cube anywhere near the top of a perspective view reveals it's bottom side to the camera, whereas in an orthographic view only the faces facing the view direction will ever show.
I guess you could use Camera.WorldToScreenPoint() to calculate the screen positions of you geometry (meshes/vertices) and then Camera.ScreenToWorldPoint with the new camera to deform your geometry to look very close to what it was in the previous view. There's probably tons of problems with this and it get's easily very complicated.
Depending on what you want, you might be able to compromise. Find 2 camera settings and a distance that make a cube in the center of the view look the same and try to align your camera to that distance of the object of interest whenever you change modes... Or rotate all objects to face the camera and move them into a spherical formation around the perspective camera when moving to that mode. They will still get distorted by the perspective, especially near the screen corners, unless you modify the mesh geometry too, though.
The object is basically a 2d sprite as i wrote in my updated question and the perspective camera is rotated exactly as the orthographic. This is why i though something can be done.