How to make an Island using Perlin Noise

The modified code I got from the yt tutorial, One question, I guess this make a random noise map, but how do I combine it with another noise map? etc like this, I have been struggling with this for 2 days, I have tried some formula by myself but it corrupt the map eventually

My not working code for the gradient map

if chunkPosZ < Center and chunkPosX < Center then
offset = (chunkPosZ-1)(chunkPosX-1)/Center
else
if chunkPosZ > Center and chunkPosX > Center then
offset = (2
Center+(-1*(chunkPosZ+chunkPosX)))/Center
else
if chunkPosZ >= Center and chunkPosX <= Center then
offset = (2Center+(-1(chunkPosZ-chunkPosX)))/Center
else
if chunkPosZ <= Center and chunkPosX >= Center then
offset = (2Center+(-1(chunkPosX-chunkPosZ)))/Center
else
offset = 2
end
end
end

To combine them you just preform arithmetic on the numerical values, clamp if needed.

How to put this gradient map into numerical values? Also, the problem with the map is that the map starts building from the edges instead of the center, and It comes with connections between wedges and trees which means editing the height of the map after structuring might corrupt the map? It’s gonna be a big appreciation if you can modify this code :smiley:

Map structuring:
https://gyazo.com/ccfd2dab0e25f92039bdacfb7147f21a?token=f61baae301aa735c6550a6a503ffb694

Code Noise Mapping Part:

posGrid[x][z] = newV3(
CHUNK_SCALE.X * chunkPosX + xWIDTH_SCALE,
noise((x + (X-1) * chunkPosX)/TERRAIN_SMOOTHNESS, (z + (Z-1) * chunkPosZ)/TERRAIN_SMOOTHNESS, SEED) * HEIGHT_SCALE,
CHUNK_SCALE.Z * chunkPosZ + z
WIDTH_SCALE
)

If you generated the gradient map it would already be described by numerical values.

Do you mean like generating it manually from extension software? I haven’t made a map using another software, all of them are made by coding

You can generate them in Roblox, it’s literally just an array of numbers.

Oh really, where can i generate them? Is there a plugin for that?

I don’t think you understand, you can use math and code to generate a 2D array of numerical values assuming your noise map is also represented as a 2D array of numerical values. The combination of two maps will result in a new map aka another 2D array of numerical values. You don’t need external software or plugins.

Yeah I’m having problem combining 2 maps, Idk what I have to combine ( etc noise, CFrame ) Also I can’t combine CFrame cuz it will corrupt the map since its built with wedges. If i combie noise ( sometimes negative noise become positive )

You just do mathematical operations on the numerical values.

And the map become like this with gaps between wedges

You should probably make a function that calculates values between 0 and 1. Then just multiply the corresponding noise value with this value. And do that before creating the wedges.

What’s your discord? I’ll send you the code there so you get more details, Mine Bloxvin#4131

Maybe a code example which might help

I’m sorry I really don’t want to get back into this stuff, lots of other projects.

1 Like

I’m not sure if this function will give good results.

local arraySize = -- how many noise values there are in a row

local function getVal01(xScale, zScale)
    return (math.sin(1 - math.abs(xScale * math.pi / 2)) + math.sin(1 - math.abs(zScale * math.pi / 2)) / 2
end

for xi, zArray in ipairs(noise2dArray) do
    for zi, noiseValue in ipairs(yArray) do
        zArray[zi] = noiseValue * getVal01(xi / (arraySize * .5), zi / (arraySize * .5))
    end
end

Edit: I tested this and noticed that it doesn’t work the way I thought it would.
Edit: Here’s a function that creates a circle-like shape when drawn using 100 x 100 frames (0 = black, 1 = white). I wrote the function in a module script. You can get more higher or more lower values by using the easing functions.

local CircularGrayscale = {}

local function sineEase(val)
	return math.sin(val * math.pi / 2)
end

local function cosEase(val)
	return 1 - math.cos(val * math.pi / 2)
end

-- input values between -1 and 1, output value between 0 and 1
function CircularGrayscale.GetVal(xScale, yScale)
	xScale, yScale = math.abs(xScale), math.abs(yScale)
	local squaredDistToEdgeInXZDir = 1 + math.min(xScale, yScale)^2
	local linear = 1 - math.sqrt( (xScale^2 + yScale^2) / squaredDistToEdgeInXZDir )
	
	local val = linear ^ squaredDistToEdgeInXZDir
	--val = sineEase(val)
	--val = cosEase(val)
	return val
end

return CircularGrayscale

2 Likes

Can we DM, Bloxvin#4131 in discord

Discord is not letting me in. It’s saying that new login location detected (I haven’t used it for quite a while).

I seem to be a bit late to this. Although I don’t have any code examples, I can say that what you are looking for is called a “falloff map” which brings the terrain gradually into the water rather than it just suddenly stopping.