Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable extreme render distances using LOD chunks #4452

Merged
merged 9 commits into from
Feb 2, 2021

Conversation

4Denthusiast
Copy link
Contributor

@4Denthusiast 4Denthusiast commented Feb 1, 2021

Generate less detailed meshes of far away chunks without actually loading them. I have been able to test it with an effective view distance of around 8000 chunks in each direction just fine without using particularly much memory. In order for this feature to be enabled, the world generator needs to support scalable generation. This can be added for a subset of facet providers and rasterizers (the others will just be ignored), so it is backwards-compatible. This has been implemented for the default world generator in Terasology/CoreWorlds#26 (although scaled trees have not been implemented yet).

There is room for improvement in the scheduling of loading and unloading LOD chunks (gaps appear while the game waits for replacements to be generated), and this PR also introduces some new occasional lighting bugs, but I thought I'd just get it merged and fix those later.

This resolves #319.

@4Denthusiast
Copy link
Contributor Author

At the highest LOD settings, it looks pretty much like the view distance is infinite.
image

Copy link
Contributor

@DarkWeird DarkWeird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks nice.
Lod... look a bit strange at first look. but when you walking closer. you began understand it.
image
image

also holes between lodchunks unload and normal chunks loading.
image
Can you do something with it?

nearby = new ClosenessComparator(center);
neededChunks = new PriorityBlockingQueue<>(11, nearby);
for (int i = 0; i < 2; i++) {
Thread thread = new Thread(this::createChunks, "LOD Chunk Generation " + i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use separate thread, please.
You reimplement TaskMaster now :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a central ThreadPool or ExecutorService to use for this sort of thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's the ThreadManagerSubsystem, but that doesn't support tasks with priorities like this, and there's TaskMaster, which is basically just a slightly more abstract way of doing the same thing.

@DarkWeird
Copy link
Contributor

Some more screens.
image
I see chunk bounds..

I don't like level difference at water surface between scales.
image

Ensure that the sky is visible even at the lowest view distances.
Remove unused code from the AABB renderer.
Reduce the amount of gaps between chunks.
@4Denthusiast
Copy link
Contributor Author

4Denthusiast commented Feb 1, 2021

Some more screens.
image

The issue where, when the player is at certain heights, there is a gap between the ocean and the shore is now fixed.

I don't like level difference at water surface between scales.
image

I still haven't been able to replicate this. There is actually a difference in the water level, because the correct water height is, for sufficiently large scales, not actually a possible height for blocks, it's just usually not this visible because the sides of the water blocks don't render for me at the boundary.

Copy link
Member

@skaldarnar skaldarnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feeling standing in a world with this near infinity view distance is amazing! It's hard to stop posting screenshots of this ^^

I'd like to the this stabilize a bit more in the future (holes in generated chunks, removing LOD chunks before the replacement is ready), and I'm curious how to extend this to other structures (trees, buildings) and even hand-made changes to the world at some point 😍

Terasology-210201223028-2560x1376
Terasology-210201224546-2560x1376

(The code looks fine to me, but I haven't looked at it in detail...)

package org.terasology.world.generation;

public interface ScalableFacetProvider extends FacetProvider {
void process(GeneratingRegion region, float scale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the facet providers assume something about the scale, e.g., the range the value is in? Can they query the min/max scale somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the scale is never less than 1, or more than about 1000 (because the LODs slider doesn't go past 10). Do you think that some sort of pre-computed stuff in setSeed or initialize might be useful? I can't think of any use cases for that information (except that a ScalableFacetProvider might rely on the scale never being less than 1, but that's more of an algorithmic simplicity thing, and being able to query it wouldn't really help).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about a facets that would want to use a simplified model (e.g., just 3 stages of LOD or something like that). However, I think I was missing some pieces about how this works, and that we are not generating placeholder meshes that get scaled to the correct size, but instead try to generate the world (features) in lower resolution.

I think those are two essentially different ways of doing the LOD effect (your's keeping the blockiness, while the other approach could do more interpolation/low-poly effect). I'm totally fine with what we have here in this PR, just trying to get my head around this. 😉

DarkWeird
DarkWeird previously approved these changes Feb 2, 2021
@skaldarnar skaldarnar changed the title Enable extreme render distances using LOD chunks feat: Enable extreme render distances using LOD chunks Feb 2, 2021
@skaldarnar skaldarnar merged commit 8a1532d into develop Feb 2, 2021
@skaldarnar skaldarnar deleted the feat/lodChunks branch February 2, 2021 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new rendering approach for far distance chunks to support very far rendering distances
5 participants