0
\$\begingroup\$

Does anyone know a formula, way, ... to make a FPS player feel like an object has the same size on different FOVs (given that it's at the same distance of the player, of course)? I know that this can't be done perfectly, because of the distortion various FOVs cause and the position of the object (near the edges of the FOV = more distortion). Let's ignore these distortions, and aim for a same size feel for objects that are directly in front of the player (so in the exact center of the FOV).

To clarify things a bit further: I want 1 object in my game to have the same scale feel on different FOVs, not my entire game world.

I've tried giving it a percentage of the frustrum height, but that doesn't seem to give me consistent results.

Note: I'm using vertical field of view in my game.

\$\endgroup\$
  • 4
    \$\begingroup\$ I think what you are looking for is Dolly Zoom. \$\endgroup\$ – Pluto Nov 26 '17 at 16:38
0
\$\begingroup\$

If the suggested dolly zoom is not what you are after, you could try this - not sure how well it'll work, though, this is pretty much of the top of my head. Store the initial view frustum height (h0) in a variable, and then when it changes (h1) compute the scaling factor s = h1/h0, and then uniformly scale your target object by s.

Now, if the FOV change is extreme, the distortion you mentioned may become a bit too pronounced; you could then experiment with dynamically modifying s to compensate - by making s larger or smaller; just multiply it with a floating point number that's around 1.0 (slightly higher or lower) and see what works best.

Once you have the values that work (say, cMin and cMax), you can use linear interpolation for that multiplier. For that, you'll need an interpolation parameter t that goes from 0 to 1 (0 will map to cMin, and 1 will map to cMax - think of it like a slider of some kind). So, you calculate your compensation factor like this:

c = (1-t)*cMin + t*cMax

To get t, you can use either the FOV angle or the view frustum height. Again, find some minimum value and a maximum value (say, hMin and hMax), and do:

t = (h - hMin) / (hMax - hMin)    // where h is the current value

This will produce 0 when h == hMin and 1 when h == hMax.

Finally, you calculate the scale:

sFinal = c * s         // or
sFinal = c * h1/h0
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.