Archaegeo / DualUniverseLuaIssues

DualUniverse LUA Issue Tracking
GNU General Public License v3.0
5 stars 0 forks source link

Game FOV settings are off from the actual camera FOV [Bug][Game Settings][Camera] #4

Closed matt225022 closed 3 years ago

matt225022 commented 3 years ago

In action of changing the game settings for resolution or fov sometimes the fov recorded in the settings becomes inaccurate to the game view settings. This affects the lua api for returning the one that is accurate to the camera.

From some testing when this occurs the fov value is offset by 10000th of your screen height + width of a degree This does not quite match up with the value in settings.yaml which is different from the game settings so something weird is going on and is hard to account for with lua.

Here is the example settings file:

system:  # System settings
  vsync: false  # Enable vertical synchronization
  cameraSettings:  # Player camera settings
    znear: 0.1  # Near distance
    fov: 37  # Vertical FOV (we present horizontal FOV to players, beware these are not the same)

Here is how that setting looks in game: image

EasternGamer commented 3 years ago

Could the game be rounding the converted value? Also, correction, it's 10000th, not 1000th.

matt225022 commented 3 years ago

Right, 10000th vs 1000th. Also note that this difference is not 100% accurate and is only there when the game file settings is not updated after the game has been loaded.

EasternGamer commented 3 years ago

Investigated it a bit more and it seems it's not rounding.

NQ-Deckard commented 3 years ago

An example construct with Lua and reproduction steps would be most useful for me to have someone look into this.

EasternGamer commented 3 years ago

An example construct with Lua and reproduction steps would be most useful for me to have someone look into this. ::pos{0,0,2515341.2798,-99129540.5639,-1117555.6128} The above is the position of my ship, the Merdian. The board on the left attached to the gold console is the programming board in question.

Once the board is activated, four relevant values are printed. The projection matrix X and Y value which correspond to the diagonal of the matrix and the calculated vertical and horizontal FOVs (in degrees for reading purposes, radians used internally)

The code which produces this is found in the bottom start filter under library. The below code is an extract of it.

    -- Projection infomation
    --- Screen Parameters
    local width = getWidth()/2
    local height = getHeight()/2

    --- FOV Parameters

    --local offset = (width + height) / 5000
    local offset = 0
    local hfovRad = rad(getFov() + offset)
    local tanFov = tan(hfovRad/2)*height/width

    --- Matrix Subprocessing
    local aspect = width/height
    local near = width/tanFov
    local top = near * tanFov
    local bottom = -top;
    local left = bottom * aspect
    local right = top * aspect

    --- Matrix Paramters
    local x0 = 2 * near / (right - left)
    local y0 = 2 * near / (top - bottom)

    local projectionMatrix = {  -- Not included in the original code, just to give you an idea of how it looks.
        x0, 0, 0,  0,
        0, y0, 0,  0,
        0,  0, N, N,
        0,  0, N,  0
    }
    --N values are not applicable to the end calculation as they should only related, or so I have observed,
    --to if something should be viewed and shouldn't manipulate the XY coordinates on screen.
    print('X0: '..x0)
    print('Y0: '..y0)
    print('Vert. FOV: ' .. deg(tanFov))
    print('Horiz. FOV: ' .. getFov())

To use the program to reproduce the issue, activate the board. Then, calibrate your pitch, or just jetpack, press alt-1 on any planet marker, turn your character so that the marker is close to the edge of the screen, and you should see the effect. When changing your in-game field of view, also remember to restart the programming board as it does not check if that changes.

The example below shows a 120-degree FOV. image Looking straight on is perfect. image Looking down to the Y edge, at which point the marker stops changing position. (The in-game marker will stop moving at this point, so I don't go further) image This image is the same as the above, but for the X edge of my screen. image This is combining both and placing both markers in the X and Y edge of my screen. image

It is possible that I made a mistake somewhere in the projection, as I have said previously in the Lua chat. So, I mostly want you to verify if the values match what the game is using or if maybe the waypoint markers are actually inaccurate to some degree.