advicefere.blogg.se

Correct fov for 1920x1080
Correct fov for 1920x1080








correct fov for 1920x1080

At aspect rations less than 16:9 you’ll need horizontal bars like in your example picture, and for aspect ratios greater than 16:9 you’ll need vertical bars at the sides of the screen. Set it every time the camera viewport changes sizeĬamera:GetPropert圜hangedSignal("ViewportSize"):Connect(function()Īs for making sure the player can only every see enough of the screen to force a certain aspect ratio, you’ll have to adjust the black bars. Set the horizontal FoV at the start of the came Here's an example script showing how you can make sure the camera always has a fixed horizontal FoV, even if the player resizes the game window: - Keep a constant horizontal FoV. In that case, balls near the top and bottom edges of the screen will remain so when the screen is stretched. The opposite is the case if you keep the vertical FoV constant. Also notice how the two red balls are always near the left and right edges of the screen, no matter how it’s stretched. Notice how the horizontal FoV (in the output window) stays at 80 (because that’s what I set it to) between the two aspect- ratios. Here are some screenshots showing exactly what happens when setting the horizontal FoV instead of the vertical FoV: At aspect- ratio near 1 to 1: Local aspectRatio = getHorizontalFov(camera)/getVerticalFov(camera) Here are functions for setting either the vertical for horizontal FoV function setVerticalFov(camera, fov) In my tests, only the current version gave the correct result Here's a function for calculating the camera aspect ratio (apparently not the same as screen FoV?) function getAspectRatio(camera) Return g(math.acos(r0.Direction.Unit:Dot(r1.Direction.Unit))) return g(math.acos(r0.Direction.Unit:Dot(r1.Direction.Unit)))Ĭamera:ViewportPointToRay(viewSize.X*0, viewSize.Y/2, z),Ĭamera:ViewportPointToRay(viewSize.X*1, viewSize.Y/2, z) camera:ViewportPointToRay(viewSize.X/2, viewSize.Y*1, z) camera:ViewportPointToRay(viewSize.X/2, viewSize.Y*0, z), But it gives a good idea of how the calculation works.

correct fov for 1920x1080

Note that the getVerticalFov function is pretty redundant because you can just get that number with CurrentCamera.FieldOfView.

correct fov for 1920x1080

Here are functions for *calculating* the vertical and horizontal FoV, given a screen and a camera: The Camera.FieldOfView property sets the vertical FoV, so you’ll have to do some calculations to figure out which vertical FoV results in the desired horizontal FoV with the current screen aspect ratio. First of all, since your play field is mostly horizontal, you’ll probably want the horizontal FoV to be the same for all players, rather than the vertical FoV.










Correct fov for 1920x1080