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

@ -5,7 +5,7 @@ plugins {
} }
group 'com.volmit.iris' group 'com.volmit.iris'
version '1.5.13' version '1.5.14'
def apiVersion = '1.17' def apiVersion = '1.17'
def name = 'Iris' def name = 'Iris'
def main = 'com.volmit.iris.Iris' def main = 'com.volmit.iris.Iris'

View File

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

View File

@ -347,35 +347,49 @@ public class CNG {
} }
private double getNoise(double... dim) { private double getNoise(double... dim) {
if (isTrueFracturing()) {
if (dim.length == 2) {
double scale = noscale ? 1 : this.bakedScale * this.scale; 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); if(fracture == null || noscale)
double x = dim[0] + f1; {
double y = dim[1] + -f1; return generator.noise(
double z = 0D; (dim.length > 0 ? dim[0] : 0D) * scale,
return generator.noise(x * scale, y * scale, z * scale) * opacity; (dim.length > 1 ? dim[1] : 0D) * scale,
} else if (dim.length == 3) { (dim.length > 2 ? dim[2] : 0D) * scale) * opacity;
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.isTrueFracturing()) {
double f = noscale ? 0 : (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D); double x = dim.length > 0 ? dim[0] + ((fracture.noise(dim) - 0.5) * fscale) : 0D;
double x = dim.length > 0 ? dim[0] + f : 0D; double y = dim.length > 1 ? dim[1] + ((fracture.noise(dim[1], dim[0]) - 0.5) * fscale) : 0D;
double y = dim.length > 1 ? dim[1] + -f : 0D; double z = dim.length > 2 ? dim[2] + ((fracture.noise(dim[2], dim[0], dim[1]) - 0.5) * fscale) : 0D;
double z = dim.length > 2 ? dim[2] + -f : 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity; 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;
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) { public double noise(double... dim) {
double n = getNoise(dim); double n = getNoise(dim);
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n; 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; 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.") @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.") @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; private IrisGeneratorStyle fracture = null;
@ -74,7 +74,7 @@ public class IrisGeneratorStyle {
return cng.aquire(() -> return cng.aquire(() ->
{ {
CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake(); CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(maxFractureAccuracy); cng.setTrueFracturing(axialFracturing);
if (fracture != null) { if (fracture != null) {
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934)), fracture.getMultiplier()); cng.fractureWith(fracture.create(rng.nextParallelRNG(2934)), fracture.getMultiplier());