Voxel Terrain Generator RESCRIPTED (biomes based on height now using roblox's terrain)


  • I made a script that does what the 3d voxel script did, but without any blocks!
    What this means:

    • Less lag
    • Bigger terrain (There still is a limit)
    • More variety

    SCRIPT

    Screenshots:
    alt text
    alt text


  • Don't worry about the "choppy-ness" of the terrain. That just happens when the camera is far away. The terrain is actually smooth.


  • How did you do this in game? I thought terrain can only be generated in game


  • @XXDLOLXDDILMOA Yes you can use roblox's terrain generator or you can use this one. I think this one is much faster.
    EDIT: It works both in-game and as a plugin.


  • @develop_d
    I ment in studio lol, also do u have a link for it?


  • @XXDLOLXDDILMOA Click on the SCRIPT link for it. Should be at the top of the page. Put the script inside ServerScriptService


  • Nice script!

    In your script you requested performance tips; here's a more efficient version:

    local ms = 1500 -- Map size (limit before timeout is around 3000)
    
    local amp = 200 -- How high/low the terrain goes (this affects biomes)
    local scale = 150 -- How big the biomes are (the higher the bigger)
    local blockScale = 4 -- How blocky the terrain looks
    local waterLevel = -1 -- self explanatory
    
    local terrainThickness = 2 -- was 30
    local waterThickness = 2 -- was 80
    
    local seed = math.random(-10000, 10000)
    print(seed)
    
    local done = Instance.new("BoolValue")
    done.Name = "TerrainDone"
    done.Value = false
    done.Parent = workspace
    
    local v3 = Vector3.new
    local cf = CFrame.new
    local terrain = workspace.Terrain
    local size = v3(blockScale, terrainThickness, blockScale)
    
    local pauseEvery = 0.1 -- pause every this many seconds
    local nextPause = tick() + pauseEvery
    local stepped = game:GetService("RunService").Stepped
    local begin = tick()
    for x = -ms/2, ms/2 do
    	if tick() >= nextPause then
    		stepped:Wait()
    		nextPause = tick() + pauseEvery
    	end
    	local px = blockScale * x
    	for z = -ms/2, ms/2 do
    		local pz = blockScale * z
    		local height = (math.noise(x/scale, z/scale, seed) * amp) + waterLevel
    		if height <= waterLevel then
    			terrain:FillBlock(cf(v3(px, waterLevel - waterThickness/2, pz)), v3(size.X, waterThickness, size.Z), Enum.Material.Water)
    		else
    			local material = -- I encourage playing with the values after the "+"
    				height < waterLevel + 4 and Enum.Material.Sand
    				or height < waterLevel + 80 and Enum.Material.Grass
    				or Enum.Material.Snow
    			terrain:FillBlock(cf(v3(px, height, pz)), size, material)
    		end
    	end
    end
    print("Done in", math.floor((tick() - begin)*100)/100,"sec")
    done.Value = true
    

    Efficiency improvements:

    • Localized some of the variables/functions (this could be done even more, though I'm not sure if the impact is noticeable)
    • Used 'and or' instead of 'if'
    • Skipped using a part
    • Kept track of time passed (with 'tick') instead of 'wait' (if you move the relevant code into the 'z' for loop you can make the terrain generate even larger)
    • (The biggest speed improvement) Make the terrain only 2 thick (though sometimes holes can generate depending on what settings you use)
Log in to reply
 

Looks like your connection to Scripting Helpers was lost, please wait while we try to reconnect.