How to make an Island using Perlin Noise

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.