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 scalable generation #26

Merged
merged 4 commits into from
Feb 2, 2021
Merged

feat: Enable scalable generation #26

merged 4 commits into from
Feb 2, 2021

Conversation

4Denthusiast
Copy link
Contributor

This requires the engine PR MovingBlocks/Terasology#4452 . It gives an example of what that engine feature is capable of, so I would recommend testing them together.

@skaldarnar
Copy link
Contributor

Could you elaborate a bit how the scale parameter is going to be used, or rather, how it should be implemented? Scaling the overall terrain looks like a super simple use case, but I'm wondering how this should apply to something like the tree facet...

@4Denthusiast
Copy link
Contributor Author

Generally, the scaled versions of facets should be whatever is needed to make the final result visually similar, so if the tree facet is generated with a scale of 2, then for each position in the facet, the provider should try to ensure that there is a tree there iff there is a tree in any of the corresponding 8 blocks in the unscaled version, and if the scale is so large that individual trees wouldn't be visible, then something like generating trees in heavily forested areas in general (which are then converted to just 1 leaf block each) might be appropriate, until the scale gets so large that even the forest shouldn't be visible.

@skaldarnar
Copy link
Contributor

💡 I think I have to read up on how the respective noise functions behave. The overall description definitely makes sense...

Given that, it might be that the computation effort for LOD chunks is the same as for the detailed chunk (determine on block level whether there's a tree or not), and then scale down to lower level of detail (is there at least one tree here, are there enough trees in this area to form a forest, ...). Maybe the tree facet is already a pretty tough thing to support, because of the randomness in the L-Systems and that it probably is harder to figure out an approximation of the blocks set later on...

@4Denthusiast
Copy link
Contributor Author

It would be possible to generate a scaled tree facet without all that much computational expense (except that the wider trees that require a 5 block flat area to spawn on wouldn't work as well), if we change the algorithm for placing trees in the unscaled version. Rather than having a separate random sample for every surface block, if instead we start at a scale level where each block has quite a high probability of containing a tree, then if there is a tree at that scale, recursively subdivide the area using the conditional probabilities of there being a tree in each octant, given that there is a tree in at least one of them (with some correction for the correlation too). This way the computation is the same whatever the actual scale is (up to the point where pretty much every surface block probably contains a tree anyway).

This algorithm would not be perfect at always placing trees in the right place, but it would get it right most of the time, and that should be enough for LOD chunks. It would be more complicated than the current one for scale = 1, but there is also an efficiency advantage in not calculating the noise for every position. It would be even more suitable for features like volcanoes or flying islands, which are less common (which makes this algorithm more efficient) and have less conditions on suitable locations for them to appear (which makes this algorithm more correct).

@skaldarnar skaldarnar changed the title Enable scalable generation feat: Enable scalable generation Feb 2, 2021
@skaldarnar skaldarnar merged commit 1415e4c into develop Feb 2, 2021
@skaldarnar skaldarnar deleted the feat/scalable branch February 2, 2021 18:14
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.

2 participants