Coder Social home page Coder Social logo

stegu / webgl-noise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashima/webgl-noise

467.0 467.0 38.0 307 KB

GLSL procedural noise functions compatible with WebGL

License: MIT License

Makefile 0.78% Shell 0.26% C 85.97% GLSL 10.32% HTML 1.42% JavaScript 1.18% CSS 0.07%

webgl-noise's People

Contributors

jcbernack avatar redblobgames avatar stegu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webgl-noise's Issues

How to use periodic fbm/rmf/turbulence?

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

Patent protection

It would be helpful to clarify in the readme whether or not the 3D and 4D simplex noise functions use the implementation covered by Perlin's U.S. Patent 6,867,776.

Noise3D pixelization bug [?]

Hi, I use the simplex noise 3d in my work. I noticed that the higher time you give the more pixelized the image becomes:

Time = 0.3:
image
Time = 2313.0 (with zoomed image)
image
Time = 9000000.0
image

Is there any way to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.