mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Auto stash before revert of "Improve finding by allowing minimal distance & randomization"
This commit is contained in:
parent
434e7f75fa
commit
d7ad947cbb
@ -47,6 +47,13 @@ public class IrisGeneratorStyle {
|
||||
private final transient AtomicCache<CNG> cng = new AtomicCache<>();
|
||||
@Desc("The chance is 1 in CHANCE per interval")
|
||||
private NoiseStyle style = NoiseStyle.FLAT;
|
||||
|
||||
@Desc("If set above 0, this style will be cellularized")
|
||||
private double cellularFrequency = 0;
|
||||
|
||||
@Desc("Cell zooms")
|
||||
private double cellularZoom = 1;
|
||||
|
||||
@MinNumber(0.00001)
|
||||
@Desc("The zoom of this style")
|
||||
private double zoom = 1;
|
||||
@ -89,6 +96,11 @@ public class IrisGeneratorStyle {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
if(cellularFrequency > 0)
|
||||
{
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
|
||||
}
|
||||
|
||||
return cng;
|
||||
}
|
||||
}
|
||||
@ -102,6 +114,11 @@ public class IrisGeneratorStyle {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
if(cellularFrequency > 0)
|
||||
{
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
|
||||
}
|
||||
|
||||
return cng;
|
||||
}
|
||||
|
||||
@ -112,6 +129,11 @@ public class IrisGeneratorStyle {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
if(cellularFrequency > 0)
|
||||
{
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
|
||||
}
|
||||
|
||||
return cng;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.BiasedCellularNoise;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.noise.CNGFactory;
|
||||
import com.volmit.iris.util.noise.NoiseType;
|
||||
@ -447,23 +446,6 @@ public enum NoiseStyle {
|
||||
|
||||
@Desc("Vascular noise gets higher as the position nears a cell border. Cells are distorted using Iris styled wispy noise.")
|
||||
VASCULAR_IRIS_HALF(rng -> CNG.signatureHalf(rng, NoiseType.VASCULAR)),
|
||||
|
||||
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
|
||||
SIMPLEX_BIASED_CELLULAR(rng -> new CNG(rng, new BiasedCellularNoise(rng.lmax(),
|
||||
SIMPLEX.stream(rng.nextParallelRNG(-23333666)).zoom(0.158)), 1D, 1)),
|
||||
|
||||
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
|
||||
NOWHERE_BIASED_CELLULAR(rng -> new CNG(rng, new BiasedCellularNoise(rng.lmax(),
|
||||
NOWHERE.stream(rng.nextParallelRNG(-23333666)).zoom(0.158)), 1D, 1)),
|
||||
|
||||
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
|
||||
IRIS_BIASED_CELLULAR(rng -> new CNG(rng, new BiasedCellularNoise(rng.lmax(),
|
||||
IRIS.stream(rng.nextParallelRNG(-23333666)).zoom(0.158)), 1D, 1)),
|
||||
|
||||
@Desc("White Noise is like static. Useful for block scattering but not terrain.")
|
||||
VASCULAR_BIASED_CELLULAR(rng -> new CNG(rng, new BiasedCellularNoise(rng.lmax(),
|
||||
VASCULAR.stream(rng.nextParallelRNG(-23333666)).zoom(0.158)), 1D, 1)),
|
||||
|
||||
;
|
||||
|
||||
private final CNGFactory f;
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
import com.volmit.iris.engine.object.NoiseStyle;
|
||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
|
||||
public class BiasedCellularNoise implements NoiseGenerator {
|
||||
private final FastNoise n;
|
||||
private final ProceduralStream<Double> biasShape;
|
||||
|
||||
public BiasedCellularNoise(long seed, ProceduralStream<Double> biasShape) {
|
||||
this.biasShape = biasShape.subtract(0.5).multiply(2);
|
||||
this.n = new FastNoise(new RNG(seed).imax());
|
||||
n.SetNoiseType(FastNoise.NoiseType.Cellular);
|
||||
n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue);
|
||||
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return (n.GetCellular((float) x, (float) 0, biasShape) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return (n.GetCellular((float) x, (float) z, biasShape) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return (n.GetCellular((float) x, (float) y, biasShape) / 2D) + 0.5D;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.IRare;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.function.NoiseInjector;
|
||||
@ -102,6 +103,34 @@ public class CNG {
|
||||
}
|
||||
}
|
||||
|
||||
public CNG cellularize(RNG seed, double freq)
|
||||
{
|
||||
FastNoise cellularFilter = new FastNoise(seed.imax());
|
||||
cellularFilter.SetNoiseType(FastNoise.NoiseType.Cellular);
|
||||
cellularFilter.SetCellularReturnType(FastNoise.CellularReturnType.CellValue);
|
||||
cellularFilter.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Manhattan);
|
||||
cellularFilter.SetFrequency((float) freq * 0.01f);
|
||||
|
||||
ProceduralStream<Double> str = stream();
|
||||
|
||||
return new CNG(seed, new NoiseGenerator() {
|
||||
@Override
|
||||
public double noise(double x) {
|
||||
return noise(x, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double z) {
|
||||
return (cellularFilter.GetCellular((float)x, (float)z, str, 1) / 2D) + 0.5D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
return noise(x, y + z);
|
||||
}
|
||||
}, 1D, 1);
|
||||
}
|
||||
|
||||
public static CNG signature(RNG rng) {
|
||||
return signature(rng, NoiseType.SIMPLEX);
|
||||
}
|
||||
|
@ -1729,7 +1729,7 @@ public class FastNoise {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public float GetCellular(float x, float y, ProceduralStream<Double> sourceNoise) {
|
||||
public float GetCellular(float x, float y, ProceduralStream<Double> sourceNoise, double iscale) {
|
||||
x *= m_frequency;
|
||||
y *= m_frequency;
|
||||
|
||||
@ -1737,7 +1737,7 @@ public class FastNoise {
|
||||
case CellValue:
|
||||
case NoiseLookup:
|
||||
case Distance:
|
||||
return SingleCellular(x, y, sourceNoise);
|
||||
return SingleCellular(x, y, sourceNoise, iscale);
|
||||
default:
|
||||
return SingleCellular2Edge(x, y);
|
||||
}
|
||||
@ -1837,7 +1837,7 @@ public class FastNoise {
|
||||
}
|
||||
}
|
||||
|
||||
private float SingleCellular(float x, float y, ProceduralStream<Double> sourceNoise) {
|
||||
private float SingleCellular(float x, float y, ProceduralStream<Double> sourceNoise, double iscale) {
|
||||
int xr = FastRound(x);
|
||||
int yr = FastRound(y);
|
||||
|
||||
@ -1904,7 +1904,7 @@ public class FastNoise {
|
||||
|
||||
switch (m_cellularReturnType) {
|
||||
case CellValue:
|
||||
return sourceNoise.get(xc, yc).floatValue();
|
||||
return sourceNoise.get(xc * iscale, yc * iscale).floatValue();
|
||||
|
||||
case NoiseLookup:
|
||||
Float2 vec = CELL_2D[Hash2D(m_seed, xc, yc) & 255];
|
||||
|
@ -18,6 +18,9 @@
|
||||
|
||||
package com.volmit.iris.util.noise;
|
||||
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.stream.interpolation.Interpolated;
|
||||
|
||||
public interface NoiseGenerator {
|
||||
double noise(double x);
|
||||
|
||||
@ -32,4 +35,9 @@ public interface NoiseGenerator {
|
||||
default boolean isNoScale() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default ProceduralStream<Double> stream()
|
||||
{
|
||||
return ProceduralStream.of(this::noise, this::noise, Interpolated.DOUBLE);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user