RidgedPerlin cleanup / More river noise options
This commit is contained in:
@@ -47,7 +47,6 @@ public class MenuRenderer implements Disposable{
|
|||||||
Simplex s1 = new Simplex(offset);
|
Simplex s1 = new Simplex(offset);
|
||||||
Simplex s2 = new Simplex(offset + 1);
|
Simplex s2 = new Simplex(offset + 1);
|
||||||
Simplex s3 = new Simplex(offset + 2);
|
Simplex s3 = new Simplex(offset + 2);
|
||||||
RidgedPerlin rid = new RidgedPerlin(1 + offset, 1);
|
|
||||||
Block[] selected = Structs.select(
|
Block[] selected = Structs.select(
|
||||||
new Block[]{Blocks.sand, Blocks.sandWall},
|
new Block[]{Blocks.sand, Blocks.sandWall},
|
||||||
new Block[]{Blocks.shale, Blocks.shaleWall},
|
new Block[]{Blocks.shale, Blocks.shaleWall},
|
||||||
@@ -141,7 +140,7 @@ public class MenuRenderer implements Disposable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(tendrils){
|
if(tendrils){
|
||||||
if(rid.getValue(x, y, 1f / 17f) > 0f){
|
if(RidgedPerlin.noise2d(1 + offset, x, y, 1f / 17f) > 0f){
|
||||||
floor = Mathf.chance(0.2) ? Blocks.sporeMoss : Blocks.moss;
|
floor = Mathf.chance(0.2) ? Blocks.sporeMoss : Blocks.moss;
|
||||||
|
|
||||||
if(wall != Blocks.air){
|
if(wall != Blocks.air){
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class BlendFilter extends GenerateFilter{
|
|||||||
@Override
|
@Override
|
||||||
public FilterOption[] options(){
|
public FilterOption[] options(){
|
||||||
return Structs.arr(
|
return Structs.arr(
|
||||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 15f),
|
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||||
new BlockOption("block", () -> block, b -> block = b, anyOptional),
|
new BlockOption("block", () -> block, b -> block = b, anyOptional),
|
||||||
new BlockOption("floor", () -> floor, b -> floor = b, anyOptional),
|
new BlockOption("floor", () -> floor, b -> floor = b, anyOptional),
|
||||||
new BlockOption("ignore", () -> ignore, b -> ignore = b, floorsOptional)
|
new BlockOption("ignore", () -> ignore, b -> ignore = b, floorsOptional)
|
||||||
@@ -41,7 +41,7 @@ public class BlendFilter extends GenerateFilter{
|
|||||||
outer:
|
outer:
|
||||||
for(int x = -rad; x <= rad; x++){
|
for(int x = -rad; x <= rad; x++){
|
||||||
for(int y = -rad; y <= rad; y++){
|
for(int y = -rad; y <= rad; y++){
|
||||||
if(x*x + y*y > rad) continue;
|
if(x*x + y*y > rad*rad) continue;
|
||||||
Tile tile = in.tile(in.x + x, in.y + y);
|
Tile tile = in.tile(in.x + x, in.y + y);
|
||||||
|
|
||||||
if(tile.floor() == block || tile.block() == block || tile.overlay() == block){
|
if(tile.floor() == block || tile.block() == block || tile.overlay() == block){
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import mindustry.world.*;
|
|||||||
|
|
||||||
public abstract class GenerateFilter{
|
public abstract class GenerateFilter{
|
||||||
protected transient float o = (float)(Math.random() * 10000000.0);
|
protected transient float o = (float)(Math.random() * 10000000.0);
|
||||||
protected transient long seed;
|
protected transient int seed;
|
||||||
protected transient GenerateInput in;
|
protected transient GenerateInput in;
|
||||||
|
|
||||||
public void apply(Tiles tiles, GenerateInput in){
|
public void apply(Tiles tiles, GenerateInput in){
|
||||||
@@ -117,11 +117,15 @@ public abstract class GenerateFilter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected float rnoise(float x, float y, float scl, float mag){
|
protected float rnoise(float x, float y, float scl, float mag){
|
||||||
return in.pnoise.getValue((int)(x + o), (int)(y + o), 1f / scl) * mag;
|
return RidgedPerlin.noise2d(seed + 1, (int)(x + o), (int)(y + o), 1f / scl) * mag;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float rnoise(float x, float y, int octaves, float scl, float falloff, float mag){
|
||||||
|
return RidgedPerlin.noise2d(seed + 1, (int)(x + o), (int)(y + o), octaves, falloff, 1f / scl) * mag;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float chance(){
|
protected float chance(){
|
||||||
return Mathf.randomSeed(Pack.longInt(in.x, in.y + (int)seed));
|
return Mathf.randomSeed(Pack.longInt(in.x, in.y + seed));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** an input for generating at a certain coordinate. should only be instantiated once. */
|
/** an input for generating at a certain coordinate. should only be instantiated once. */
|
||||||
@@ -134,7 +138,6 @@ public abstract class GenerateFilter{
|
|||||||
public Block floor, block, overlay;
|
public Block floor, block, overlay;
|
||||||
|
|
||||||
Simplex noise = new Simplex();
|
Simplex noise = new Simplex();
|
||||||
RidgedPerlin pnoise = new RidgedPerlin(0, 1);
|
|
||||||
TileProvider buffer;
|
TileProvider buffer;
|
||||||
|
|
||||||
public void apply(int x, int y, Block block, Block floor, Block overlay){
|
public void apply(int x, int y, Block block, Block floor, Block overlay){
|
||||||
@@ -150,7 +153,6 @@ public abstract class GenerateFilter{
|
|||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
noise.setSeed(filter.seed);
|
noise.setSeed(filter.seed);
|
||||||
pnoise.setSeed((int)(filter.seed + 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile tile(float x, float y){
|
Tile tile(float x, float y){
|
||||||
|
|||||||
@@ -8,15 +8,17 @@ import mindustry.world.*;
|
|||||||
import static mindustry.maps.filters.FilterOption.*;
|
import static mindustry.maps.filters.FilterOption.*;
|
||||||
|
|
||||||
public class RiverNoiseFilter extends GenerateFilter{
|
public class RiverNoiseFilter extends GenerateFilter{
|
||||||
float scl = 40, threshold = 0f, threshold2 = 0.1f;
|
float scl = 40, threshold = 0f, threshold2 = 0.1f, octaves = 1, falloff = 0.5f;
|
||||||
Block floor = Blocks.water, floor2 = Blocks.deepwater, block = Blocks.sandWall;
|
Block floor = Blocks.water, floor2 = Blocks.deepwater, block = Blocks.sandWall;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FilterOption[] options(){
|
public FilterOption[] options(){
|
||||||
return Structs.arr(
|
return Structs.arr(
|
||||||
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
new SliderOption("scale", () -> scl, f -> scl = f, 1f, 500f),
|
||||||
new SliderOption("threshold", () -> threshold, f -> threshold = f, -1f, 0.3f),
|
new SliderOption("threshold", () -> threshold, f -> threshold = f, -1f, 1f),
|
||||||
new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, -1f, 0.3f),
|
new SliderOption("threshold2", () -> threshold2, f -> threshold2 = f, -1f, 1f),
|
||||||
|
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
|
||||||
|
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
|
||||||
new BlockOption("block", () -> block, b -> block = b, wallsOnly),
|
new BlockOption("block", () -> block, b -> block = b, wallsOnly),
|
||||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
|
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
|
||||||
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly)
|
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly)
|
||||||
@@ -30,7 +32,7 @@ public class RiverNoiseFilter extends GenerateFilter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(){
|
public void apply(){
|
||||||
float noise = rnoise(in.x, in.y, scl, 1f);
|
float noise = rnoise(in.x, in.y, (int)octaves, scl, falloff, 1f);
|
||||||
|
|
||||||
if(noise >= threshold){
|
if(noise >= threshold){
|
||||||
in.floor = floor;
|
in.floor = floor;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import mindustry.world.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class SerpuloPlanetGenerator extends PlanetGenerator{
|
public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||||
RidgedPerlin rid = new RidgedPerlin(1, 2);
|
|
||||||
BaseGenerator basegen = new BaseGenerator();
|
BaseGenerator basegen = new BaseGenerator();
|
||||||
float scl = 5f;
|
float scl = 5f;
|
||||||
float waterOffset = 0.07f;
|
float waterOffset = 0.07f;
|
||||||
@@ -115,7 +114,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
|||||||
tile.floor = getBlock(position);
|
tile.floor = getBlock(position);
|
||||||
tile.block = tile.floor.asFloor().wall;
|
tile.block = tile.floor.asFloor().wall;
|
||||||
|
|
||||||
if(rid.getValue(position.x, position.y, position.z, 22) > 0.31){
|
if(RidgedPerlin.noise3d(1, position.x, position.y, position.z, 2, 22) > 0.31){
|
||||||
tile.block = Blocks.air;
|
tile.block = Blocks.air;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ kapt.use.worker.api=true
|
|||||||
kapt.include.compile.classpath=false
|
kapt.include.compile.classpath=false
|
||||||
# I don't need to use the kotlin stdlib yet, so remove it to prevent extra bloat & method count issues
|
# I don't need to use the kotlin stdlib yet, so remove it to prevent extra bloat & method count issues
|
||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
archash=99280fd6749dec1ed5d8bb829462de47364948bc
|
archash=2583b8229309dbe5a5c30b647779be5163feb68f
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ public class Generators{
|
|||||||
});
|
});
|
||||||
|
|
||||||
generate("cracks", () -> {
|
generate("cracks", () -> {
|
||||||
RidgedPerlin r = new RidgedPerlin(1, 3);
|
|
||||||
for(int size = 1; size <= BlockRenderer.maxCrackSize; size++){
|
for(int size = 1; size <= BlockRenderer.maxCrackSize; size++){
|
||||||
int dim = size * 32;
|
int dim = size * 32;
|
||||||
int steps = BlockRenderer.crackRegions;
|
int steps = BlockRenderer.crackRegions;
|
||||||
@@ -177,7 +176,7 @@ public class Generators{
|
|||||||
for(int x = 0; x < dim; x++){
|
for(int x = 0; x < dim; x++){
|
||||||
for(int y = 0; y < dim; y++){
|
for(int y = 0; y < dim; y++){
|
||||||
float dst = Mathf.dst((float)x/dim, (float)y/dim, 0.5f, 0.5f) * 2f;
|
float dst = Mathf.dst((float)x/dim, (float)y/dim, 0.5f, 0.5f) * 2f;
|
||||||
if(dst < 1.2f && r.getValue(x, y, 1f / 40f) - dst*(1f-fract) > 0.16f){
|
if(dst < 1.2f && RidgedPerlin.noise2d(1, x, y, 3, 1f / 40f) - dst*(1f-fract) > 0.16f){
|
||||||
image.setRaw(x, y, Color.whiteRgba);
|
image.setRaw(x, y, Color.whiteRgba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,12 +484,11 @@ public class Generators{
|
|||||||
wrecks[i] = new Pixmap(image.width, image.height);
|
wrecks[i] = new Pixmap(image.width, image.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
RidgedPerlin r = new RidgedPerlin(1, 3);
|
|
||||||
VoronoiNoise vn = new VoronoiNoise(type.id, true);
|
VoronoiNoise vn = new VoronoiNoise(type.id, true);
|
||||||
|
|
||||||
image.each((x, y) -> {
|
image.each((x, y) -> {
|
||||||
//add darker cracks on top
|
//add darker cracks on top
|
||||||
boolean rValue = Math.max(r.getValue(x, y, 1f / (20f + image.width/8f)), 0) > 0.16f;
|
boolean rValue = Math.max(RidgedPerlin.noise2d(1, x, y, 3, 1f / (20f + image.width/8f)), 0) > 0.16f;
|
||||||
//cut out random chunks with voronoi
|
//cut out random chunks with voronoi
|
||||||
boolean vval = vn.noise(x, y, 1f / (14f + image.width/40f)) > 0.47;
|
boolean vval = vn.noise(x, y, 1f / (14f + image.width/40f)) > 0.47;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user