add FractalBrownianMotion2D function
needs testing
This commit is contained in:
+17
@@ -556,4 +556,21 @@ function simplex.Seed(seed)
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO test functionality
|
||||
function simplex.FractalBrownianMotion2D(x, y, octaves, lacunarity, gain)
|
||||
octaves = octaves or 4
|
||||
lacunarity = lacunarity or 2
|
||||
gain = gain or 0.5
|
||||
|
||||
local total, amplitude, frequency, peak_amplitude = 0, 1, 1, 0
|
||||
for i = 1, octaves do
|
||||
total = total + amplitude * simplex.Noise2D(x * frequency, y * frequency)
|
||||
peak_amplitude = peak_amplitude + amplitude
|
||||
amplitude = amplitude * gain
|
||||
frequency = frequency * lacunarity
|
||||
end
|
||||
|
||||
return total / peak_amplitude -- normalize to [-1, 1]
|
||||
end
|
||||
|
||||
return simplex
|
||||
|
||||
Reference in New Issue
Block a user