I have a few issues currently I am still figuring out how to fix.
Tears appear in my terrain due to how I load chunks probably.
The chunk loading works fine, but I am trying to make chunks that are near load first before loading the others further away.
My current way of doing it is basically this:
spawn(function() wait() while true do wait(1) for x = 0, renderdist.Value do wait(0.5) local campos = cam.CFrame.Position local x2 = x * abcs local fl = campos+v3(-x2,0,-x2) local fr = campos+v3(x2,0,-x2) local bl = campos+v3(-x2,0,x2) local br = campos+v3(x2,0,x2) --i loop for i = 0, (renderdist.Value) - x do local i2 = i * abcs loadchunk(fl + v3(-i2, 0, 0)) loadchunk(fl + v3(0, 0, -i2)) loadchunk(fr + v3(i2, 0, 0)) loadchunk(fr + v3(0, 0, -i2)) loadchunk(bl + v3(-i2, 0, 0)) loadchunk(bl + v3(0, 0, i2)) loadchunk(br + v3(i2, 0, 0)) loadchunk(br + v3(0, 0, i2)) rs.Heartbeat:Wait() end --i loop end end end)
This isn’t the whole script (it’s like 3 modules btw) but this is where I load nearby chunks first and then the ones further away.
Also, the chunkloading is multi-threaded so the tears can’t be because of chunks not loading in time/too slow.
I’m not certain what the best way to load nearby chunks first is (in a circle pattern that slowly expands as you walk).
Second issue I’m running into is the fact that there are too many mountains and don’t really know a way to adjust perlin noise to generate flat areas as well.
mod.noisey = function(pos) local spos = tostring(pos) local key = noiseycache[spos] if key then return v3(pos.x, pos.y + key, pos.z) end noiseycache[spos] = (noise( --Noise 1 pos.x / steepnessx, seed, pos.z / steepnessz ) ) * amplitude noiseycachesize = noiseycachesize + 1 return v3(pos.x, pos.y + noiseycache[spos], pos.z) end
ignore the key/table part, that’s just for caching in case I expand the function and it becomes heavier/more expensive.
I’m not certain how to modify this so it generates not only hills but also flat ground and mountains.
Currently just 2 issues.
Too many hills and inefficient nearby chunk loading causing tears in the distance.
(Nothing is wrong with the chunk loading itself, it snaps to positions correctly and does not overlap.)
Help would be very appreciated, looking forward on making this generate more than just grass terrain.
I eventually even want to generate randomly placed houses, cities, roads, etc, maybe even a desert or snow wonderland.