[MOD] Distant Terrain

A curated forum for approved mods. Users are unable to create new topics in this forum but can reply to existing topics. Please message a moderator to have your mod moved into this forum area.
User avatar
Nystul
Posts: 1377
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul » Sat Dec 22, 2018 8:56 am

Interesting, actually I don't understand what could cause post processing mod to have an effect on those bumps. Because I thought pp are only some image effect shaders which could decrease framerate a bit but in a constant way - independent of other stuff. So I would have expected it to lower your overall fps a bit but not increase the bumping.

Distant terrain is definitely causing bumps. That's expected with improved terrain since heights computation in terrainsampler takes some time for every map pixel (several milliseconds). When player moves to a new map pixel a bunch of new terrains needs to be created. This is done over the next couple of second (which causes the bumps)

Another thing that increases the bumps is terrain transition which again touches terrain heights and alters them to match border heights at the transition from near to far terrain.

I want to look into optimizing both issues. It might get a bit better but there will always be a noticeable bump.

I also think that floating origin update takes some time since many objects get their transforms updated.

User avatar
pango
Posts: 1417
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [MOD] Distant Terrain

Post by pango » Sat Dec 22, 2018 9:30 am

Are those computations, as I understand, done in a coroutine? Would using some thread so that it could be offloaded to any available CPU smooth the bumps? Difficult part being that Unity API itself is not thread safe...
(found this for example by looking for discussions on the matter)
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: [MOD] Distant Terrain

Post by Nystul » Sat Dec 22, 2018 10:07 am

I also planned to do stuff in threads - but the main problem is most things that take time are unity api calls and those are forbidden to be done in separate threads

User avatar
pango
Posts: 1417
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [MOD] Distant Terrain

Post by pango » Sat Dec 22, 2018 10:17 am

Exactly what I feared, so sad :(
It seems only the expensive version of Unity has a workaround for that, from what I understand you can prepare stuff like meshes offscreen then attach them to the main view when they're ready.
Let's hope their work on GPU-optimized terrain generation support will help...
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

Narf the Mouse
Posts: 758
Joined: Mon Nov 30, 2015 6:32 pm

Re: [MOD] Distant Terrain

Post by Narf the Mouse » Mon Dec 24, 2018 11:31 pm

As far as mesh creation goes, for multi-threading I create my own mesh class, and convert it to a Unity Engine mesh afterwards for any processing that has to be done Unity-side.

You can create this with just a thin class and List<T>, but I have two context-dependent recommendations:

1) Using a vertex-position-keyed dictionary with the value being the index for that vertex; this will allow automatically trimming out duplicate vertices. For this, I recommend using an "int Index GetOrAdd(Vector3 position)" pattern.
2) Using an adjacency list or dictionary; this will speed up a number of calculations.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

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

Re: [MOD] Distant Terrain

Post by Nystul » Sat Jan 26, 2019 11:31 am

new version 2.6.0 is available in first post of this thread.
It does not work with current builds because it is using Hazelnut's optimizations for terrain with unity job system.
It works with Hazelnut's branch for UpdateTerrain-onlyJobs and hopefully soon with interkarma's master when the pr is merged

User avatar
King of Worms
Posts: 2193
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: [MOD] Distant Terrain

Post by King of Worms » Sat Jan 26, 2019 12:43 pm

Awesome cooperation guys - the way its ment to be played :!:

User avatar
pango
Posts: 1417
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [MOD] Distant Terrain

Post by pango » Tue Jan 29, 2019 9:56 pm

I'm seeing a systematic resources unloading when crossing a new map pixel with Distant Terrain mod, that doesn't seem to happen otherwise:

Code: Select all

...
Unloading 2434 unused Assets to reduce memory usage. Loaded Objects now: 7958.
Total: 134.304000 ms (FindLiveObjects: 1.049000 ms CreateObjectMapping: 0.404000 ms MarkObjects: 122.909000 ms  DeleteObjects: 9.941000 ms)

Entering new map pixel X=413, Y=399
...
Problem is, this is slow, MarkObjects ~ 120ms is quite standard on my system, no matter how many resources can be collected.
I'm not sure what calls Resources.UnloadUnusedAssets()
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Midknightprince
Posts: 1097
Joined: Fri Aug 11, 2017 6:51 am
Location: San Antonio TX
Contact:

Re: [MOD] Distant Terrain

Post by Midknightprince » Sun Feb 03, 2019 5:41 pm

This works with the dev build for me
Check out my YouTube Channel!

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

Re: [MOD] Distant Terrain

Post by Nystul » Sun Feb 03, 2019 5:44 pm

pango wrote:
Tue Jan 29, 2019 9:56 pm
I'm seeing a systematic resources unloading when crossing a new map pixel with Distant Terrain mod, that doesn't seem to happen otherwise:

Code: Select all

...
Unloading 2434 unused Assets to reduce memory usage. Loaded Objects now: 7958.
Total: 134.304000 ms (FindLiveObjects: 1.049000 ms CreateObjectMapping: 0.404000 ms MarkObjects: 122.909000 ms  DeleteObjects: 9.941000 ms)

Entering new map pixel X=413, Y=399
...
Problem is, this is slow, MarkObjects ~ 120ms is quite standard on my system, no matter how many resources can be collected.
I'm not sure what calls Resources.UnloadUnusedAssets()
which build do you use?
which mod version do you use?

Post Reply