Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Discuss Daggerfall Unity and Daggerfall Tools for Unity.
Post Reply
User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Interkarma »

For the last few days, I've been working on an upgrade to the floating origin system. This is available in a branch here and is almost complete as far as supporting the base game is concerned (any uncaught bugs aside).

What is it?
If the player moves far enough from origin position [0, 0, 0] then they will start to experience precision problems due to the limited ability of 32-bit floating point numbers to be simultaneously very large and very precise (they can only be one or the other). Precision problems are visible as jittery movement, jumpy shadows, and errors in physics system.

A floating origin setup is one way to minimise this problem by moving everything in the world back towards origin when the player moves far enough away. Daggerfall Unity's streaming world has supported floating origin for years now, but it only worked in the X-Z (horizontal) plane.

This means player can still encounter precision problems if they manage to go high enough. This is currently possible in the mountainous areas and is exacerbated if using a mod (like far terrain) that increases terrain vertical scale. The solution is to upgrade floating origin to support all three axes: X, Y, Z.

Why fix it now?
Besides correcting precision problems in mountainous regions right now, this upgrade unleashes the potential for more vertical play in future. I'm talking potential for deep oceans and floating cities, if that's your kind of thing.

There are already mod creators starting to add custom locations (see Uncanny_Valley's work) which has the potential to be broken by this kind of change. So I feel it's important to get this working before the game is much further developed and the mod scene grows to the point this issue is embedded and unworkable.

I just play the game without any mods - am I affected?
You shouldn't need to do anything. The base game will have all the support required to load save games created prior to floating y upgrade and will save new information after you upgrade. All of your loot and world state will be exactly where you left it. You just won't be able to take your new save games backwards reliably to an older version (which is already the case most of the time). I'll post more details on this before the upgrade drops in Live Builds. And you'll have a test build available well beforehand to check.

I play the game with mods - am I affected?
It's possible that mods created before the floating y upgrade will not function afterwards. Anything that places objects into the world with a fixed height coordinate will need to be made "floating y aware" to continue working. If your favourite mods continue to work, then awesome! Otherwise let the creator know so they can fix it.

I'm a developer or mod creator - what do I need to know?
The gist of things is the Y axis is no longer tied to a static elevation in world. The player can be 10km in the air and still positioned at [0, 0, 0] in scene. So if you need to place something into the world there are a few rules to follow.
  • Dungeons - Are instanced separately to exterior world, nothing special to do here.
  • Interiors - When placing objects into interiors, please place them relative to the interior parent object (i.e. transform.parent=interiorParent.transform and transform.localPosition=relativePosition). If serializing objects to interiors, you will also need to store local position and possibly some other state to correctly restore. If you are already serializing state for interiors, the deserialization process will need to handle migration of legacy Y positions in addition to saving floating Y aware positions. I've already developed some solutions for this that can be adapted to your work.
  • Exteriors - The biggest change is that terrain elevation is no longer equal to Y position and terrain object placement can change as the player levitates up and down, enters and exits buildings, or saves and loads a game. Objects placed to exterior will need to account for StreamingWorld.WorldCompensation to get correct position in scene. And if deserializing to exterior, you need to know the previous and current WorldCompensation values to calculate actual placement. Some of you are probably already familiar with this. The only real difference is now all three axes X, Y, Z need to be observed.
Don't Panic
This probably sounds more dramatic than it really is. At the end of the day, we just need to calculate a few new vertical positions. We're talking simple addition and subtraction here, nothing major. And I'm taking care of the base game so everything just keeps working on that front.

Developers and mod creators can test the floating Y branch in progress right now and see how well their mods work. If your mod isn't storing storing objects in the world, or it's already using things like relative coordinates in interiors, then probably very little needs to be changed. And keep in mind this is still a work in progress.

Please use this thread for any questions and I'll do my best to support you all to help get your mods ready. Once I've wrapped up the first pass at floating y support, I'll make a test build available for everyone to check and help find problems before changes are merged to master.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Interkarma »

Test Build
A Floating-Y test build is now ready. This is only available for Windows 64-bit and Linux Universal at this time.

Edit: Test builds have been removed and new builds will be issued to Live Builds.

Notes
  • I recommend not saving over your current games for now. Instead create new saves for Floating-Y tests. Depending on any problems found, you might need to delete any saves created by this test build.
  • When loading an exterior save for the first time, your character will be placed on the ground near to where you were last. Saves in interiors and dungeons should place you exactly where you were as if nothing happened. Future saves will be as normal.
  • If your old save is on your ship, the return transport method (selecting SHIP a second time from transport menu) will throw you into the abyss right now. Just use fast travel menu to travel back to world. Future transports to and from ship will work normally.
  • If you have a teleport Anchor set from your old save it will be ignored if you try to Teleport. The only exception is teleporting within same dungeon (e.g. back to exit point). The next time you set an anchor after upgrade it will work as normal.
  • Loot dropped to exteriors in older saves might have trouble being positioned in world depending on terrain elevation and sampler used. I'm not so worried about resolving this, as loot dropped outside is volatile anyway. If you do happen to be near loot you want to keep - please pick it up again before loading save in new version. As with the other items, future saves will be as normal.
Note: Items in strikethrough above are resolved in current version.

Feedback
All feedback is welcome. I'm particularly interested in knowing how everyone goes with mods so we can get the ball rolling on upgrading mods to be compatible with Floating-Y prior to being merged into main game.

Hopefully not too many problems and we can merge everything after a few rounds of testing.

Thank you all!

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Interkarma »

RESERVED

User avatar
Mosin Nagant
Posts: 40
Joined: Thu Nov 16, 2017 2:06 am
Location: Land of the Free, Home of the Brave

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Mosin Nagant »

Interkarma wrote: Wed May 23, 2018 12:24 pm For the last few days, I've been working on an upgrade to the floating origin system. ...
I'm such a stickler for precision, so I'm glad to see this. I have a profound and extreme (some would say unreasonable or unfounded) hatred of floating-point imprecision.

I had a super basic programming assignment for college this last semester where my professor wanted me to make a calculator in Java using either floats or doubles. "Forget that," I said. "I'm using 64bit ints." Setting up division and multiplication was insanely difficult, but having a dozen decimal points of pure accuracy when dividing, or adding .0001 to 100,000,000 and having it result in exactly 100,000,000.0001 made it all worth it. I await the day when someone develops an integer-based rendering engine. :lol:
Previously known as LordMordecai on DXL forums

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Nystul »

I am one of those developers that are really looking forward to this feature. Whoever experienced shadow issues with far terrain mod when in high mountain areas will love this feature ;)
I will soon work on an updated far terrain version ;)

fyi, see these screenshots of the shadow issues:

Image

Image

User avatar
Mosin Nagant
Posts: 40
Joined: Thu Nov 16, 2017 2:06 am
Location: Land of the Free, Home of the Brave

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Mosin Nagant »

Nystul wrote: Thu May 24, 2018 10:11 am fyi, see these screenshots of the shadow issues:
Interesting. Can't say that I've run into this, or at the very least, haven't noticed it. I wonder how the floating point imprecision causes this.
Previously known as LordMordecai on DXL forums

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Interkarma »

I've updated test build in second post. This version fixes all the items above and everything should "just work" as far as the base game goes. I was even able to support old teleport anchors and ship transport return.

This will be very close to the final version merged into master. I'll keep testing to try and find problems, and if you guys can report on your experiences that will be great.

If we don't hit any roadblocks within the next week, I'll merge and drop new builds.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Interkarma »

I've added a Floating-Y Linux Universal test build to second post of this topic now.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Floating Origin Y Upgrade - Users, Devs, and Script Modders Please Read

Post by Interkarma »

I haven't had any developer feedback with any problems, and my testing has been successful as well. I'm merging this to master today so it will be in next round of builds for general testing.

Post Reply