Stateless simplex

This commit is contained in:
Anuken
2021-06-15 19:28:54 -04:00
parent 210fb349de
commit fe9ff212b2
9 changed files with 30 additions and 39 deletions

View File

@@ -44,9 +44,7 @@ public class MenuRenderer implements Disposable{
Seq<Block> ores = content.blocks().select(b -> b instanceof OreBlock && !(b instanceof WallOreBlock));
shadows = new FrameBuffer(width, height);
int offset = Mathf.random(100000);
Simplex s1 = new Simplex(offset);
Simplex s2 = new Simplex(offset + 1);
Simplex s3 = new Simplex(offset + 2);
int s1 = offset, s2 = offset + 1, s3 = offset + 2;
Block[] selected = Structs.select(
new Block[]{Blocks.sand, Blocks.sandWall},
new Block[]{Blocks.shale, Blocks.shaleWall},
@@ -85,27 +83,27 @@ public class MenuRenderer implements Disposable{
Block ore = Blocks.air;
Block wall = Blocks.air;
if(s1.octaveNoise2D(3, 0.5, 1/20.0, x, y) > 0.5){
if(Simplex.noise2d(s1, 3, 0.5, 1/20.0, x, y) > 0.5){
wall = walld;
}
if(s3.octaveNoise2D(3, 0.5, 1/20.0, x, y) > 0.5){
if(Simplex.noise2d(s3, 3, 0.5, 1/20.0, x, y) > 0.5){
floor = floord2;
if(wall != Blocks.air){
wall = walld2;
}
}
if(s2.octaveNoise2D(3, 0.3, 1/30.0, x, y) > tr1){
if(Simplex.noise2d(s2, 3, 0.3, 1/30.0, x, y) > tr1){
ore = ore1;
}
if(s2.octaveNoise2D(2, 0.2, 1/15.0, x, y+99999) > tr2){
if(Simplex.noise2d(s2, 2, 0.2, 1/15.0, x, y+99999) > tr2){
ore = ore2;
}
if(doheat){
double heat = s3.octaveNoise2D(4, 0.6, 1 / 50.0, x, y + 9999);
double heat = Simplex.noise2d(s3, 4, 0.6, 1 / 50.0, x, y + 9999);
double base = 0.65;
if(heat > base){
@@ -126,7 +124,7 @@ public class MenuRenderer implements Disposable{
if(tech){
int mx = x % secSize, my = y % secSize;
int sclx = x / secSize, scly = y / secSize;
if(s1.octaveNoise2D(2, 1f / 10f, 0.5f, sclx, scly) > 0.4f && (mx == 0 || my == 0 || mx == secSize - 1 || my == secSize - 1)){
if(Simplex.noise2d(s1, 2, 1f / 10f, 0.5f, sclx, scly) > 0.4f && (mx == 0 || my == 0 || mx == secSize - 1 || my == secSize - 1)){
floor = Blocks.darkPanel3;
if(Mathf.dst(mx, my, secSize/2, secSize/2) > secSize/2f + 1){
floor = Blocks.darkPanel4;
@@ -140,7 +138,7 @@ public class MenuRenderer implements Disposable{
}
if(tendrils){
if(RidgedPerlin.noise2d(1 + offset, x, y, 1f / 17f) > 0f){
if(Ridged.noise2d(1 + offset, x, y, 1f / 17f) > 0f){
floor = Mathf.chance(0.2) ? Blocks.sporeMoss : Blocks.moss;
if(wall != Blocks.air){