@teo1978 Thanks, it is wired though, still a bug ... besides even change it to noise(x - 0.01, y - 0.01), the number it generated is still around 0.46875, while the Java version is much more random
Of course! I have no idea whether the values generated by processing.js make some sense (I mean, if they are valid Perlin noise according to a different "scale" or whatever) or if it's completely broken. But either way, as long as it does not generate exactly the same values as the Java version for any given input and seed, it's of course a bug.
The code given uses x,y so that means we're triggering sum += effect * (1 + generator.noise2d(k*x, k*y))/2; break;, with the definition for noise2d being:
function(x, y) {
var X = Math.floor(x)&255, Y = Math.floor(y)&255;
x -= Math.floor(x); y -= Math.floor(y);
var fx = (3-2*x)*x*x, fy = (3-2*y)*y*y;
var p0 = perm[X]+Y, p1 = perm[X + 1] + Y;
return lerp(fy,
lerp(fx, grad2d(perm[p0], x, y), grad2d(perm[p1], x-1, y)),
lerp(fx, grad2d(perm[p0 + 1], x, y-1), grad2d(perm[p1 + 1], x-1, y-1)));
}
These seem likely culprits:
x -= Math.floor(x);
y -= Math.floor(y);
After all, if the inputs are integer then the result of this is always going to be the same as (0,0)
@GoToLoop I've removed our comments that were veering off topic, as they contributed nothing to this specific bug report. As always, if you want to discuss the structure of the Processing.js project, its development process, what is missing, and how Pjs ties into Processing itself (short version: it doesn't), feel free to file one or more separate new issues for that. This issue is for tracking a bug in the code for p.noise.
Activity
teo1978 commented on May 30, 2016
Looks like it has to do with x and y being integer. If you add 0.99 instead of 1 in each iteration, the resulting values do change.
bofeng commented on May 30, 2016
@teo1978 Thanks, it is wired though, still a bug ... besides even change it to noise(x - 0.01, y - 0.01), the number it generated is still around 0.46875, while the Java version is much more random
teo1978 commented on May 30, 2016
Of course! I have no idea whether the values generated by processing.js make some sense (I mean, if they are valid Perlin noise according to a different "scale" or whatever) or if it's completely broken. But either way, as long as it does not generate exactly the same values as the Java version for any given input and seed, it's of course a bug.
Pomax commented on May 31, 2016
They should make sense, since they're proper Perlin noise, but it's possible that there are subtle bugs in the implementation on
processing-js/src/P5Functions/Math.js
Line 612 in c2b1466
processing-js/src/P5Functions/Math.js
Lines 509 to 577 in c2b1466
The code given uses x,y so that means we're triggering sum += effect * (1 + generator.noise2d(k*x, k*y))/2; break;, with the definition for noise2d being:
function(x, y) { var X = Math.floor(x)&255, Y = Math.floor(y)&255; x -= Math.floor(x); y -= Math.floor(y); var fx = (3-2*x)*x*x, fy = (3-2*y)*y*y; var p0 = perm[X]+Y, p1 = perm[X + 1] + Y; return lerp(fy, lerp(fx, grad2d(perm[p0], x, y), grad2d(perm[p1], x-1, y)), lerp(fx, grad2d(perm[p0 + 1], x, y-1), grad2d(perm[p1 + 1], x-1, y-1))); }These seem likely culprits:
After all, if the inputs are integer then the result of this is always going to be the same as (0,0)
Pomax commented on Jun 1, 2016
@GoToLoop I've removed our comments that were veering off topic, as they contributed nothing to this specific bug report. As always, if you want to discuss the structure of the Processing.js project, its development process, what is missing, and how Pjs ties into Processing itself (short version: it doesn't), feel free to file one or more separate new issues for that. This issue is for tracking a bug in the code for p.noise.