Questions about :FillBlock() and terrain generation

I saw this the other week:

And i was reminded of the idea i had months ago. The generator script used the same method i used months ago, and i saw how smooth the terrain was and i thought: “So i could have just used the logic from this script”… always read the documentations people :wink:

So i got to work both making the example code shorter and more flexible, and making my own. But then i noticed something:

Example code:

Mine:

Mine has theese… staircase, step like structure to it, and the example one doesn’t. Even at extreme angles the example code generates smooth terrain, and mine makes rice fields.

Both use :FillBlock() and 4x4x4 blocks.

Is there something i completely ignored? Why is it like this? How can i fix this? I spent a month last time trying to figure it out and a week this time.

Any help is appreciated. If you need the code just reply. it’s not that much, anyone can make it

You’re filling with blocks so smaller blocks and smaller distances between each vertex would reduce the jaggedness. Might also be some issues with how you’re generating the amplitude for the terrain–the changes in position may be too sharp.

Here is an example that creates a 3 dimensional example that displays how the same terrain can look different depending on how exactly it is generated.

local workspace = game:GetService("Workspace")

local terrain = workspace:WaitForChild("Terrain")

for i = 1, 10 do
	for j = 1, 10 do
		for k = 1, 10 do
			local size = 1 * j
			local rough = 10 * i

			for x = 1, 50, size do
				for z = 1, 50, size do
					local y = math.noise(x / rough, 1, z / rough) * k
					
					terrain:FillBlock(
						CFrame.new(x, y, z) * CFrame.new(-65 * i, 25 * k, -65 * j),
						Vector3.new(size, 1, size),
						Enum.Material.Grass
					)
				end
			end
		end
	end
end

My code’s “base blocks”


example:

Not that much difference.

And the example code performed well even if the amplitude was extreme.

Smaller blocks did the same.

I put your code in studio and it has the same jagged edges, even on smaller amplitudes like mine:
See the step like structure?

And here is the example with more amlitude just for giggles:

I’m ashamed i didn’t think of this earlier but to anyone reading this in the future:
Add 2 to the size of the block, so if you do 1x1x1 do 3x3x3.
In my case it’s 6 x HeightOfLayer x 6.

Why 2? Well each block has to overlap so… logic.

Results?

Imma just… go lie down for a bit. This was too much.

Well it’s a quick fix to be fair. Not perfect.

EDIT: more overlap is better up to a point.

:rage: :rage: :rage: :rage: :rage:

1 Like