9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-26 02:29:14 +00:00

Proper fracturing for max fracture accuracy

This commit is contained in:
Daniel Mills
2021-07-28 20:18:10 -04:00
parent 16fa453163
commit b2a410d6cf
4 changed files with 41 additions and 28 deletions

View File

@@ -477,8 +477,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
BlockData d = getPostBlock(x, y, z, currentPostX, currentPostZ, currentData);
return d instanceof Levelled;
}
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
synchronized (currentData)
{

View File

@@ -347,35 +347,49 @@ public class CNG {
}
private double getNoise(double... dim) {
if (isTrueFracturing()) {
if (dim.length == 2) {
double scale = noscale ? 1 : this.bakedScale * this.scale;
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[1]) - 0.5) * fscale : 0D);
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0]) - 0.5) * fscale : 0D);
double x = dim[0] + f1;
double y = dim[1] + -f1;
double z = 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
} else if (dim.length == 3) {
double scale = noscale ? 1 : this.bakedScale * this.scale;
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[2], dim[1]) - 0.5) * fscale : 0D);
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0], dim[2]) - 0.5) * fscale : 0D);
double f3 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[2], dim[1], dim[0]) - 0.5) * fscale : 0D);
double x = dim[0] + f1;
double y = dim[1] + f3;
double z = dim[2] + f2;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
}
double scale = noscale ? 1 : this.bakedScale * this.scale;
if(fracture == null || noscale)
{
return generator.noise(
(dim.length > 0 ? dim[0] : 0D) * scale,
(dim.length > 1 ? dim[1] : 0D) * scale,
(dim.length > 2 ? dim[2] : 0D) * scale) * opacity;
}
double scale = noscale ? 1 : this.bakedScale * this.scale;
double f = noscale ? 0 : (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
if (fracture.isTrueFracturing()) {
double x = dim.length > 0 ? dim[0] + ((fracture.noise(dim) - 0.5) * fscale) : 0D;
double y = dim.length > 1 ? dim[1] + ((fracture.noise(dim[1], dim[0]) - 0.5) * fscale) : 0D;
double z = dim.length > 2 ? dim[2] + ((fracture.noise(dim[2], dim[0], dim[1]) - 0.5) * fscale) : 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
}
double f = fracture.noise(dim) * fscale;
double x = dim.length > 0 ? dim[0] + f : 0D;
double y = dim.length > 1 ? dim[1] + -f : 0D;
double z = dim.length > 2 ? dim[2] + -f : 0D;
double y = dim.length > 1 ? dim[1] - f : 0D;
double z = dim.length > 2 ? dim[2] - f : 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
}
public double invertNoise(double... dim) {
if(dim.length == 1)
{
return noise(-dim[0]);
}
else if(dim.length == 2)
{
return noise(dim[1], dim[0]);
}
else if(dim.length == 3)
{
return noise(dim[1], dim[2], dim[0]);
}
return noise(dim);
}
public double noise(double... dim) {
double n = getNoise(dim);
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;

View File

@@ -49,7 +49,7 @@ public class IrisGeneratorStyle {
private double multiplier = 1;
@Desc("If set to true, each dimension will be fractured with a different order of input coordinates. This is usually 2 or 3 times slower than normal.")
private boolean maxFractureAccuracy = false;
private boolean axialFracturing = false;
@Desc("Apply a generator to the coordinate field fed into this parent generator. I.e. Distort your generator with another generator.")
private IrisGeneratorStyle fracture = null;
@@ -74,7 +74,7 @@ public class IrisGeneratorStyle {
return cng.aquire(() ->
{
CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(maxFractureAccuracy);
cng.setTrueFracturing(axialFracturing);
if (fracture != null) {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934)), fracture.getMultiplier());