Hello. I want to make a terrain generator with smooth terrain. But, when I try to generate some terrain, the terrain looks kinda “sharp”, or “blocky” in some areas. Here is an example:
Here is my code:
local dataTable = {}
local hasVisited = {} -- Ignore this line, it was from a greedy mesher that I made a year or two ago
local rand = Random.new()
local randNum = rand:NextNumber(-10e6, 10e6)
local terrainRegion = Region3.new(Vector3.new(-512, -128, -512), Vector3.new(512, 128, 512))
terrainRegion = terrainRegion:ExpandToGrid(4)
local terrain = workspace.Terrain
local terrainOccupancies = {}
local terrainMats = {}
for x = 1, 256 do
task.wait()
if not terrainOccupancies[x] then
terrainOccupancies[x] = {}
terrainMats[x] = {}
end
for y = 1, 64 do
if not terrainOccupancies[x][y] then
terrainOccupancies[x][y] = {}
terrainMats[x][y] = {}
end
for z = 1, 256 do
local terrainData = math.max(math.noise(x / 16, (y + randNum) / 16, z / 16) - ((y - 32) / 16), 0)-- > 0 and true or false
--[[if terrainData then
terrain:FillBlock(CFrame.new(x*4, y*4, z*4), Vector3.new(4, 4, 4), Enum.Material.Grass)
end]]--
terrainOccupancies[x][y][z] = terrainData
terrainMats[x][y][z] = Enum.Material.Grass
end
end
end
terrain:WriteVoxels(terrainRegion,4,terrainMats,terrainOccupancies)
I originally used the :FillBlock()
method, but it looked kinda blocky, and so I then tried to use :WriteVoxels()
, which makes the terrain looks slightly less blocky, but, in some areas it looks blockier than other areas. Is there any way I can make the terrain look less blocky?