Hello, I trying to implement 3D noise for hills and cliffs and other stuff like that. I generate a 2D noise for a base map but when I’m generating 3D noise I’m getting a result like that. If you can help me then write thanks for fast help and here is a photo of my work and what im want.
PS. I’m not using chunks in this because I need all-terrain rendered and I’m adding to this falloff map.
------------------------------------------------------------ Photos ------------------------------------------------------------
What I want
This photo is form this video: https://www.youtube.com/watch?v=ehhI29laMFE
What I have (This white cubes is 3D noise)
This is how i generate 3D noise
function Terrian.Generate3DNoise()
local Offset = Vector3.new(0, 0, 0)
local OctavesOffsets = {}
for i = 1, Info.Octaves do
local OffsetX = Info.Seed + Offset.X
local OffsetY = Info.Seed + Offset.Y
local OffsetZ = Info.Seed + Offset.Z
OctavesOffsets[i] = Vector3.new(OffsetX, OffsetY, OffsetZ)
end
for X = 1, Info.Size do
Noise3D[X] = {}
for Y = 1, Info.Size do
Noise3D[X][Y] = {}
for Z = 1, Info.Size do
local Amplitude = 4
local Frequency = 1
local NoiseHeight = 0
for i = 1, Info.Octaves do
local SampleX = (X - HalfSize) / Info.Resolution * Frequency + OctavesOffsets[i].X
local SampleY = (Y - HalfSize) / Info.Resolution * Frequency + OctavesOffsets[i].Y
local SampleZ = (Z - HalfSize) / Info.Resolution * Frequency + OctavesOffsets[i].Z
local PerlinValue = math.noise(SampleX, SampleY, SampleZ)
NoiseHeight = NoiseHeight + PerlinValue * Amplitude
Amplitude = Amplitude * Info.Persistance
Frequency = Frequency * Info.Lacunarity
end
Noise3D[X][Y][Z] = NoiseHeight
end
RunService.Heartbeat:Wait()
end
end
print("Rendered!")
end
This is for add noise life
Terrian.GenerateFallOfMap()
Terrian.GenerateNoise()
Terrian.Generate3DNoise()
Terrian.GenerateMaterial()
for X = 1, Info.Size do
for Z = 1, Info.Size do
Noise[X][Z] = math.clamp(Noise[X][Z] - FallOfMap[X][Z], 0, 1)
local Height = Noise[X][Z]
Terrian.GenerateTerrain(Height * Info.Height, X, Z, MaterialMap[X][Z])
--local Part = Instance.new("Part", workspace)
--Part.Size = Vector3.new(1, 1, 1)
--Part.Anchored = true
--local Color = ColorMap[X][Z]
--Part.Position = Vector3.new(X, Height, Z)
--Part.Color = Color3.new(Color.R, Color.G, Color.B)
for Y = 1, Info.Size do
local Density = Noise3D[X][Y][Z] - FallOfMap[X][Z]
local Density_Modifier = (Height - Y) / 30
Density = Density + Density_Modifier
if Density >= 0 then
local Part = Instance.new("Part", workspace)
Part.Anchored = true
Part.Size = Vector3.new(1, 1, 1)
Part.Position = Vector3.new(X, Y + Info.Min_Height, Z)
end
end
end
RunService.Heartbeat:Wait()
end