Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Spoon on July 02, 2016, 12:37:02 pm

Title: Default FoV
Post by: Spoon on July 02, 2016, 12:37:02 pm
From the What would you like to see in a 'Freespace 1 Blue'? thread (http://www.hard-light.net/forums/index.php?topic=91743.0):

That's because -fov 0.75 in Freespace isn't the same as setting FOV to 75 in other games. Most games have a direct correlation between their FOV settting and the actual Field of View in degrees. In Freespace the default 0.75 FOV is actually something else. It's the vertical angle of view, in radians, multiplied by 1.39626348. for some reason.

First, you'd have to convert 0.75 radians to degrees which would be ~43 degrees.
Next you multiply that by 1.39626348 to get ~60 AoV. How this converts to FoV depends on your monitor's aspect ratio, but let's assume you're using a 16:9 widescreen one. Multiply 60 by (16/9) and you get 106.666...

The default Freespace FOV for a 16:9 monitor is actually ~107 degrees, which is quite high and this is why it causes "fisheye" distortions and makes big ships less impressive.

For a 16:9 monitor you need to divide whatever FOV you actually want by 142.2222 to get the number you need to use with the -fov flag. So if you want a 90 degree FOV you need to use -fov 0.6328.

On an old school 4:3 monitor the default FoV would be only 80, something that's much more natural.
I'm just thinking on how to get this information more widespread known to all the players. The fisheye effect is there, but its so much harder to notice in a space game with no good points of visual reference. So a lot of players are going to end up playing on a too wide of a FoV by default and then feel the scales for the ships are off. (incidently, I've been using default FoV for a long time myself, but my screens are 16:10). I feel ideally the scp should make the default to say 0.65 (so 85 fov on 16:10 and 94 fov on 16:9) or have it listed as a note on the launchers that FoV should probably be adjusted for a better experience. Or something.

Thoughts, opinions?
We're still having a default FoV that is basically tailored for 4:3 screens, while being in the year of our lord 2016.
Considering like half the WoD troubleshooting was caused by people not setting the resolution from 640x480 to something else in the launcher makes me feel not exactly hopeful that informing the player about FoV will get the point across. Setting the default to something else or have it auto adjust depending on screen size seems like the more idea solution in my book.
Title: Re: Default FoV
Post by: Axem on July 02, 2016, 03:00:53 pm
Yeah and a new command flag like -fovdeg where you go would input the desired angle in degrees and have the game auto do some hidden calculations would probably help a lot.

(So literally everything you said)
Title: Re: Default FoV
Post by: karajorma on July 03, 2016, 06:03:15 am
have it auto adjust depending on screen size seems like the more idea solution in my book.

This gets my vote. If no -fov flag is set it should just take a guess from the resolution. 
Title: Re: Default FoV
Post by: m!m on July 03, 2016, 07:04:49 am
I'm not exactly sure how the math would work but if you have a desired (horizontal or vertical) field of view you should be able to compute the right perspective projection matrix independently of the actually used resolution.
Title: Re: Default FoV
Post by: LaineyBugsDaddy on July 05, 2016, 12:52:55 pm
Not too long ago, I took a look at a CMS (Content Managemen System, for those not heavily into web design and development) that I helped write back when I knew nothing about PHP/MySQL interactions, so I was working UI while a former friend worked the backend. One of the things he did that I absolutely detested was that he wrote indivual create/update functions for each table of the database. For those that know a bit about PHP/MySQL interactions, you're probably already facepalming. For those that don't, here's the deal. Since this was supposed to be a framework for websites that gets used and reused, that meant that each time it got used for a new site, I would have to go in and change several individual functions around to match table and field names. And this was also the way the lookup functions were written. I was going to refactor the thing, but after a few attempts, I realized it would be easier to write a new one. One where the server does as much of the work as possible. Using SHOW TABLES to generate an array that PHP uses to have the data for the lookup functions; have a create/update function that takes arguments from the form calling it to determine table and field names and if it's creating or updating a record; attempting to use directory lookup to procedurally generate a navigation bar, though I have to be careful with that because it will pull in alphabetical order, so I have to make sure of a sort order or logic to make sure the link to the main page is always on top; etc.

My point being, of course, I'm all for making the computers do the work instead of us, with allowances to adjust for personal taste.
Title: Re: Default FoV
Post by: Yarn on July 07, 2016, 04:43:58 pm
I figured out a formula that should produce a good FOV value for any aspect ratio in the 5:4-16:9 range:

sqrt( FOV^2 * (4/3) / AR )

where:

FOV = the requested vertical field of view (default is 0.75)
AR = aspect ratio, represented as the result of width / height

Assuming FOV is 0.75, this is equivalent to -fov 0.75 for 4:3, about -fov 0.68 for 16:10, and about -fov 0.65 for 16:9.

To ensure that players with very wide displays don't lose too much of the top and bottom, AR should probably be capped at a certain value, such as 16/9.

Also, AR should be derived from the center resolution (center_w and center_h), not the main resolution (max_w and max_h). This way, players using multiple monitors will get an FOV that's appropriate for the center monitor (which might be narrower than 16:9) rather than the entire viewing area.
Title: Re: Default FoV
Post by: FrikgFeek on July 07, 2016, 06:24:37 pm
That's pretty good for adjusting FOV based on aspect ratio but I'd still prefer a straight out -fovdeg flag or something that does the full calculations and gives you the desired FOV in degrees. Not the vertical AoV in radians multiplied by some random number.
Title: Re: Default FoV
Post by: Yarn on July 07, 2016, 06:40:15 pm
Well, the formula doesn't have to (and probably shouldn't) be used if an explicit FOV is given, whether with -fov or -fovdeg.
Title: Re: Default FoV
Post by: Lykurgos88 on July 08, 2016, 02:30:04 am
Here is a comparison for your enjoyment:

Fov 30
(http://koti.mbnet.fi/olzie/Moebius/FSO_bughunt/fov/small_fov_30.bmp)

Fov 60
(http://koti.mbnet.fi/olzie/Moebius/FSO_bughunt/fov/small_fov_60.bmp)

Fov 75 (default)
(http://koti.mbnet.fi/olzie/Moebius/FSO_bughunt/fov/small_Default_fov_16_9.bmp)

Fov 90

(http://koti.mbnet.fi/olzie/Moebius/FSO_bughunt/fov/small_fov_90.bmp)
Title: Re: Default FoV
Post by: Kobrar44 on July 08, 2016, 04:13:00 am
Default fov gives you like 90 degree view angle horizontally, it is actually super standard. Unless you have a console. I don't think that is really too wide. Also, any sort of auto-adjusting could hurt mods with cockpits. I know these are badly implemented, but it's all we have right now.
Title: Re: Default FoV
Post by: FrikgFeek on July 08, 2016, 04:17:08 am
It's ~107 for 16:9 monitors and 96 for 16:10. Since most people are on 16:9 monitors I'd say 107 is really damn high. That's 17 degrees higher than the standard 90.

Or not, whoops.
Title: Re: Default FoV
Post by: Kobrar44 on July 08, 2016, 04:53:49 am
Why 107? Its 60 vertically. 60/2 = 30. tg30 = sqrt(3)/3. sqrt(3)/3*16/9 = 16sqrt(3)/27. arctg 16sqrt(3)/27 = 45.75 degrees. 2* 45.75 degrees = 91.5 degrees. 1.5 degree more than industry standard.

60 * 16/9 isn't really how trigonometry works. Unless FSO uses some crazy ass weird projection, but in that case, why would it. You need ~ 59 vertically to achieve 90 horizontally on 16:9.
Title: Re: Default FoV
Post by: AdmiralRalwood on July 08, 2016, 06:09:07 am
Why 107?
That's because -fov 0.75 in Freespace isn't the same as setting FOV to 75 in other games. Most games have a direct correlation between their FOV settting and the actual Field of View in degrees. In Freespace the default 0.75 FOV is actually something else. It's the vertical angle of view, in radians, multiplied by 1.39626348. for some reason.

First, you'd have to convert 0.75 radians to degrees which would be ~43 degrees.
Next you multiply that by 1.39626348 to get ~60 AoV. How this converts to FoV depends on your monitor's aspect ratio, but let's assume you're using a 16:9 widescreen one. Multiply 60 by (16/9) and you get 106.666...

The default Freespace FOV for a 16:9 monitor is actually ~107 degrees, which is quite high and this is why it causes "fisheye" distortions and makes big ships less impressive.

For a 16:9 monitor you need to divide whatever FOV you actually want by 142.2222 to get the number you need to use with the -fov flag. So if you want a 90 degree FOV you need to use -fov 0.6328.

On an old school 4:3 monitor the default FoV would be only 80, something that's much more natural.
Title: Re: Default FoV
Post by: FrikgFeek on July 08, 2016, 06:39:29 am
I thought FSO just uses some weird ass scaling but it seems to use standard hor+, took some screenshots with different resolutions to compare.

Still, doesn't change the fact that the default FOV causes fisheye distortions with big ships or skyboxes near the edge of the screen and it's pretty noticable. Just look at how weirdly stretched that herc2 is with the default FOV  in Lykurgos' screenshot. And if you fly near a big ship and turn up/down the stretching is extremely obvious and just looks bad. So maybe the problem isn't that the default FOV is too high as a value but that FSO just doesn't play nice with a standard 90 FOV.

But yeah, the default FOV is indeed just above 90 for a 16:9 resolution, sorry for messing that up. If you target a fighter right near the edge of the screen and then turn the view 90 degrees with the view right/left commands that fighter will still be close to the edge of your screen, meaning it's ~45 degrees or so from the centre to the edge. Seems FSO uses the videogame standard rectilinear projection, which is slightly sub-optimal at higher FOVs as you'll be looking up/down as much as you will left/right.


I mean, just look at THIS


Also I really need to reconfigure my lighting settings, make them more appropriate for the new PBR builds.
Title: Re: Default FoV
Post by: Flaser on July 08, 2016, 05:02:57 pm
Just a 5c: if fov could be changed on the fly, it'd be pretty much a "zoom"  feature. For default FS this isn't important, but would be useful for more "simmy" TCs with virtual cockpits.
Title: Re: Default FoV
Post by: AdmiralRalwood on July 08, 2016, 05:13:06 pm
Just a 5c: if fov could be changed on the fly, it'd be pretty much a "zoom"  feature. For default FS this isn't important, but would be useful for more "simmy" TCs with virtual cockpits.
This can already be done, both with SEXPs and with Lua scripting.
Title: Re: Default FoV
Post by: Yarn on July 08, 2016, 07:48:15 pm
In light of what Kobrar44 has said, here's my revised formula:

atan(sqrt( tan(FOV * Z)^2 * (4/3) / AR )) / Z

where:

FOV = the uncorrected requested vertical field of view in radians (default is 0.75)
AR = aspect ratio, represented as the result of width / height
Z = half of 1.39626348 (0.69813174)

Assuming FOV is 0.75, this new formula is equivalent to -fov 0.75 for 4:3, about -fov 0.69 for 16:10, and about -fov 0.66 for 16:9.

My previous notes apply to this formula too.