Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Generating smooth cube terrain using perlin noise?

Asked by 5 years ago

Recently decided to do some light scripting and decided to go with terrain generation, cubic terrain, to be exact, meaning terrain is split into 4x4x4 cubes, I searched around for tutorials about this but they were either completely different or just overall non-existent :P

If you could provide me with a simple method on how to do this and an example if possible, that'd be greatly appreciated.

0
I am actually doing that now. However I have only been able to create layers of Grass Dirt, Stone, Larva, And bed. I haven't been able to develop any type of land yet. vamps108 0 — 5y

1 answer

Log in to vote
0
Answered by
Y_VRN 246 Moderation Voter
5 years ago
Edited 5 years ago

This question made me look for my old thing. I eventually found it, though I assure you this ain't really focused on, so imperfections may occur.


local depthTable = {} -- DO NOT EDIT local x,z = 100,100 local amplitude = 160 local height = 200 -- DO NOT EDIT local minimum = 5 local sea level = 0 -- 0 = normal local smoothness = 30 local groundheight = 5 local heightOffset = 100 local seed = 0 -- DO NOT EDIT local naturalAmp = true -- DO NOT EDIT local natAMP = 1 -- DO NOT EDIT local plainsBiomeSize = 60 local built = 0 -- DO NOT EDIT local depthNo = 0 -- DO NOT EDIT local total = 0 -- DO NOT EDIT local depthCurrent = 0 -- DO NOT EDIT function developVoxelTerrain() seed = math.randomseed(tick()) local seedA = math.random()*100 for X = 1,x do for Z = 1,z do if naturalAmp then natAMP = math.noise(X/(smoothness*plainsBiomeSize),Z/(smoothness*plainsBiomeSize),seedA) end total = x*z local no = (heightOffset + math.floor(math.noise(X/smoothness,Z/smoothness,seedA)*amplitude*natAMP)*4)/4-20 + groundheight table.insert(depthTable,table.getn(depthTable)+1,no) built = built + 1 end wait() end for R = 1,x do for T = 1,z do depthCurrent = depthCurrent + 1 local current = depthTable[depthCurrent] depthNo = depthNo + 1 for P = 1, current do local part = Instance.new("Part") part.CFrame = CFrame.new(R*4,(minimum*4)+((P*4)),T*4) part.Size = Vector3.new(4,4,4) part.Color = Color3.fromRGB(168,51,48) part.Anchored = true part.Name = "TestSoil" part.Material = "Slate" part.Parent = workspace end end wait() end depthNo = 0 for X = 1,x do for Z = 1,z do depthNo = depthNo + 1 local part = Instance.new("Part") part.Size = Vector3.new(4,4,4) part.Color = Color3.fromRGB(40,255,20) part.Anchored = true part.Name = "TestGrass" part.Position = Vector3.new(X*4,(minimum*4)+depthTable[depthNo]*4+4,Z*4) part.Material = "Grass" part.Parent = workspace total = x*z built = built + 1 end wait() end end developVoxelTerrain()

I have long abandoned fiddling with perlin noise so I can't provide you details and simple methods. Sorry.

0
I realized my script is somewhat heavy. Meh, it's just three-step process. Y_VRN 246 — 5y
Ad

Answer this question