diff --git a/assets/mods/basegame/blocks/18.tga b/assets/mods/basegame/blocks/18.tga index c23beebef..5dab032c6 100644 --- a/assets/mods/basegame/blocks/18.tga +++ b/assets/mods/basegame/blocks/18.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bff1d9e16c37d0dc9042e39956ecd0a38d133e3b4701822d90086adf00d8a7ad +oid sha256:671200cfbe47ae1733c0e62dfff21f4d84e1d81a37a01bf0ac7d04760851295a size 56594 diff --git a/assets/mods/basegame/blocks/19.tga b/assets/mods/basegame/blocks/19.tga index 5ff5650bc..93f3caee0 100644 --- a/assets/mods/basegame/blocks/19.tga +++ b/assets/mods/basegame/blocks/19.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b194abbf3d8047a2749b88ac8c23015d349ab9413a4d57979b416feb63752ba1 +oid sha256:67c14f007328fb4867c107a0fb08a8a7723e422c3d339d2c1559373d73d2e91f size 56594 diff --git a/assets/mods/basegame/blocks/20.tga b/assets/mods/basegame/blocks/20.tga index 9037de227..4b58c10c7 100644 --- a/assets/mods/basegame/blocks/20.tga +++ b/assets/mods/basegame/blocks/20.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f2a8b7ec928879b071f7c67f89602c16e9cbd7bd0afa5a7eec576d2505123566 +oid sha256:8c4e04625eb7b4d46709708381b709f8c70822fce0b70d8d5e7867f25e4b4a62 size 56594 diff --git a/assets/mods/basegame/blocks/21.tga b/assets/mods/basegame/blocks/21.tga index 33b72b813..39e0d7729 100755 --- a/assets/mods/basegame/blocks/21.tga +++ b/assets/mods/basegame/blocks/21.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f41fc1f8ccde814e66b749d2f6333c53100dc1b4b4653244a1078d9cf8584aa +oid sha256:7c5e25928d2d004e4a60137bf5c89f51f3116f3d4643c351d57b43804a2ced91 size 56594 diff --git a/assets/mods/basegame/blocks/22.tga b/assets/mods/basegame/blocks/22.tga index 7e0b4e835..0f029324b 100644 --- a/assets/mods/basegame/blocks/22.tga +++ b/assets/mods/basegame/blocks/22.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dd9500638ed8df143471d450f5a08f366bcb6b07081a89700403012190f5bc64 +oid sha256:c4364f12ad21c485b87f50e091e0e38a23bfacac22dee7d8b400a386f0557ee4 size 56594 diff --git a/assets/mods/basegame/blocks/23.tga b/assets/mods/basegame/blocks/23.tga index cb8fd84d6..176b88ab7 100644 --- a/assets/mods/basegame/blocks/23.tga +++ b/assets/mods/basegame/blocks/23.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2554f1fe7f2f15e18face4b7c2212b1ebdf1a0ab0449ef5f7de1d0aeaf5bc325 +oid sha256:08dbda3eb8f2b388e686298c21d27a671487faeb89cde7ffb460237e96be6b89 size 56594 diff --git a/assets/mods/basegame/blocks/24.tga b/assets/mods/basegame/blocks/24.tga index da4732168..20c47bb35 100644 --- a/assets/mods/basegame/blocks/24.tga +++ b/assets/mods/basegame/blocks/24.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fb94b23a19ccb7de64be15507474912371b77163993c6e61abe233cf2c90edee +oid sha256:859a4b80e8d669bef16b8e84f0a0d244be03f62a7d2e5282652a25f9b7f2c080 size 56594 diff --git a/assets/mods/basegame/blocks/25.tga b/assets/mods/basegame/blocks/25.tga index 8bdceadf6..418f3daf2 100644 --- a/assets/mods/basegame/blocks/25.tga +++ b/assets/mods/basegame/blocks/25.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:885235045a35a9b353cc0dd91e99881e6d3d2ccbb60124be258183096b1b4f63 +oid sha256:23a6db823b67b858eef916aaeac60a7a939a22928f4cffd6de65f73c83967c34 size 56594 diff --git a/assets/mods/basegame/blocks/26.tga b/assets/mods/basegame/blocks/26.tga new file mode 100644 index 000000000..592f2383a --- /dev/null +++ b/assets/mods/basegame/blocks/26.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e52bcb1536829f9735d4c18b2bb157320a7f43421d05355ffbb399065646d06 +size 56594 diff --git a/assets/mods/basegame/blocks/27.tga b/assets/mods/basegame/blocks/27.tga new file mode 100644 index 000000000..ae171bf01 --- /dev/null +++ b/assets/mods/basegame/blocks/27.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c924c234ad96d8986be7619c43c3dad43ecb103e79f60829a662969d421493e0 +size 56594 diff --git a/assets/mods/basegame/blocks/blocks.csv b/assets/mods/basegame/blocks/blocks.csv index 4fd19a100..ef16fcf9d 100644 --- a/assets/mods/basegame/blocks/blocks.csv +++ b/assets/mods/basegame/blocks/blocks.csv @@ -3,23 +3,25 @@ "1";"N/A";"N/A";"BLOCK_UPDATE";"0.0312";"0.0312";"0.0312";"0.0312";"1";"1";"AIIR";"0";"1";"N/A";"0";"0";"4";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"INTERNAL,NORANDTILE" # rocks -"16";"16";"16";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,SHALLOWROCK,BRICKROCK" -"17";"16";"16";"BLOCK_STONE_QUARRIED";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,SHALLOWROCK,BRICKROCK" +"16";"16";"16";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,BRICKTILE¤19" +"17";"16";"16";"BLOCK_STONE_QUARRIED";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" "18";"18";"18";"BLOCK_STONE_TILE_WHITE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.18";"STONE" "19";"19";"19";"BLOCK_STONE_BRICKS";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"STONE" -"20";"20";"20";"BLOCK_STONE_DEEP";"0.1252";"0.1252";"0.1252";"0.1252";"80";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURA,OREBEARING,DEEPROCK,BRICKROCK" -"21";"21";"21";"BLOCK_STONE_MARBLE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.1";"ROCK,NATURAL,DEEPROCK" -"22";"22";"22";"BLOCK_STONE_ORTHOCLASE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,SHALLOWROCK,BRICKROCK" -"23";"23";"23";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,SHALLOWROCK,BRICKROCK" -"24";"24";"24";"BLOCK_STONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,SHALLOWROCK,BRICKROCK" -"25";"25";"25";"BLOCK_STONE_BASALT";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING,SHALLOWROCK,BRICKROCK" +"20";"20";"20";"BLOCK_STONE_GABBRO";"0.1252";"0.1252";"0.1252";"0.1252";"80";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURA,OREBEARING,OLDNAME¤0.4.4¤STONE_DEEP" +"21";"21";"21";"BLOCK_STONE_MARBLE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.1";"ROCK,NATURAL,STONETILE¤18" +"22";"22";"22";"BLOCK_STONE_ORTHOCLASE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" +"23";"23";"23";"BLOCK_STONE_PLAGIOCLASE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" +"24";"24";"24";"BLOCK_STONE_MICROCLINE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" +"25";"25";"25";"BLOCK_STONE_BASALT";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" +"26";"26";"26";"BLOCK_STONE_SLATE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" +"27";"27";"27";"BLOCK_STONE_LIMESTONE";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"ROCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"ROCK,NATURAL,OREBEARING" # dirts "32";"32";"32";"BLOCK_DIRT";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1400";"DIRT";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"DIRT,NATURAL,CULTIVABLE" "33";"32";"32";"BLOCK_GRASS";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1400";"GRSS";"1";"0";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"GRASS,NATURAL,CULTIVABLE" "34";"34";"34";"BLOCK_GRASSWALL";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1400";"GRSS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"GRASS,NATURAL" "35";"item@basegame:25";"item@basegame:25";"BLOCK_CLAY";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1700";"DIRT";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"DIRT,NATURAL" -"36";"36";"36";"BLOCK_BRICKS";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"BRCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.1";"ROCK,NATURAL,DEEPROCK" +"36";"36";"36";"BLOCK_BRICKS";"0.1252";"0.1252";"0.1252";"0.1252";"48";"2400";"BRCK";"1";"1";"N/A";"0";"4";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.1";"ROCK,NATURAL" #"35";"35";"35";"BLOCK_FOLIAGE_GREEN";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1400";"GRSS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"GRASS,NATURAL" #"36";"36";"36";"BLOCK_FOLIAGE_LIME";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1400";"GRSS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"GRASS,NATURAL" #"37";"37";"37";"BLOCK_FOLIAGE_GOLD";"0.1252";"0.1252";"0.1252";"0.1252";"12";"1400";"GRSS";"1";"1";"N/A";"0";"0";"16";"0.0000";"0.0000";"0.0000";"0.0000";"0.0";"GRASS,NATURAL" diff --git a/src/net/torvald/terrarum/blockproperties/Block.kt b/src/net/torvald/terrarum/blockproperties/Block.kt index 1c97f9993..901d2a69c 100644 --- a/src/net/torvald/terrarum/blockproperties/Block.kt +++ b/src/net/torvald/terrarum/blockproperties/Block.kt @@ -12,12 +12,14 @@ object Block { const val STONE_QUARRIED = "basegame:17" const val STONE_TILE_WHITE = "basegame:18" const val STONE_BRICKS = "basegame:19" - const val STONE_GNEISS = "basegame:20" + const val STONE_GABBRO = "basegame:20" const val STONE_MARBLE = "basegame:21" const val STONE_ORTHOCLASE = "basegame:22" const val STONE_PLAGIOCLASE = "basegame:23" const val STONE_MICROCLINE = "basegame:24" const val STONE_BASALT = "basegame:25" + const val STONE_SLATE = "basegame:26" + const val STONE_LIMESTONE = "basegame:27" const val DIRT = "basegame:32" const val GRASS = "basegame:33" diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt index c53e1e57c..d100f4bc7 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Aquagen.kt @@ -19,6 +19,8 @@ import kotlin.math.sin */ class Aquagen(world: GameWorld, isFinal: Boolean, val groundScalingCached: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) { + private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) + private val FLUID_FILL = 1.2f override fun getDone(loadscreen: LoadScreenBase?) { @@ -33,7 +35,7 @@ class Aquagen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modul } override fun draw(xStart: Int, yStart: Int, noises: List, soff: Double) { - if (INGAME.worldGenVer != null && INGAME.worldGenVer!! <= 0x0000_000004_000003) return + if (INGAME.worldGenVer != null && !isAlpha2) return for (x in xStart until xStart + CHUNK_W) { val st = (x.toDouble() / world.width) * TWO_PI diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt index 1b5d5d965..dd021e46f 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Cavegen.kt @@ -16,6 +16,8 @@ import kotlin.math.sin */ class Cavegen(world: GameWorld, isFinal: Boolean, val highlandLowlandSelectCache: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) { + private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) + override fun getDone(loadscreen: LoadScreenBase?) { loadscreen?.let { it.stageValue += 1 @@ -108,8 +110,8 @@ class Cavegen(world: GameWorld, isFinal: Boolean, val highlandLowlandSelectCache val cavePerturb = ModuleCombiner().also { // 0: rock, 1: air it.setType(ModuleCombiner.CombinerType.MULT) it.setSource(0, cavePerturb0) - // basically disabling terminal closure for the world generated from the old version - if (INGAME.worldGenVer != null && INGAME.worldGenVer!! <= 0x0000_000004_000003) + // enable terminal closure for new worlds or ones generated from recent versions + if (INGAME.worldGenVer == null || isAlpha2) it.setSource(1, caveTerminalClosureGrad) } diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt index 71e9668ce..6f304b841 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/Terragen.kt @@ -19,8 +19,7 @@ import kotlin.math.sin */ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: ModuleCache, seed: Long, params: Any) : Gen(world, isFinal, seed, params) { - private val dirtStoneDitherSize = 3 // actual dither size will be double of this value - private val stoneSlateDitherSize = 4 + private val isAlpha2 = ((params as TerragenParams).version >= 0x0000_000004_000004) override fun getDone(loadscreen: LoadScreenBase?) { loadscreen?.let { @@ -34,10 +33,6 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu } - private val groundDepthBlock = listOf( - Block.AIR, Block.DIRT, Block.STONE, Block.STONE_GNEISS - ) - private fun Double.tiered(tiers: List): Int { tiers.reversed().forEachIndexed { index, it -> if (this >= it) return (tiers.lastIndex - index) // why?? @@ -45,17 +40,26 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu return tiers.lastIndex } - private val terragenYscaling = (world.getClampedHeight() / 2400.0).pow(0.75) - private val terragenTiers = (params as TerragenParams).terragenTiers.map { it * terragenYscaling } // pow 1.0 for 1-to-1 scaling; 0.75 is used to make deep-rock layers actually deep for huge world size + private val terragenYscaling = + if (isAlpha2) + 1.0 + else + (world.height / 2400.0).pow(0.75) //private fun draw(x: Int, y: Int, width: Int, height: Int, noiseValue: List, world: GameWorld) { override fun draw(xStart: Int, yStart: Int, noises: List, soff: Double) { + val strataMode = if (!isAlpha2) + 0 + else + 1// TODO + + val strata = (params as TerragenParams).getStrataForMode(strataMode) + val groundDepthBlock = strata.map { it.tiles } + val terragenTiers = strata.map { it.yheight * terragenYscaling } + for (x in xStart until xStart + CHUNK_W) { val st = (x.toDouble() / world.width) * TWO_PI - var dirtStoneTransition = -1 - var stoneSlateTransition = -1 - for (y in yStart until yStart + CHUNK_H) { val sx = sin(st) * soff + soff // plus sampleOffset to make only val sz = cos(st) * soff + soff // positive points are to be sampled @@ -65,21 +69,7 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu val terr = noiseValue[0].tiered(terragenTiers) - - // disable the marker if relativeY=0 already has rock - if (y == yStart && terr == 2) - dirtStoneTransition = -2 - else if (y == yStart && terr == 3) - stoneSlateTransition = -2 - // mark off the position where the transition occurred - else { - if (dirtStoneTransition == -1 && terr == 2) - dirtStoneTransition = y - if (stoneSlateTransition == -1 && terr == 3) - stoneSlateTransition = y - } - - val isMarble = noiseValue[1] > 0.5 + val isMarble = if (!isAlpha2) noiseValue[1] > 0.5 else false val wallBlock = if (isMarble) Block.STONE_MARBLE else groundDepthBlock[terr] val terrBlock = if (isMarble) Block.STONE_MARBLE else wallBlock @@ -152,15 +142,17 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu // they should be treated properly when you actually generate the world out of the noisemap // for the visualisation, no treatment will be done in this demo app. - val marblerng = HQRNG(seed) // this must be here: every slice must get identical series of random numbers - - return listOf( - Joise(groundScalingCached), - - Joise(generateRockLayer(groundScalingCached, seed, params, (0..7).map { - thicknesses[it] + marblerng.nextTriangularBal() * 0.006 to (1.04 * params.terragenTiers[3] * terragenYscaling) + it * 0.18 + marblerng.nextTriangularBal() * 0.09 - })), - ) + return if (!isAlpha2) { + val marblerng = HQRNG(seed) // this must be here: every slice must get identical series of random numbers + listOf( + Joise(groundScalingCached), + Joise(generateRockLayer(groundScalingCached, seed, params, (0..7).map { + thicknesses[it] + marblerng.nextTriangularBal() * 0.006 to (1.04 * params.strata[3].yheight.h * terragenYscaling) + it * 0.18 + marblerng.nextTriangularBal() * 0.09 + })), + ) + } + else + listOf(Joise(groundScalingCached)) } private fun generateRockLayer(ground: Module, seed: Long, params: TerragenParams, thicknessAndRange: List>): Module { @@ -229,35 +221,91 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu } } -interface TerragenParams { - val version: Long +abstract class TerragenParams { + abstract val version: Long + abstract val strata: List + abstract val featureSize: Double + abstract val lowlandScaleOffset: Double // linearly alters the height + abstract val highlandScaleOffset: Double // linearly alters the height + abstract val mountainScaleOffset: Double // linearly alters the height + abstract val mountainDisturbance: Double // greater = more distortion, overhangs + abstract val caveShapeFreq: Double //adjust the "density" of the caves + abstract val caveAttenuateScale: Double // used with the caveAttenuateBias, controls the "concentration" of the cave gen + abstract val caveAttenuateBias: Double // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) + abstract val caveAttenuateScale1: Double // used with the caveAttenuateBias, controls the "concentration" of the cave gen + abstract val caveAttenuateBias1: Double // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) + abstract val caveSelectThre: Double // also adjust this if you've touched the bias value. Number can be greater than 1.0 + abstract val caveBlockageFractalFreq: Double + abstract val caveBlockageSelectThre: Double // adjust cave closing-up strength. Lower = more closing + abstract val rockBandCutoffFreq: Double + abstract val lavaShapeFreg: Double - val terragenTiers: List - val terragenTiles: List - val featureSize: Double - val lowlandScaleOffset: Double // linearly alters the height - val highlandScaleOffset: Double // linearly alters the height - val mountainScaleOffset: Double // linearly alters the height - val mountainDisturbance: Double // greater = more distortion, overhangs - val caveShapeFreq: Double //adjust the "density" of the caves - val caveAttenuateScale: Double // used with the caveAttenuateBias, controls the "concentration" of the cave gen - val caveAttenuateBias: Double // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) - val caveAttenuateScale1: Double // used with the caveAttenuateBias, controls the "concentration" of the cave gen - val caveAttenuateBias1: Double // 1.0: flattens the gradient (deep voids are less tend to be larger). Also controls the distribution of ores. Equation: x^(log(bias) / log(0.5)) - val caveSelectThre: Double // also adjust this if you've touched the bias value. Number can be greater than 1.0 - val caveBlockageFractalFreq: Double - val caveBlockageSelectThre: Double // adjust cave closing-up strength. Lower = more closing - val rockBandCutoffFreq: Double + private val strataCache = Array?>(16) { null } - val lavaShapeFreg: Double + private fun generateStrataCache(mode: Int) { + if (strataCache[mode] != null) return + val rng = HQRNG(0x572A7AL shake mode.toLong()) + + val tilebuf = Array(2) { "" } + fun shiftTilebuf(item: String) { + tilebuf[0] = tilebuf[1] + tilebuf[1] = item + } + + strata.map { + // 0. randomiser gets two-element buffer + // 1. randomiser consults the buffer and removes matching elements from the random pool + // 2. if the pool is empty, pool is reset with the original candidates + // 3. randomiser makes random choices + // 4. if the size of the ORIGINAL candidates > 1, the chosen element gets queued into the buffer + + var tilePool = it.tiles.toMutableList() // toList makes copies, asList keeps original pointers + tilebuf.forEach { tilePool.remove(it) } + if (tilePool.isEmpty()) tilePool = it.tiles.toMutableList() + val selectedTile = tilePool[rng.nextInt(tilePool.size)] + if (it.tiles.size > 1) shiftTilebuf(selectedTile) + + StratumObj( + (if (it.yheight.v > 1.0 / 1024.0) + rng.nextDouble(it.yheight.h - it.yheight.v, it.yheight.h + it.yheight.v) + else + it.yheight.h), + selectedTile + ) + }.let { + strataCache[mode] = it + } + } + + fun getStrataForMode(mode: Int): List { + generateStrataCache(mode) + return strataCache[mode]!! + } } +/** + * @param h: STARTING height of the strata relative to the ground select gradient + * @param v: linear ± to the `h` + */ +data class Hv(val h: Double, val v: Double) +class Stratum(val yheight: Hv, vararg val tiles: ItemID) +class StratumObj(val yheight: Double, val tiles: ItemID) + data class TerragenParamsAlpha1( override val version: Long = 0L, - override val terragenTiers: List = listOf(.0, .5, 1.0, 2.5), - override val terragenTiles: List = listOf(Block.AIR, Block.DIRT, Block.STONE, Block.STONE_GNEISS), + // 0. randomiser gets two-element buffer + // 1. randomiser consults the buffer and removes matching elements from the random pool + // 2. if the pool is empty, pool is reset with the original candidates + // 3. randomiser makes random choices + // 4. if the size of the ORIGINAL candidates > 1, the chosen element gets queued into the buffer + override val strata: List = listOf( + Stratum(Hv(.0, .0), Block.AIR), + Stratum(Hv(.5, .0), Block.DIRT), + Stratum(Hv(1.0, .0), Block.STONE), + Stratum(Hv(2.5, .0), Block.STONE_GABBRO), + ), override val featureSize: Double = 333.0, override val lowlandScaleOffset: Double = -0.65, // linearly alters the height @@ -278,35 +326,43 @@ data class TerragenParamsAlpha1( override val lavaShapeFreg: Double = 0.03, -) : TerragenParams + ) : TerragenParams() data class TerragenParamsAlpha2( override val version: Long = 0x0000_000004_000004, -// override val terragenTiers: List = listOf(.0, .5, 1.5, 4.2), - override val terragenTiers: List = listOf(.0, .5, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 6.25, 6.50, 6.75, 7.0, 8.0, 9.0, 10.0, 11.0), - override val terragenTiles: List = listOf(Block.AIR, Block.DIRT, - Block.STONE, // 1.0 - Block.SANDSTONE, // 1.1 - Block.STONE_MICROCLINE, // 1.2 - Block.STONE_ORTHOCLASE, // 1.3 - Block.STONE_MARBLE, // 1.4 - Block.STONE, // 1.5 - Block.STONE_MICROCLINE, // 2.0 - Block.STONE_PLAGIOCLASE, // 3.0 - Block.STONE, // 4.0 - Block.STONE_ORTHOCLASE, // 5.0 - Block.STONE_MICROCLINE, // 6.0 + override val strata: List = listOf( + Stratum(Hv(.0, .0), Block.AIR), + Stratum(Hv(.5, .0), Block.DIRT), + Stratum(Hv(1.0, 0.03), Block.STONE, Block.STONE_LIMESTONE), + Stratum(Hv(1.1, 0.03), Block.STONE, Block.SANDSTONE, Block.STONE_LIMESTONE), + Stratum(Hv(1.2, 0.03), Block.STONE, Block.SANDSTONE, Block.STONE_LIMESTONE), + Stratum(Hv(1.3, 0.03), Block.SANDSTONE, Block.STONE_LIMESTONE, Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE), + Stratum(Hv(1.4, 0.03), Block.STONE_LIMESTONE, Block.STONE_PLAGIOCLASE, Block.SANDSTONE), + Stratum(Hv(1.5, 0.03), Block.STONE, Block.STONE_MICROCLINE, Block.STONE_LIMESTONE), - Block.STONE_MARBLE, // 6.25 - Block.STONE, // 6.50 - Block.STONE_MARBLE, // 6.75 - Block.STONE_PLAGIOCLASE, // 7.0 - Block.STONE, // 8.0 - Block.STONE_BASALT, // 9.0 - Block.STONE, // 10.0 - Block.STONE_GNEISS, // 11.0 - ), + Stratum(Hv(2.0, 0.3), Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE), + Stratum(Hv(3.0, 0.3), Block.STONE, Block.STONE_MICROCLINE, Block.STONE_LIMESTONE), + Stratum(Hv(4.0, 0.3), Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE), + Stratum(Hv(5.0, 0.3), Block.STONE, Block.STONE_MICROCLINE, Block.STONE_LIMESTONE), + Stratum(Hv(6.0, 0.3), Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE), + + Stratum(Hv(6.1, 0.03), Block.STONE_MARBLE), + Stratum(Hv(6.2, 0.03), Block.STONE, Block.STONE_PLAGIOCLASE, Block.STONE_MICROCLINE), + Stratum(Hv(6.3, 0.03), Block.STONE_SLATE), + Stratum(Hv(6.4, 0.03), Block.STONE, Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE, Block.STONE_MICROCLINE), + Stratum(Hv(6.5, 0.03), Block.STONE_MARBLE), + Stratum(Hv(6.6, 0.03), Block.STONE, Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE, Block.STONE_MICROCLINE), + Stratum(Hv(6.7, 0.03), Block.STONE_SLATE), + + Stratum(Hv(6.9, 0.06), Block.STONE, Block.STONE_ORTHOCLASE, Block.STONE_PLAGIOCLASE, Block.STONE_MICROCLINE), + + Stratum(Hv(7.0, 0.3), Block.STONE, Block.STONE_MICROCLINE), + Stratum(Hv(8.0, 0.3), Block.STONE_BASALT), + Stratum(Hv(9.0, 0.3), Block.STONE), + Stratum(Hv(10.0, 0.3), Block.STONE, Block.STONE_GABBRO), + Stratum(Hv(11.0, 0.3), Block.STONE_GABBRO), + ), override val featureSize: Double = 333.0, override val lowlandScaleOffset: Double = -0.65, // linearly alters the height @@ -327,4 +383,4 @@ data class TerragenParamsAlpha2( override val lavaShapeFreg: Double = 0.03, -) : TerragenParams \ No newline at end of file +) : TerragenParams() \ No newline at end of file diff --git a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt index 824108dcb..bb9b60d3e 100644 --- a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt +++ b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt @@ -367,6 +367,9 @@ val aquiferGrad = TerrarumModuleCacheY().also { lateinit var crudeOilGradStart: TerrarumModuleCacheY lateinit var crudeOilGrad: TerrarumModuleCacheY +lateinit var lavaPocketGradStart: TerrarumModuleCacheY +lateinit var lavaPocketGrad: TerrarumModuleCacheY + val crudeOilGradEnd = TerrarumModuleCacheY().also { it.setSource(TerrarumModuleCaveLayerClosureGrad().also { it.setH(4800.0) @@ -408,9 +411,6 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { it[it.lastIndex] = Block.AIR }*/ - private val groundDepthBlockWall = params.terragenTiles - private val groundDepthBlockTERR = groundDepthBlockWall - private fun Double.tiered(tiers: List): Int { tiers.reversed().forEachIndexed { index, it -> if (this >= it) return (tiers.lastIndex - index) // why?? @@ -424,12 +424,14 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { Block.AIR to Color(0f, 0f, 0f, 1f), Block.DIRT to Color(0.588f, 0.45f, 0.3f, 1f), Block.STONE to Color(0.4f, 0.4f, 0.4f, 1f), - Block.STONE_GNEISS to Color(0.2f, 0.2f, 0.2f, 1f), + Block.STONE_GABBRO to Color(0.2f, 0.2f, 0.2f, 1f), Block.STONE_MARBLE to Color(0.8f, 0.8f, 0.8f, 1f), Block.STONE_ORTHOCLASE to Color(0xa3836bff.toInt()), Block.STONE_PLAGIOCLASE to Color(0xaa998fff.toInt()), Block.STONE_MICROCLINE to Color(0x9ea3adff.toInt()), Block.STONE_BASALT to Color(0x3f3e3fff.toInt()), + Block.STONE_SLATE to Color(0x242730ff.toInt()), + Block.STONE_LIMESTONE to Color(0xcdcbc9ff.toInt()), Block.SANDSTONE to Color(0xe0c688ff.toInt()) ) @@ -454,31 +456,40 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { ) private val terragenYscaling = (NOISEBOX_HEIGHT / 2400.0).pow(0.75) - private val terragenTiers = (params.terragenTiers).map { it * terragenYscaling } // pow 1.0 for 1-to-1 scaling; 0.75 is used to make deep-rock layers actually deep for huge world size private fun ItemID.isRock() = this.substringAfter(':').toInt() in 16 until 32 override fun draw(x: Int, y: Int, noiseValue: List, outTex: Pixmap) { + val strataMode = 1//TODO + + val strata = params.getStrataForMode(strataMode) + val groundDepthBlock = strata.map { it.tiles } + val terragenTiers = strata.map { it.yheight * terragenYscaling } + val terr = noiseValue[0].tiered(terragenTiers) val cave = if (noiseValue[1] < 0.5) 0 else 1 val ore = (noiseValue.subList(2, noiseValue.size - 1)).zip(oreCols).firstNotNullOfOrNull { (n, colour) -> if (n > 0.5) colour else null } val isMarble = false // noiseValue[13] > 0.5 - val wallBlock = if (isMarble) Block.STONE_MARBLE else groundDepthBlockWall[terr] - val terrBlock = if (cave == 0) Block.AIR else if (isMarble) Block.STONE_MARBLE else groundDepthBlockTERR[terr] - val terrBlockNoAir = if (isMarble) Block.STONE_MARBLE else groundDepthBlockTERR[terr] + val wallBlock = if (isMarble) Block.STONE_MARBLE else groundDepthBlock[terr] + val terrBlock = if (cave == 0) Block.AIR else if (isMarble) Block.STONE_MARBLE else groundDepthBlock[terr] + val terrBlockNoAir = if (isMarble) Block.STONE_MARBLE else groundDepthBlock[terr] - val lavaVal = noiseValue[noiseValue.lastIndex - 2] + val lavaVal = noiseValue[noiseValue.lastIndex - 3] val lava = (lavaVal >= 0.5) - val waterVal = noiseValue[noiseValue.lastIndex - 1] + val waterVal = noiseValue[noiseValue.lastIndex - 2] val waterShell = (waterVal >= 0.32) val water = (waterVal >= 0.5) - val oilVal = noiseValue[noiseValue.lastIndex] - val oilShell = (oilVal >= 0.38) - val oil = (oilVal >= 0.5) + val oilVal = noiseValue[noiseValue.lastIndex - 1] + val oilShell = (oilVal >= 0.36) + val oil = (oilVal >= 0.7) + + val lavaPocketVal = noiseValue[noiseValue.lastIndex] + val lavaPocketShell = (lavaPocketVal >= 0.30) + val lavaPocket = (lavaPocketVal >= 0.5) outTex.drawPixel(x, y, if (water) WATER @@ -495,6 +506,13 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { else blockToCol[terrBlockNoAir]!!.toRGBA() } + else if (lavaPocket) LAVA + else if (lavaPocketShell) { + if (terrBlockNoAir.isRock()) + ore ?: blockToCol[Block.STONE_BASALT]!!.toRGBA() + else + blockToCol[terrBlockNoAir]!!.toRGBA() + } else if (lava) LAVA else if (ore != null && (terrBlock.isRock())) ore else if (wallBlock == Block.AIR && terrBlock == Block.AIR) BACK @@ -857,6 +875,7 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { Joise(generateSeaOfLava(seed)), Joise(generateAquifer(seed, groundScalingCached)), Joise(generateCrudeOil(seed, groundScalingCached)), + Joise(generateLavaPocket(seed, groundScalingCached)), ) } @@ -1090,12 +1109,12 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.SIMPLEX) it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC) it.setNumOctaves(4) - it.setFrequency(params.rockBandCutoffFreq / params.featureSize) + it.setFrequency(params.rockBandCutoffFreq / (params.featureSize * 1.4142)) it.seed = seed shake "CrudeOil" }) - it.setScaleX(0.16) - it.setScaleZ(0.16) - it.setScaleY(1.4) + it.setScaleX(0.23) + it.setScaleZ(0.23) + it.setScaleY(1.0) } crudeOilGradStart = TerrarumModuleCacheY().also { @@ -1127,6 +1146,50 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker { return oilLayer } + private fun generateLavaPocket(seed: Long, groundScalingCached: Module): Module { + val oilPocket = ModuleScaleDomain().also { + it.setSource(ModuleFractal().also { + it.setType(ModuleFractal.FractalType.BILLOW) + it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.SIMPLEX) + it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC) + it.setNumOctaves(4) + it.setFrequency(params.rockBandCutoffFreq / params.featureSize) + it.seed = seed shake "LavaPocket" + }) + it.setScaleX(0.5) + it.setScaleZ(0.5) + it.setScaleY(0.8) + } + + lavaPocketGradStart = TerrarumModuleCacheY().also { + it.setSource(ModuleClamp().also { + it.setSource(ModuleScaleOffset().also { + it.setSource(groundScalingCached) + it.setOffset(-4.0) + }) + it.setRange(0.0, 1.0) + }) + } + + lavaPocketGrad = TerrarumModuleCacheY().also { + it.setSource(ModuleCombiner().also { + it.setType(ModuleCombiner.CombinerType.ADD) + it.setSource(0, lavaPocketGradStart) + it.setSource(1, crudeOilGradEnd) + it.setSource(2, ModuleConstant().also { it.setConstant(-1.0) }) + }) + } + + val oilLayer = ModuleCombiner().also { + it.setType(ModuleCombiner.CombinerType.MULT) + it.setSource(0, oilPocket) + it.setSource(1, lavaPocketGrad) + } + + + return oilLayer + } + private object DummyModule : Module() { override fun get(x: Double, y: Double) = 0.0 diff --git a/work_files/graphics/terrain/terrain_variable_subtiling_full.kra b/work_files/graphics/terrain/terrain_variable_subtiling_full.kra index aca40623e..b3a246b88 100644 --- a/work_files/graphics/terrain/terrain_variable_subtiling_full.kra +++ b/work_files/graphics/terrain/terrain_variable_subtiling_full.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5c652cbcba347b5dabc1efbf163519d9c4c8f201503db8a2145b528920984418 -size 1809711 +oid sha256:66365d5d677995ee40a2c6f01dc8868ae77884ae750bcafda3fd73106db36431 +size 1848870