-
Notifications
You must be signed in to change notification settings - Fork 34
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
Improve worldgen #79
Comments
Ideally, the worldgen would actually be implemented in Lua, as part of the mod. That way mods can not only create their own terrain, but also you can stack mods to modify the world. Of course, that comes at a certain speed cost and creating an API for that is non-trivial in my opinion, especially when considering the placement of decorations and structures like trees, which might overlap into neighboring, not yet created, chunks. Also noise functions should be wired to the Lua API, if not already done so. I have to say that I always struggled with finding a good solution for all that, and didn't come that far either. My approach was to simply hand the newly created chunk to the mods and let them modify it, but as I said, that comes with a few drawbacks. Regarding caves, I'm not sure whether you've done research in that area already, but Minecraft uses Perlin Worms for their cave generation. Another interesting approach, for which I can't find the source anymore, is to combine two 3D noises and only use their overlaps. Something I've implemented here...which, might be hard to read, to be honest. The basic idea is to have noise A and B, and if the value of A falls into a certain range and the value of B falls into a certain range, it's a cave. With perlin noise this does produce tunnels which might or might not connect if you use middle values, like -0.5 to 0.5 (on a -1/1 scale). |
I completely agree that worldgen should be implemented in Lua. About caves, Minecraft doesn't use Perlin Worms for cave generation but instead a whole bunch of randomness and sin/cos shenanigans. I tried to read the code to understand and noticed that they're basically carving tunnels with a random direction. Unfortunately, I don't understand the whole thing enough to be able to make my own implementation yet. I'd be interested to know more about your way tho if it is able to carve tunnels. |
Oh sorry, I missed your reply. Oh dear I've finally found the article I was talking about! Was driving me crazy...anyway, as I've already typed it, here is a short explanation from my end anyway (in pseudo-Lua-code): local noiseA = PerlinNoise(someParams)
local noiseB = PerlinNoise(similarParams)
-- Values have the range of -1/+1.
local valueA = noiseA.get(x, y, z)
local valueB = noiseB.get(x, y, z)
if (isBetween(valueA, -0.1, 0.1)) and isBetween(valueB, -0.1, 0.1)) {
-- Air
else
-- Rock
end What we're basically doing is that we are using ridged perlin noise for the caves. By combining two noises we receive a more winding and interrupted cave system, but can still control its properties very well. For example one could stretch it to receive higher or less high caves. Additional noises can be added and so forth. |
I already tried using ridged perlin noise for the caves here but the results were not so great. Carved tunnels have the advantage of having coherent elevation and direction. Take this screenshot for example, they're not coherent: |
What do you mean with "coherent" here? You mean that they should not branch like this? |
Do you mean the elevation of the tunnels themselves or the elevation of the terrain? Regarding the terrain, I can very well imagine that one could offset the used noises based on the heightmap in that area. That way the tunnels would always mimic the overworld elevation. |
Of the tunnels themselves, they shouldn't care about overworld elevation. |
Oh, now I think I get what you mean. You mean that the tunnels are going up and down with no direction in either. I never thought about that. I'm not sure whether that can be solved with my suggestion. I mean, my suggestion makes this a little bit better as it combines two ridged noises, creating less of a network and more of single tunnels, but still they will move in any direction in space. If you want tunnels that primarily lead downward as they progress, I'm not sure how to hammer the noise in such a shape. |
Worldgen should use a seed(World generation should use a seed #116)Cave tunnels(Cave tunnels #118)The text was updated successfully, but these errors were encountered: