How can I apply a "Perlin" noise to my giant voxel sphere generator?

I have made a script that can generate huge voxel spheres above the Terrain:FillBall() size limit, and would like to know how to apply 3D Noise on it to make structures such as Mountains or caves.

local steps = 0
local layer = 0
local position
local diameter = 2500

position = CFrame.Angles(math.rad(steps),math.rad(-layer),math.rad(0))*,0,math.abs(diameter/2))
workspace.Terrain:FillBlock(position +,-diameter/2,0),,30,10), Enum.Material.Grass)
steps = steps + 1
until steps == 360
steps = 0
layer = layer + 1
until layer == 270

I have found topics slightly similar to this one, but it was mostly from other engines and different terrain generation methods.

Any help on this or tips to improve this script would be very appreciated!


Caves aren’t my area of expertise but there are quite a few things I can say about Terrain Generation.

The math.noise function in Roblox takes 3 parameters, X, Y and the Seed of the noise. The X and Y represent the point within 2D space in which you are trying to obtain the noise value, and the seed is what helps you add variation to those values. After putting these through, it’ll return a value that is proportionate to how high a part of terrain should be. All you have to do then is multiply that by the max amount of studs you want terrain to reach (almost like a height limit) and you’ll have the top position of your terrain. You can use this height for things such as material selection, checking whether or not its got a high altitude and if it should have rock or snow, or if its got a low altitude and it should be water.

From there, if you were to make a predefined square region of terrain, you could use two for loops to iterate through a region’s X and Y coordinates (so like a for x = 0, maxChunkSize do for y = 0,maxChunkSize do style thing).

If we say that for each square, an X and Y coordinate will take up about 4x4, stud wise, then you’d apply this, alongside a predefined minimum height (so basically where you’d want terrain to stop generating), and the height value that’s returned by the noise function to create the region in which you’ll render terrain. I would keep in mind though that especially in the case of noise generation, you may have issues with smoothing over the terrain you’ve generated, especially at the edges or the cut off in which terrain is not generated.

There are plenty of other things that would need to be considered when applying it to your scenario, but for the sake of explaining noise, I hope the strategy above will give you some ideas as to how you can apply noise.

The above is an application for using the terrain system that Roblox provides, but there’s also a helpful resource here that not only covers the use of noise in tiled terrain, but also Cave Generation:


If you want all your sphere to be a giant perlin noise sphere, you could just use lookvector.

Perlin noise uses 3 parameters, 2 of them are decimals and the third one is a random number most commonly known as seed.

To do it, you just have to make the cframe’s lookvector to point outwards the sphere, then you just simply set the fillblock cframe to the original cframe + the cframe’s lookvector * noise.

local noise = math.noise(steps/200,layer/100,0) * math.random(100,200) --Just multiplies the noise so that it is not flat–

workspace.Terrain:FillBlock(position + position.LookVector * noise,,30,100,),Enum.Material.Grass)

Note that your code is very unefficient, that is due to the fact that it has to cover the same half of the sphere to fully generate the sphere.