Perlin Noise library Module! (4D and octaves!)

Is there currently any way I can make it look more like real terrain with overhangs, instead of just caves?

local module = require(script.Parent.PerlinNoise)

for x = -64/2, 64/2 do
	wait()
	for y = -64/2, 64/2 do
		for z = -64/2, 64/2 do
			local noise = module.new({x, y, z, 4}, 15, 3, 0.5)
			if noise > .15 then
				local g = Instance.new("Part")
				g.Parent = workspace
				g.Size = Vector3.new(1, 1, 1)
				g.Position = Vector3.new(x, y, z)
				g.Anchored = true
			end
		end
	end
end

Helps a lot thanks! Again reply character minimum :confused:

From what I remember, generating a 2D heightmap (for the Y-axis), then two more heightmaps which indicate how far points on the original generation should move (on both X and Z) and create a new part there. The last two heightmaps should be setup to only move a small amount, so as not to create floating blobs. Even with this small amount of variation, it should make a difference in the end product.

If someone could simplify this, that would be nice.

also please include a tag so if tyridge doesn’t reply I won’t miss out. e.g. perlin

2 Likes

I think I figured it out now:

local module = require(script.Parent.PerlinNoise)

for x = -64/2, 64/2 do
	wait()
	for y = -64/2, 64/2 do
		for z = -64/2, 64/2 do
			local noise = (module.new({x, y, z, 4}, 15, 3, 0.5)) - (y/(64*2))
			if noise > .15 then
				local g = game:GetService("ServerStorage").Block:Clone()
				g.Parent = workspace
				g.Size = Vector3.new(1, 1, 1)
				g.Position = Vector3.new(x, y, z)
				g.Anchored = true
			end
		end
	end
end

The only obvious issues are, the grass texture is causing way to much lag, and There are way to many cliffs, and overhangs.

6 Likes

I don’t completely understand what you’re doing in the code sample…

Sorry for the confusing way I explained my method. I’ll get some pictures of what happened when I did it.
[Edit]


See how there’s extra terrain poking out that doesn’t occur in perlin noise? That’s just the same 2D heightmap, but with another heightmap used on it. The outcome of the second heightmap, instead of telling it the height of that terrain, tells it to create a new voxel of terrain that is positioned at (position on original heightmap) + (heightmap two gives X axis offset) + (heightmap three gives Z axis offset)

I got the idea from this video, which explained the same concept in 2D world generation. Jump to about 6:20.

1 Like

Made this using this module, absolutaly amazing!

I recommend this to everyone that want make world generation. No lag at all.

12 Likes

Is there any way I can change the seed without doing this:

???

What I do for seed is:

PerlinNoise.new({SEED, X, Z}, amplitude, octaves, persistence)

for the Y Axis I use perlin noise for the height:

for x = 0, 100, 1 do
     for z = 0, 100, 1 do
          part.Size = Vector3.new(4, math.floor(height * 100), 4);
          part.Position = Vector3.new(4 * x, height * 10 , 4 * z);
     end;
end;

Hope this helps!

1 Like

How do you do 3D Perlin noise if one of the arguments never change?

1 Like

What do you mean?

(30 characters)

To use the fourth dimension, you have to use both the x, y, z arguments, here is what they need to be:

for x = 1, 32 do
    for y = 1, 32 do
        for z = 1, 32 do
            local noise = (module.new({x, y, z, 4}, 15, 3, 0.5)) - (y/(64*2))
        end
    end
end

How I put in a seed, if all of the arguments are being used up?

1 Like

the SEED is the argument X, the X Axis is the Y axis and the Z argument is the Z Axis.

1 Like

What would be the y axis then? I’m assuming I would just offset the X axis / the seed?

The only reason (I think) the module creator put in the W argument was for putting in seeds in 3D perlin noise.

as most games don’t work in 4D :stuck_out_tongue:

2 Likes

I really like this! Would be cool to try to write procedural terrain generator with Roblox terrain using this.
Could end up looking pretty good.

I remember something like that from KonekoKitten’s channel when he showed someone ported the entire code of Minecraft to Roblox, perlin noise included. Sadly after the video the game was put under review because of copyright infringement.

Here is what i’m doing differently:

At around line 7 where I make the noise variable, and call module.new I also, subtract this from the number that the module returns:

(y/(64*2))

64 is basically the number that the for loop uses.

the Y Axis is the height generated from the perlin noise.

1 Like

For instance

local height = math.noise(x,y,z + (seed*1000)) -- probably doesn't need to be 1000
1 Like

Soo… You stacked two layers of 3D perlin noise to create a mixed effect? Could you run that method a few more times on different seeds?

also, I think it’s time we move this to private messages…

i know this is a dumb question but how can i calculate the grass position and the grass should be like the positon like in minecraft in order to make grass but only like 70 grasses each grass biome