[MOD] Distant Terrain

A curated forum for compatible and maintained 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.
Post Reply
User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

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: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [MOD] Distant Terrain

Post by pango »

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)
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: [MOD] Distant Terrain

Post by Nystul »

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: 3347
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: [MOD] Distant Terrain

Post by pango »

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...
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: [MOD] Distant Terrain

Post by Narf the Mouse »

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: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

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: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: [MOD] Distant Terrain

Post by King of Worms »

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

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

Re: [MOD] Distant Terrain

Post by pango »

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()
Mastodon: @pango@fosstodon.org
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

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

Re: [MOD] Distant Terrain

Post by Midknightprince »

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

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

Re: [MOD] Distant Terrain

Post by Nystul »

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