Skip to content

How to use periodic fbm/rmf/turbulence? #3

@piranha771

Description

@piranha771

Hi, first thanks for the great work!

I need periodic 2D noise for a planet texture/heightmap.

My current solution is the following.
Take the UV and do this:

vec4 tile(in vec2 pos) {
	return vec4(
		offset + cos(pos.x * 2.0 * PI) * inResolution.x / (2.0 * PI),
		offset + cos(pos.y * 2.0 * PI) * inResolution.y / (2.0 * PI),
		offset + sin(pos.x * 2.0 * PI) * inResolution.x / (2.0 * PI),
		offset + sin(pos.y * 2.0 * PI) * inResolution.y / (2.0 * PI)
	);
}

The resulting 4D position is the used in 4D simplex noise as position. This leads to sweet tileable noise.
This is how I doing fractal brownian motion for example:

float fbm(in vec4 pos, in int octaves, in float frequency, in float lacunarity, in float persistence) {
	frequency /= inResolution.x;
	float currentWeight = 1.0;
	float totalWeights = 0.0;
	float result = 0.0;
	for (int i = 0; i < MAX_OCTAVES; i++) {
		if (i >= octaves) break;
		result += snoise(vec4(pos.x * frequency, pos.y * frequency, pos.z * frequency, pos.w * frequency)) * currentWeight;
		totalWeights += currentWeight;
		currentWeight *= persistence;
		frequency *= lacunarity;
	}

	return result / totalWeights;
}

But this is 4D noise computation complexity just for 2D noise. :(

I would like to use your periodic 2d simplex noise instead, but I have problems to use it in context of fractal brownian motion, ridgit multi fractals and turbulence.
This is my approach so far:

float fbm2(in vec2 pos, in int octaves, in float frequency, in float lacunarity, in float persistence) {
	float currentWeight = 1.0;
	float totalWeights = 0.0;
	float result = 0.0;
	for (int i = 0; i < MAX_OCTAVES; i++) {
		if (i >= octaves) break;
		result += psnoise((pos)*pow(2.0,float(i)),vec2(2.0,2.0)*pow(2.0, float(i))) * currentWeight;
		totalWeights += currentWeight;
		currentWeight *= persistence;
		frequency *= lacunarity;
	}

	return result / totalWeights;
}

This works, but completly skips the frequency and lacunarity parameters.
As soon as I take frequency or lacunarity in account (ex. multiply by position like in 4D fbm) its not tileable anymore :(

So my question is: is there a way to use periodic noise and be still able to set arbitrary frequency and lacunarity?
something like:

fbm2(pos, 6, 1.0, 2.13727, 0.507123)

This is how it looks with octaves as frequency and below my approach to use the parameters:

alt text

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions