FractalNoise

Generates a fractal noise using LOVE's noise functions

-- returns a fractal noise value in the range [-1.0, 1.0]
function genFractalNoise2(x, y, iter, factor, f)
	val = love.math.noise(x, y)*2-1
	f = f or 2
	iter = iter or 1
	factor = factor or 0.5
	local n = 0
	while n < iter-1 do
		val = val + (love.math.noise(x*n^f, y*n^f)*2-1)*factor^n
		n = n + 1
	end
	return math.max(math.min(val, 1.0), -1.0)
end

-- returns a fractal noise value in the range [-1.0, 1.0]
function genFractalNoise3(x, y, z, iter, factor, f)
	val = love.math.noise(x, y, z)*2-1
	f = f or 2
	local n = 0
	while n < iter-1 do
		val = val + (love.math.noise(x*n^f, y*n^f, z*n^f)*2-1)*factor^n
		n = n + 1
	end
	return math.max(math.min(val, 1.0), -1.0)
end

Contributors