Tuesday, May 29, 2018

perspective - An object twice as close appears twice as big?


So I was thinking about creating a 2D game where you can also move along the Z-axis, by changing in which layer you are. Depending on the depth I want to scale my 2D sprites.


Once, someone had shown me a demo in which he had a lot of 2d sprites, and by scrolling he could change the depth of the camera. So when zooming in, the objects would come closer to the player, and appear bigger. Then I wondered, how much bigger should an object be when it gets 1 unit closer. How would you calculate that? So the guy told me: There is one basic rule I am using: "objects twice as close, appear twice as big."


Now, by testing it myself, I know that rule doesn't apply in the real world ;) But is there some constant that is used in real world calculations for perspective or something? Or a formula?


I know this might not be the best place to ask such a question, but since this is the only site I use for game-related questions, and my context is a game, I thought I'd give it a try. Also, I am kind of expecting that there is this person here that knows everything about 3D perspectives and matrices or something, since it might relate to 3D games ;)


tl;dr:



"an object twice as close, appears twice as big" That is not true in the real world. But which constant or formula is correct?



Answer



Generally it is true, depending on your view point and in which direction it has moved, as well as the viewing angle.


Example of perspectives for objects


Note how in the first camera view, as the Red block is perpendicular to the camera view, the object seems to be twice as large in a perfect 1:2 ratio (Note the arrow pointing that it hits the edge of the view after being moved twice as close)


The second is the same size block rotated at 45 degrees. As it is rotated, the bottom edge is no longer at the same distance from the camera as the top edge, so it does not SEEM correctly scale to a 1:2 ratio but it in actual fact is twice as large (as it is at the same angle on the further away blue block as it is in the close blue block.)


In conclusion this actually means your friend was correct and a 1:1 ratio ("objects twice as close, appear twice as big.") for your objects is a good choice.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...