diff --git a/assets/mods/basegame/ores/1.tga b/assets/mods/basegame/ores/1.tga index 012aac24d..00ff74112 100644 --- a/assets/mods/basegame/ores/1.tga +++ b/assets/mods/basegame/ores/1.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3fd652b5ed8f82ffc51e4e6e9cd5136b612fb7a30f1d1464a176078e3e1e18f7 -size 16402 +oid sha256:01d26c89135355a8c6cecbf45b9be85d83527fcd82ac68a0fb9f587ab460f062 +size 262162 diff --git a/assets/mods/basegame/ores/2.tga b/assets/mods/basegame/ores/2.tga index 172df4b2b..87c0ab3aa 100644 --- a/assets/mods/basegame/ores/2.tga +++ b/assets/mods/basegame/ores/2.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65f4146699b95ee6cc5552f378a6be055a4c680d63a2f561e21f9c8b7a352ccc -size 16402 +oid sha256:ece800ce7990d383ae30439f45385f0196c7268a33bac21176d3507d8b45b97e +size 262162 diff --git a/assets/mods/basegame/ores/3.tga b/assets/mods/basegame/ores/3.tga new file mode 100644 index 000000000..fd4e816b9 --- /dev/null +++ b/assets/mods/basegame/ores/3.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e6bdb3357e4b0bb112db35da06252a56e7570bed952bcdf7784ca5b6624ddad +size 65554 diff --git a/assets/mods/basegame/ores/ores.csv b/assets/mods/basegame/ores/ores.csv index 11fb133aa..bd6857ed3 100644 --- a/assets/mods/basegame/ores/ores.csv +++ b/assets/mods/basegame/ores/ores.csv @@ -1,8 +1,8 @@ "id";"item";"tags" "1";"item@basegame:128";"COPPER,MALACHITE" "2";"item@basegame:129";"IRON,HEMATITE" -# "3";"item@basegame:130";"GOLD,NATURAL_GOLD" -# "4";"item@basegame:131";"COAL,CARBON" + "3";"item@basegame:130";"COAL,CARBON" +# "4";"item@basegame:131";"GOLD,NATURAL_GOLD" # "5";"item@basegame:132";"ZINC,SPHALERITE" # "6";"item@basegame:133";"TITANIUM,RUTILE" # "7";"item@basegame:134";"GEM,RUBY" diff --git a/assets/mods/basegame/ores/worldgen.csv b/assets/mods/basegame/ores/worldgen.csv index f914f9324..343156a1d 100644 --- a/assets/mods/basegame/ores/worldgen.csv +++ b/assets/mods/basegame/ores/worldgen.csv @@ -1,7 +1,7 @@ "id";"freq";"power";"scale";"ratio";"tiling";"comment" -"1";"0.026";"0.01";"0.505";"1.0";"a16";"copper (malachite)" -"2";"0.040";"0.01";"0.505";"1.0";"a16";"iron (haematite)" -#"3";"0.040";"0.08";"0.501";"1.0";"r16";"coal" +"1";"0.026";"0.01";"0.505";"1.0";"a16x16";"copper (malachite)" +"2";"0.040";"0.01";"0.505";"1.0";"a16x16";"iron (haematite)" +"3";"0.040";"0.08";"0.493";"10.0";"a16x4";"coal" ################################################################################ @@ -14,6 +14,8 @@ # # tiling: determines how the tiles are tiled # - a16: use 4-neighbour autotiling (16 possible cases) +# - a16x4: 4 variants of a16 +# - a16x16: 16 variants of a16 # - a47: use 8-neighbour autotiling (47 possible cases) # - r16: use the hash of the tile position as a variant selection, module 16 # - r8: use the hash of the tile position as a variant selection, module 8 diff --git a/src/net/torvald/terrarum/modulebasegame/worldgenerator/OregenAutotiling.kt b/src/net/torvald/terrarum/modulebasegame/worldgenerator/OregenAutotiling.kt index d6fd36d2c..951415e7c 100644 --- a/src/net/torvald/terrarum/modulebasegame/worldgenerator/OregenAutotiling.kt +++ b/src/net/torvald/terrarum/modulebasegame/worldgenerator/OregenAutotiling.kt @@ -6,6 +6,7 @@ import net.torvald.terrarum.concurrent.sliceEvenly import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.gameitems.isOre import net.torvald.terrarum.gameworld.GameWorld +import net.torvald.terrarum.gameworld.fmod import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.terrarum.serialise.toBig64 import net.torvald.terrarum.toInt @@ -34,6 +35,8 @@ class OregenAutotiling(world: GameWorld, seed: Long, val tilingModes: HashMap { + // get placement (tile connection) info + val mult = getHashCoord(x, y, 4) + val autotiled = getNearbyOres8(x, y).foldIndexed(0) { index, acc, placement -> + acc or (placement.item == ore).toInt(index) + } + BlocksDrawer.connectLut16[autotiled] or mult.shl(4) + } + "a16x16" -> { + // get placement (tile connection) info + val mult = getHashCoord(x, y, 16) + val autotiled = getNearbyOres8(x, y).foldIndexed(0) { index, acc, placement -> + acc or (placement.item == ore).toInt(index) + } + BlocksDrawer.connectLut16[autotiled] or mult.shl(4) + } "a47" -> { // get placement (tile connection) info val autotiled = getNearbyOres8(x, y).foldIndexed(0) { index, acc, placement -> @@ -60,10 +79,10 @@ class OregenAutotiling(world: GameWorld, seed: Long, val tilingModes: HashMap { - (XXHash64.hash((y.toLong().shl(32) or x.toLong().and(0xFFFFFFFF)).toBig64(), 16L) % 16).toInt() + getHashCoord(x, y, 16) } "r8" -> { - (XXHash64.hash((y.toLong().shl(32) or x.toLong().and(0xFFFFFFFF)).toBig64(), 8L) % 8).toInt() + getHashCoord(x, y, 8) } else -> throw IllegalArgumentException("Unknown tiling mode: $tilingMode") } diff --git a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt index edf740a07..5424d26f0 100644 --- a/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt +++ b/src/net/torvald/terrarum/tests/WorldgenNoiseSandbox.kt @@ -691,7 +691,7 @@ internal object TerragenTest : NoiseMaker { Joise(caveScaling), Joise(generateOreVeinModule(caveAttenuateBiasScaled, seed shake "ores@basegame:1", 0.024, 0.01, 0.505, 1.0)), Joise(generateOreVeinModule(caveAttenuateBiasScaled, seed shake "ores@basegame:2", 0.04, 0.01, 0.505, 1.0)), - Joise(generateOreVeinModule(caveAttenuateBiasScaled, seed shake "ores@basegame:3", 0.04, 0.01, 0.505, 10.0)), + Joise(generateOreVeinModule(caveAttenuateBiasScaled, seed shake "ores@basegame:3", 0.04, 0.08, 0.493, 5.0)), ) } diff --git a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt index 599412df8..7bb0bafa4 100644 --- a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt +++ b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt @@ -16,6 +16,7 @@ import net.torvald.terrarum.gameitems.ItemID import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.utils.HashArray import net.torvald.terrarum.worlddrawer.CreateTileAtlas.AtlasSource.* +import net.torvald.terrarum.worlddrawer.CreateTileAtlas.RenderTag.Companion.MASK_47 import kotlin.math.roundToInt import kotlin.math.sqrt @@ -319,22 +320,32 @@ class CreateTileAtlas { // predefined by the image dimension: 16x16 for (1,0) if (tilesPixmap.width == TILE_SIZE && tilesPixmap.height == TILE_SIZE) { addTag(blockID, RenderTag.CONNECT_SELF, RenderTag.MASK_NA) - drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.maskTypeToTileCount(RenderTag.MASK_NA)) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.MASK_NA) } // predefined by the image dimension: 64x16 for (2,3) else if (tilesPixmap.width == TILE_SIZE * 4 && tilesPixmap.height == TILE_SIZE) { addTag(blockID, RenderTag.CONNECT_WALL_STICKER, RenderTag.MASK_TORCH) - drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.maskTypeToTileCount(RenderTag.MASK_TORCH)) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.MASK_TORCH) } // predefined by the image dimension: 128x16 for (3,4) else if (tilesPixmap.width == TILE_SIZE * 8 && tilesPixmap.height == TILE_SIZE) { addTag(blockID, RenderTag.CONNECT_WALL_STICKER_CONNECT_SELF, RenderTag.MASK_PLATFORM) - drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.maskTypeToTileCount(RenderTag.MASK_PLATFORM)) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.MASK_PLATFORM) } // predefined by the image dimension: 256x16 else if (tilesPixmap.width == TILE_SIZE * 16 && tilesPixmap.height == TILE_SIZE) { addTag(blockID, RenderTag.CONNECT_SELF, RenderTag.MASK_16) - drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.maskTypeToTileCount(RenderTag.MASK_16)) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.MASK_16) + } + // predefined by the image dimension: 256x64 + else if (tilesPixmap.width == TILE_SIZE * 16 && tilesPixmap.height == TILE_SIZE * 4) { + addTag(blockID, RenderTag.CONNECT_SELF, RenderTag.MASK_16X4) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.MASK_16X4) + } + // predefined by the image dimension: 256x256 + else if (tilesPixmap.width == TILE_SIZE * 16 && tilesPixmap.height == TILE_SIZE * 16) { + addTag(blockID, RenderTag.CONNECT_SELF, RenderTag.MASK_16X16) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, RenderTag.MASK_16X16) } // 112x112 or 224x224 else { @@ -355,8 +366,7 @@ class CreateTileAtlas { } addTag(blockID, connectionType, maskType) - val tileCount = RenderTag.maskTypeToTileCount(maskType) - drawToAtlantes(tilesPixmap, tilesGlowPixmap, tileCount) + drawToAtlantes(tilesPixmap, tilesGlowPixmap, maskType) } itemSheetNumbers[blockID] = itemSheetCursor @@ -385,7 +395,8 @@ class CreateTileAtlas { printdbg(this, "tileName ${id} ->> tileNumber ${atlasCursor}") } - private fun drawToAtlantes(matte: Pixmap, glow: Pixmap, tilesCount: Int) { + private fun drawToAtlantes(matte: Pixmap, glow: Pixmap, renderMask: Int) { + val tilesCount = RenderTag.maskTypeToTileCount(renderMask) if (atlasCursor + tilesCount >= TOTAL_TILES) { // throw Error("Too much tiles for $MAX_TEX_SIZE texture size: $atlasCursor") println("[CreateTileAtlas] Too much tiles for atlas of ${MAX_TEX_SIZE}x$MAX_TEX_SIZE (tiles so far: $atlasCursor/${(MAX_TEX_SIZE*MAX_TEX_SIZE)/(TILE_SIZE* TILE_SIZE)}, tiles to be added: $tilesCount), trying to expand the atlas...") @@ -400,7 +411,7 @@ class CreateTileAtlas { // different texture for different seasons (224x224) if (sixSeasonal) { - val i = if (i < 41) i else i + 1 // to compensate the discontinuity between 40th and 41st tile + val i = if (renderMask == MASK_47) (if (i < 41) i else i + 1) else i // to compensate the discontinuity between 40th and 41st tile _drawToAtlantes(matte, atlasCursor, i % 7 , i / 7, PREVERNAL) _drawToAtlantes(matte, atlasCursor, i % 7 + 7 , i / 7, VERNAL) _drawToAtlantes(matte, atlasCursor, i % 7 + 14, i / 7, AESTIVAL) @@ -413,7 +424,7 @@ class CreateTileAtlas { atlasCursor += 1 } else { - val i = if (i < 41) i else i + 1 // to compensate the discontinuity between 40th and 41st tile + val i = if (renderMask == MASK_47) (if (i < 41) i else i + 1) else i // to compensate the discontinuity between 40th and 41st tile _drawToAtlantes(matte, atlasCursor, i % txOfPixmap, i / txOfPixmap, SIX_SEASONS) _drawToAtlantes(glow, atlasCursor, i % txOfPixmapGlow, i / txOfPixmapGlow, GLOW) atlasCursor += 1 @@ -470,6 +481,8 @@ class CreateTileAtlas { const val MASK_47 = 2 const val MASK_TORCH = 3 const val MASK_PLATFORM = 4 + const val MASK_16X4 = 5 + const val MASK_16X16 = 6 fun maskTypeToTileCount(maskType: Int) = when (maskType) { MASK_NA -> 1 @@ -477,6 +490,8 @@ class CreateTileAtlas { MASK_47 -> 47 MASK_TORCH -> 4 MASK_PLATFORM -> 8 + MASK_16X4 -> 64 + MASK_16X16 -> 256 else -> throw IllegalArgumentException("Unknown maskType: $maskType") } } diff --git a/work_files/graphics/terrain/coal_layer.kra b/work_files/graphics/terrain/coal_layer.kra new file mode 100644 index 000000000..9b0576876 --- /dev/null +++ b/work_files/graphics/terrain/coal_layer.kra @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:302824c6f51b20ad4d25efb149f5dbaaa2abec45250ef38c022be736abdefcff +size 106442 diff --git a/work_files/graphics/terrain/ore_mask_sample.kra b/work_files/graphics/terrain/ore_mask_sample.kra index a7903fba8..106767ac2 100644 --- a/work_files/graphics/terrain/ore_mask_sample.kra +++ b/work_files/graphics/terrain/ore_mask_sample.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:865d139ec29f26da1242189e9ec4d1d251b5b2f1e7ecee97d37e2206ed741b30 -size 96275 +oid sha256:3bdf5ed54142ab44af7f65e24a86f8d05c34638053c17e7f4dbfa70b37fbe42a +size 574724