Skip to content

Commit

Permalink
Merge pull request PolyhedralDev#444 from PolyhedralDev/dev/fix-lerp
Browse files Browse the repository at this point in the history
6.4.3 - Fix lerp (urgent)
  • Loading branch information
dfsek authored Dec 24, 2023
2 parents da4ab8b + d8ba9e1 commit ab60f14
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
preRelease(true)

versionProjects(":common:api", version("6.4.2"))
versionProjects(":common:implementation", version("6.4.2"))
versionProjects(":platforms", version("6.4.2"))
versionProjects(":common:api", version("6.4.3"))
versionProjects(":common:implementation", version("6.4.3"))
versionProjects(":platforms", version("6.4.3"))


allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public double getNoiseRaw(long seed, double x, double y) {
for(int i = 0; i < octaves; i++) {
double noise = input.noise(seed++, x, y);
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;
y *= lacunarity;
Expand All @@ -42,7 +42,7 @@ public double getNoiseRaw(long seed, double x, double y, double z) {
for(int i = 0; i < octaves; i++) {
double noise = input.noise(seed++, x, y, z);
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;
y *= lacunarity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public double getNoiseRaw(long seed, double x, double y) {
for(int i = 0; i < octaves; i++) {
double noise = pingPong((input.noise(seed++, x, y) + 1) * pingPongStrength);
sum += (noise - 0.5) * 2 * amp;
amp *= MathUtil.lerp(1.0, noise, weightedStrength);
amp *= MathUtil.lerp(weightedStrength, 1.0, noise);

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

x *= lacunarity;
y *= lacunarity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public double getNoiseRaw(long seed, double x, double y) {
for(int i = 0; i < octaves; i++) {
double noise = Math.abs(input.noise(seed++, x, y));
sum += (noise * -2 + 1) * amp;
amp *= MathUtil.lerp(1.0, 1 - noise, weightedStrength);
amp *= MathUtil.lerp(weightedStrength, 1.0, 1 - noise);

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

x *= lacunarity;
y *= lacunarity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public double getNoiseRaw(long sl, double x, double y) {
int x1 = x0 + PRIME_X;
int y1 = y0 + PRIME_Y;

double xf0 = MathUtil.lerp(gradCoord(seed, x0, y0, xd0, yd0), gradCoord(seed, x1, y0, xd1, yd0), xs);
double xf1 = MathUtil.lerp(gradCoord(seed, x0, y1, xd0, yd1), gradCoord(seed, x1, y1, xd1, yd1), xs);
double xf0 = MathUtil.lerp(xs, gradCoord(seed, x0, y0, xd0, yd0), gradCoord(seed, x1, y0, xd1, yd0));
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
Expand Down Expand Up @@ -64,14 +64,14 @@ public double getNoiseRaw(long sl, double x, double y, double z) {
int y1 = y0 + PRIME_Y;
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 xf10 = MathUtil.lerp(gradCoord(seed, x0, y1, z0, xd0, yd1, zd0), gradCoord(seed, x1, y1, z0, xd1, yd1, zd0), xs);
double xf01 = MathUtil.lerp(gradCoord(seed, x0, y0, z1, xd0, yd0, zd1), gradCoord(seed, x1, y0, z1, xd1, yd0, zd1), xs);
double xf11 = MathUtil.lerp(gradCoord(seed, x0, y1, z1, xd0, yd1, zd1), gradCoord(seed, x1, y1, z1, xd1, yd1, zd1), 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(xs, gradCoord(seed, x0, y1, z0, xd0, yd1, zd0), gradCoord(seed, x1, y1, z0, xd1, yd1, zd0));
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(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 yf1 = MathUtil.lerp(xf01, xf11, ys);
double yf0 = MathUtil.lerp(ys, xf00, xf10);
double yf1 = MathUtil.lerp(ys, xf01, xf11);

return MathUtil.lerp(yf0, yf1, zs) * 0.964921414852142333984375;
return MathUtil.lerp(zs, yf0, yf1) * 0.964921414852142333984375;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public double getNoiseRaw(long sl, double x, double y) {
int x1 = x0 + PRIME_X;
int y1 = y0 + PRIME_Y;

double xf0 = MathUtil.lerp(valCoord(seed, x0, y0), valCoord(seed, x1, y0), xs);
double xf1 = MathUtil.lerp(valCoord(seed, x0, y1), valCoord(seed, x1, y1), xs);
double xf0 = MathUtil.lerp(xs, valCoord(seed, x0, y0), valCoord(seed, x1, y0));
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
Expand All @@ -49,14 +49,14 @@ public double getNoiseRaw(long sl, double x, double y, double z) {
int y1 = y0 + PRIME_Y;
int z1 = z0 + PRIME_Z;

double xf00 = MathUtil.lerp(valCoord(seed, x0, y0, z0), valCoord(seed, x1, y0, z0), xs);
double xf10 = MathUtil.lerp(valCoord(seed, x0, y1, z0), valCoord(seed, x1, y1, z0), xs);
double xf01 = MathUtil.lerp(valCoord(seed, x0, y0, z1), valCoord(seed, x1, y0, z1), xs);
double xf11 = MathUtil.lerp(valCoord(seed, x0, y1, z1), valCoord(seed, x1, y1, z1), xs);
double xf00 = MathUtil.lerp(xs, valCoord(seed, x0, y0, z0), valCoord(seed, x1, y0, z0));
double xf10 = MathUtil.lerp(xs, valCoord(seed, x0, y1, z0), valCoord(seed, x1, y1, z0));
double xf01 = MathUtil.lerp(xs, valCoord(seed, x0, y0, z1), valCoord(seed, x1, y0, z1));
double xf11 = MathUtil.lerp(xs, valCoord(seed, x0, y1, z1), valCoord(seed, x1, y1, z1));

double yf0 = MathUtil.lerp(xf00, xf10, ys);
double yf1 = MathUtil.lerp(xf01, xf11, ys);
double yf0 = MathUtil.lerp(ys, xf00, xf10);
double yf1 = MathUtil.lerp(ys, xf01, xf11);

return MathUtil.lerp(yf0, yf1, zs);
return MathUtil.lerp(zs, yf0, yf1);
}
}

0 comments on commit ab60f14

Please sign in to comment.