Page 40 of 60

Re: [MOD] Distant Terrain

Posted: Sat Dec 22, 2018 8:56 am
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.

Re: [MOD] Distant Terrain

Posted: Sat Dec 22, 2018 9:30 am
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)

Re: [MOD] Distant Terrain

Posted: Sat Dec 22, 2018 10:07 am
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

Re: [MOD] Distant Terrain

Posted: Sat Dec 22, 2018 10:17 am
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...

Re: [MOD] Distant Terrain

Posted: Mon Dec 24, 2018 11:31 pm
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.

Re: [MOD] Distant Terrain

Posted: Sat Jan 26, 2019 11:31 am
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

Re: [MOD] Distant Terrain

Posted: Sat Jan 26, 2019 12:43 pm
by King of Worms
Awesome cooperation guys - the way its ment to be played :!:

Re: [MOD] Distant Terrain

Posted: Tue Jan 29, 2019 9:56 pm
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()

Re: [MOD] Distant Terrain

Posted: Sun Feb 03, 2019 5:41 pm
by Midknightprince
This works with the dev build for me

Re: [MOD] Distant Terrain

Posted: Sun Feb 03, 2019 5:44 pm
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?