Merge pull request #444 from PolyhedralDev/dev/fix-lerp

6.4.3 - Fix lerp (urgent)
This commit is contained in:
dfsek 2023-12-24 02:15:54 -07:00 committed by GitHub
commit ab60f14ff1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 29 deletions

View File

@ -1,8 +1,8 @@
preRelease(true) preRelease(true)
versionProjects(":common:api", version("6.4.2")) versionProjects(":common:api", version("6.4.3"))
versionProjects(":common:implementation", version("6.4.2")) versionProjects(":common:implementation", version("6.4.3"))
versionProjects(":platforms", version("6.4.2")) versionProjects(":platforms", version("6.4.3"))
allprojects { allprojects {

View File

@ -24,7 +24,7 @@ public class BrownianMotionSampler extends FractalNoiseFunction {
for(int i = 0; i < octaves; i++) { for(int i = 0; i < octaves; i++) {
double noise = input.noise(seed++, x, y); double noise = input.noise(seed++, x, y);
sum += noise * amp; sum += noise * amp;
amp *= MathUtil.lerp(1.0, Math.min(noise + 1, 2) * 0.5, weightedStrength); amp *= MathUtil.lerp(weightedStrength, 1.0, Math.min(noise + 1, 2) * 0.5);
x *= lacunarity; x *= lacunarity;
y *= lacunarity; y *= lacunarity;
@ -42,7 +42,7 @@ public class BrownianMotionSampler extends FractalNoiseFunction {
for(int i = 0; i < octaves; i++) { for(int i = 0; i < octaves; i++) {
double noise = input.noise(seed++, x, y, z); double noise = input.noise(seed++, x, y, z);
sum += noise * amp; sum += noise * amp;
amp *= MathUtil.lerp(1.0, (noise + 1) * 0.5, weightedStrength); amp *= MathUtil.lerp(weightedStrength, 1.0, (noise + 1) * 0.5);
x *= lacunarity; x *= lacunarity;
y *= lacunarity; y *= lacunarity;

View File

@ -36,7 +36,7 @@ public class PingPongSampler extends FractalNoiseFunction {
for(int i = 0; i < octaves; i++) { for(int i = 0; i < octaves; i++) {
double noise = pingPong((input.noise(seed++, x, y) + 1) * pingPongStrength); double noise = pingPong((input.noise(seed++, x, y) + 1) * pingPongStrength);
sum += (noise - 0.5) * 2 * amp; sum += (noise - 0.5) * 2 * amp;
amp *= MathUtil.lerp(1.0, noise, weightedStrength); amp *= MathUtil.lerp(weightedStrength, 1.0, noise);
x *= lacunarity; x *= lacunarity;
y *= lacunarity; y *= lacunarity;
@ -54,7 +54,7 @@ public class PingPongSampler extends FractalNoiseFunction {
for(int i = 0; i < octaves; i++) { for(int i = 0; i < octaves; i++) {
double noise = pingPong((input.noise(seed++, x, y, z) + 1) * pingPongStrength); double noise = pingPong((input.noise(seed++, x, y, z) + 1) * pingPongStrength);
sum += (noise - 0.5) * 2 * amp; sum += (noise - 0.5) * 2 * amp;
amp *= MathUtil.lerp(1.0, noise, weightedStrength); amp *= MathUtil.lerp(weightedStrength, 1.0, noise);
x *= lacunarity; x *= lacunarity;
y *= lacunarity; y *= lacunarity;

View File

@ -25,7 +25,7 @@ public class RidgedFractalSampler extends FractalNoiseFunction {
for(int i = 0; i < octaves; i++) { for(int i = 0; i < octaves; i++) {
double noise = Math.abs(input.noise(seed++, x, y)); double noise = Math.abs(input.noise(seed++, x, y));
sum += (noise * -2 + 1) * amp; sum += (noise * -2 + 1) * amp;
amp *= MathUtil.lerp(1.0, 1 - noise, weightedStrength); amp *= MathUtil.lerp(weightedStrength, 1.0, 1 - noise);
x *= lacunarity; x *= lacunarity;
y *= lacunarity; y *= lacunarity;
@ -43,7 +43,7 @@ public class RidgedFractalSampler extends FractalNoiseFunction {
for(int i = 0; i < octaves; i++) { for(int i = 0; i < octaves; i++) {
double noise = Math.abs(input.noise(seed++, x, y, z)); double noise = Math.abs(input.noise(seed++, x, y, z));
sum += (noise * -2 + 1) * amp; sum += (noise * -2 + 1) * amp;
amp *= MathUtil.lerp(1.0, 1 - noise, weightedStrength); amp *= MathUtil.lerp(weightedStrength, 1.0, 1 - noise);
x *= lacunarity; x *= lacunarity;
y *= lacunarity; y *= lacunarity;

View File

@ -33,10 +33,10 @@ public class PerlinSampler extends SimplexStyleSampler {
int x1 = x0 + PRIME_X; int x1 = x0 + PRIME_X;
int y1 = y0 + PRIME_Y; int y1 = y0 + PRIME_Y;
double xf0 = MathUtil.lerp(gradCoord(seed, x0, y0, xd0, yd0), gradCoord(seed, x1, y0, xd1, yd0), xs); double xf0 = MathUtil.lerp(xs, gradCoord(seed, x0, y0, xd0, yd0), gradCoord(seed, x1, y0, xd1, yd0));
double xf1 = MathUtil.lerp(gradCoord(seed, x0, y1, xd0, yd1), gradCoord(seed, x1, y1, xd1, yd1), xs); double xf1 = MathUtil.lerp(xs, gradCoord(seed, x0, y1, xd0, yd1), gradCoord(seed, x1, y1, xd1, yd1));
return MathUtil.lerp(xf0, xf1, ys) * 1.4247691104677813; return MathUtil.lerp(ys, xf0, xf1) * 1.4247691104677813;
} }
@Override @Override
@ -64,14 +64,14 @@ public class PerlinSampler extends SimplexStyleSampler {
int y1 = y0 + PRIME_Y; int y1 = y0 + PRIME_Y;
int z1 = z0 + PRIME_Z; int z1 = z0 + PRIME_Z;
double xf00 = MathUtil.lerp(gradCoord(seed, x0, y0, z0, xd0, yd0, zd0), gradCoord(seed, x1, y0, z0, xd1, yd0, zd0), xs); double xf00 = MathUtil.lerp(xs, gradCoord(seed, x0, y0, z0, xd0, yd0, zd0), gradCoord(seed, x1, y0, z0, xd1, yd0, zd0));
double xf10 = MathUtil.lerp(gradCoord(seed, x0, y1, z0, xd0, yd1, zd0), gradCoord(seed, x1, y1, z0, xd1, yd1, zd0), xs); double xf10 = MathUtil.lerp(xs, gradCoord(seed, x0, y1, z0, xd0, yd1, zd0), gradCoord(seed, x1, y1, z0, xd1, yd1, zd0));
double xf01 = MathUtil.lerp(gradCoord(seed, x0, y0, z1, xd0, yd0, zd1), gradCoord(seed, x1, y0, z1, xd1, yd0, zd1), xs); double xf01 = MathUtil.lerp(xs, gradCoord(seed, x0, y0, z1, xd0, yd0, zd1), gradCoord(seed, x1, y0, z1, xd1, yd0, zd1));
double xf11 = MathUtil.lerp(gradCoord(seed, x0, y1, z1, xd0, yd1, zd1), gradCoord(seed, x1, y1, z1, xd1, yd1, zd1), xs); double xf11 = MathUtil.lerp(xs, gradCoord(seed, x0, y1, z1, xd0, yd1, zd1), gradCoord(seed, x1, y1, z1, xd1, yd1, zd1));
double yf0 = MathUtil.lerp(xf00, xf10, ys); double yf0 = MathUtil.lerp(ys, xf00, xf10);
double yf1 = MathUtil.lerp(xf01, xf11, ys); double yf1 = MathUtil.lerp(ys, xf01, xf11);
return MathUtil.lerp(yf0, yf1, zs) * 0.964921414852142333984375; return MathUtil.lerp(zs, yf0, yf1) * 0.964921414852142333984375;
} }
} }

View File

@ -25,10 +25,10 @@ public class ValueSampler extends ValueStyleNoise {
int x1 = x0 + PRIME_X; int x1 = x0 + PRIME_X;
int y1 = y0 + PRIME_Y; int y1 = y0 + PRIME_Y;
double xf0 = MathUtil.lerp(valCoord(seed, x0, y0), valCoord(seed, x1, y0), xs); double xf0 = MathUtil.lerp(xs, valCoord(seed, x0, y0), valCoord(seed, x1, y0));
double xf1 = MathUtil.lerp(valCoord(seed, x0, y1), valCoord(seed, x1, y1), xs); double xf1 = MathUtil.lerp(xs, valCoord(seed, x0, y1), valCoord(seed, x1, y1));
return MathUtil.lerp(xf0, xf1, ys); return MathUtil.lerp(ys, xf0, xf1);
} }
@Override @Override
@ -49,14 +49,14 @@ public class ValueSampler extends ValueStyleNoise {
int y1 = y0 + PRIME_Y; int y1 = y0 + PRIME_Y;
int z1 = z0 + PRIME_Z; int z1 = z0 + PRIME_Z;
double xf00 = MathUtil.lerp(valCoord(seed, x0, y0, z0), valCoord(seed, x1, y0, z0), xs); double xf00 = MathUtil.lerp(xs, valCoord(seed, x0, y0, z0), valCoord(seed, x1, y0, z0));
double xf10 = MathUtil.lerp(valCoord(seed, x0, y1, z0), valCoord(seed, x1, y1, z0), xs); double xf10 = MathUtil.lerp(xs, valCoord(seed, x0, y1, z0), valCoord(seed, x1, y1, z0));
double xf01 = MathUtil.lerp(valCoord(seed, x0, y0, z1), valCoord(seed, x1, y0, z1), xs); double xf01 = MathUtil.lerp(xs, valCoord(seed, x0, y0, z1), valCoord(seed, x1, y0, z1));
double xf11 = MathUtil.lerp(valCoord(seed, x0, y1, z1), valCoord(seed, x1, y1, z1), xs); double xf11 = MathUtil.lerp(xs, valCoord(seed, x0, y1, z1), valCoord(seed, x1, y1, z1));
double yf0 = MathUtil.lerp(xf00, xf10, ys); double yf0 = MathUtil.lerp(ys, xf00, xf10);
double yf1 = MathUtil.lerp(xf01, xf11, ys); double yf1 = MathUtil.lerp(ys, xf01, xf11);
return MathUtil.lerp(yf0, yf1, zs); return MathUtil.lerp(zs, yf0, yf1);
} }
} }