Triangulate perlin noise values

Hello.
I’ve recently written a landscape generator for my survival game.
I’ve made it generate the terrain in Parts with the cube shape (image), but how would I be able to replace the
cubes with triangles?

Here is the code that I currently have:

local freq = 0.1
local seed = os.clock()
local waterthreshold = 0.3
local mult = 5
for x = 1,50 do
	for y = 1,50 do
		local part = Instance.new("Part")
		print(x.." "..y.." freq: "..freq)
		local noise = math.noise(((x / mult) + seed) * freq, ((y / mult) + seed) * freq)
		print(noise)
		part.Anchored = true
		part.Size = Vector3.new(1 * mult,1 * mult,1 * mult)
		part.Position = Vector3.new(x * mult,0,y * mult) + Vector3.new(0,math.clamp(noise * mult,0,1 * mult),0)
		part.Parent = workspace
		
		if noise < waterthreshold then
			part.BrickColor = BrickColor.new("Baby blue")
			part.Position = Vector3.new(x * mult,waterthreshold,y * mult)
		else
			part.BrickColor = BrickColor.new("Sea green")
		end
	end
end

How would I triangulate the terrain made by those values?
Any support is appreciated.
Thank you.

1 Like

You can use EgoMoose’s function to create triangles out of 3 points:

Use it twice on each “square” formed from 4 vertices.

Example:

2 Likes

Could you be more specific? I can think of 3 things you could be trying to do:

  • generate a single mesh with triangle faces
  • make the map a 60° triangular grid and each tile is now a triangular prism
  • make right triangles everywhere there is currently a stair-stepped edge to smooth it out

Hello, I am attempting to generate a map using the following procedure:

  • Get noise values
  • Discard noise values below the water part threshold
  • Generate islands out of the remaining noise values

Oh. Why not use Roblox’s built in Terrain for that?

I need to integrate some things with the terrain, which the built in system does not allow me to do.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.