Giter Site home page Giter Site logo

snoise(vec3) discontinuities about webgl-noise HOT 9 CLOSED

ashima avatar ashima commented on September 13, 2024
snoise(vec3) discontinuities

from webgl-noise.

Comments (9)

stegu avatar stegu commented on September 13, 2024 2

from webgl-noise.

stegu avatar stegu commented on September 13, 2024

from webgl-noise.

stegu avatar stegu commented on September 13, 2024

from webgl-noise.

rbnelr avatar rbnelr commented on September 13, 2024

from webgl-noise.

rbnelr avatar rbnelr commented on September 13, 2024

As you can see in the last image at the end of this comment, the values jump when the position crosses certain planes.
The jump is small, so it might only be visible when magnifying the the noise function by about a thousand.

This issue might not be visible when using the function as a source for color information or similar,
but it can show up as a very visible jump in some applications like isosurface generation for terrain.
At least when using the function as a base layer to generate large scale structures like mountains or large caverns in 3d.

Please let me know if you can reproduce the issue.

Following is a standalone shader that produces the images below.
Comment out the blocks other than the one you want to see.

Note: When you zoom in on the [A] image you can see that this shows up in
lots of places.

//#include "noise3D.glsl"

void main () {
	vec2 pos = gl_FragCoord.xy - vec2(700.0);

	//// [A] Shows the discontinuity as a clearly visible lines in the derivative, even visible in multiple places
	//pos /= 400.0;
	//float val = snoise(vec3(pos, 0.0) + vec3(300, -300, -300));
	//
	//float dx = dFdx(val * 100);
	//float dy = dFdy(val * 100);
	//frag_col = vec4(dx, dy, 0.0, 1.0);
	////

	//// [B] Same as above but zoomed in to one of the 'crosses' I also see in my raymarcher
	//pos += vec2(900.0, -1000.0);
	//pos /= 2000.0;
	//float val = snoise(vec3(pos, 0.0) + vec3(300, -300, -300));
	//
	//float dx = dFdx(val * 100);
	//float dy = dFdy(val * 100);
	//frag_col = vec4(dx, dy, 0.0, 1.0);
	////

	//// [C] Visualized without the derivative 
        pos += vec2(900.0, -1000.0);

	pos /= 2000.0;
	float val = snoise(vec3(pos, 0.0) + vec3(300, -300, -300));

	val -= 0.403;
	val *= 300.0;
	frag_col = vec4(val, val, val, 1.0);
	////
}

A
B
C

Edit: Deleted previous comment because typing it in gmail made it not have formatting.

from webgl-noise.

rbnelr avatar rbnelr commented on September 13, 2024

Indeed 0.5 fixes it on first inspection.
As far as I can tell your repo also uses 0.6 on that line.
I'm going to keep that line changed in my cope for now.

Anyway thanks for the quick reply.

from webgl-noise.

rbnelr avatar rbnelr commented on September 13, 2024

I guess I should keep this issue open until the code in this repo is changed.

from webgl-noise.

stegu avatar stegu commented on September 13, 2024

from webgl-noise.

stegu avatar stegu commented on September 13, 2024

At long last, I got around to fixing this issue in both repos (ashima/webgl-noise and stegu/webgl-noise) for both versions affected (noise3D.glsl and noise3Dgrad.glsl). Note that the change from 0.6 to 0.5 affects the range of output values, so I had to tweak the arbitrary final scaling factor as well, to cover the range [-1, 1] reasonably well.
Closing the issue.

from webgl-noise.

Related Issues (20)

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.