diff --git a/assets/mods/basegame/blocks/33.tga b/assets/mods/basegame/blocks/33.tga index 4a837cb22..d856dcb1b 100644 --- a/assets/mods/basegame/blocks/33.tga +++ b/assets/mods/basegame/blocks/33.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58e15698ca5858548474237a5eaa1c8dcc2f2a3ddedd975b26720b06cc76b216 -size 91410 +oid sha256:9ddab35509926975ec415e1e18666a5d9bd2a8e329875e52f091636aa0492761 +size 532242 diff --git a/assets/mods/basegame/blocks/34.tga b/assets/mods/basegame/blocks/34.tga index 3e8f55411..f92ca8946 100644 --- a/assets/mods/basegame/blocks/34.tga +++ b/assets/mods/basegame/blocks/34.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2450fdfb814d65cc6539ad4570a9bfb1d5a08e938d341a8b56550d7d07724aae -size 301074 +oid sha256:bb1f636d9df178fb98476ec5ccecbe8d5c92f56f394ba8cff75da1c67b88d10a +size 329490 diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt index 4e6862793..1ebbb046d 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt @@ -549,7 +549,15 @@ internal object BlocksDrawer { (hash ushr 25) and 7, ) val variantOps = variantOpsLUT[renderTag.tilingMode] - val subtiles = getSubtileIndexOf(tileNumberBase, nearbyTilesInfo, hash, subtileSwizzlers, variantOps) + val isGrass = (renderTag.maskType == CreateTileAtlas.RenderTag.MASK_SUBTILE_GRASS) + val nearbyGrasses = if (isGrass) { + // indices: R D L U + getNearbyTilesPos4(x, y).mapIndexed { i, it -> + BlockCodex[world.getTileFromTerrain(it.x, it.y)].hasTag("GRASS").toInt(i) + }.fold(0) { acc, it -> acc or it } + } + else null + val subtiles = getSubtileIndexOf(tileNumberBase, nearbyTilesInfo, hash, subtileSwizzlers, variantOps, nearbyGrasses) /*TL*/writeToBufferSubtile(mode, bufferBaseX * 2 + 0, bufferBaseY * 2 + 0, subtiles[0].x, subtiles[0].y, breakingStage, subtileSwizzlers[0]) /*TR*/writeToBufferSubtile(mode, bufferBaseX * 2 + 1, bufferBaseY * 2 + 0, subtiles[1].x, subtiles[1].y, breakingStage, subtileSwizzlers[1]) @@ -889,20 +897,24 @@ internal object BlocksDrawer { } /** + * @param base base full tile number in atlas + * @param nearbyTilesInfo nearbyTilesInfo (0-255) * @param variants 0-65535 + * @param subtileSwizzlers flip-rotation indices (4-element array of 0-7) + * @param variantOps operations for variant selection + * @param nearbyGrasses bitmask of nearby grasses. Marked = is grass. Indices: (RIGHT-DOWN-LEFT-UP) * * @return subtile indices on the atlas, in the following order: TL, TR, BR, BL */ - private fun getSubtileIndexOf(base: Int, nearbyTilesInfo: Int, variants: Int, subtileSwizzlers: IntArray, variantOps: Array>): List { + private fun getSubtileIndexOf(base: Int, nearbyTilesInfo: Int, variants: Int, subtileSwizzlers: IntArray, variantOps: Array>, nearbyGrasses: Int? = null): List { val variants = (0..3).map { quadrant -> (variants.ushr(quadrant * 4) and 15).let { oldIdx -> variantOps[quadrant].let { (mod, add) -> (oldIdx % mod) + add } } } val tilenumInAtlas = (0..3).map { - base.tileToSubtile() + 8*subtileVarBaseLuts[it][connectLut47[nearbyTilesInfo]].reorientSubtileUsingFliprotIdx( - subtileSwizzlers[it] - ) + val subtile = subtileVarBaseLuts[it][connectLut47[nearbyTilesInfo]].alterUsingGrassMap(it, nearbyGrasses) + base.tileToSubtile() + 8 * subtile.reorientUsingFliprotIdx(subtileSwizzlers[it]) } val baseXY = tilenumInAtlas.map { Point2i( it % App.tileMaker.SUBTILES_IN_X, @@ -918,7 +930,38 @@ internal object BlocksDrawer { ).wrapAroundAtlasBySubtile() } } - private fun Int.reorientSubtileUsingFliprotIdx(fliprotIndex: Int): Int { + private fun Int.alterUsingGrassMap(quadrant: Int, nearbyGrasses: Int?): Int { + return if (nearbyGrasses == null) this + else when (this) { + 1 -> + if (quadrant == 0) + if (nearbyGrasses and 0b0100 != 0) this else 13 + else if (quadrant == 1) + if (nearbyGrasses and 0b0001 != 0) this else 14 + else this + 7 -> + if (quadrant == 3) + if (nearbyGrasses and 0b0100 != 0) this else 18 + else if (quadrant == 2) + if (nearbyGrasses and 0b0001 != 0) this else 17 + else this + 4 -> + if (quadrant == 1) + if (nearbyGrasses and 0b1000 != 0) this else 15 + else if (quadrant == 2) + if (nearbyGrasses and 0b0010 != 0) this else 16 + else this + 10 -> + if (quadrant == 0) + if (nearbyGrasses and 0b1000 != 0) this else 20 + else if (quadrant == 3) + if (nearbyGrasses and 0b0010 != 0) this else 19 + else this + else -> this + } + } + + private fun Int.reorientUsingFliprotIdx(fliprotIndex: Int): Int { return subtileReorientLUT[fliprotIndex][this] } diff --git a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt index 5e53ce57a..93387eee6 100644 --- a/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt +++ b/src/net/torvald/terrarum/worlddrawer/CreateTileAtlas.kt @@ -263,6 +263,13 @@ class CreateTileAtlas { // PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas.tga"), atlas, false) // PixmapIO2.writeTGA(Gdx.files.absolute("${AppLoader.defaultDir}/atlasGlow.tga"), atlasGlow, false) +// PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas_0.tga"), atlasPrevernal, false) +// PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas_1.tga"), atlasVernal, false) +// PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas_2.tga"), atlasAestival, false) +// PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas_3.tga"), atlasSerotinal, false) +// PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas_4.tga"), atlasAutumnal, false) +// PixmapIO2.writeTGA(Gdx.files.absolute("${App.defaultDir}/atlas_5.tga"), atlasHibernal, false) + // Sift throuth the file list, second TGA.GZ @@ -449,8 +456,8 @@ class CreateTileAtlas { // subtitles else if (tilesPixmap.width == W_SUBTILE_GENERIC && tilesPixmap.height == H_SUBTILE || tilesPixmap.width == W_SUBTILE_GRASS && tilesPixmap.height == H_SUBTILE || - tilesPixmap.width == 3*W_SUBTILE_GENERIC && tilesPixmap.height == 2*H_SUBTILE || - tilesPixmap.width == 3*W_SUBTILE_GRASS && tilesPixmap.height == 2*H_SUBTILE) { + tilesPixmap.width == 3*W_SUBTILE_GENERIC && tilesPixmap.height == 2*H_SUBTILE-SUBTILE_SIZE || + tilesPixmap.width == 3*W_SUBTILE_GRASS && tilesPixmap.height == 2*H_SUBTILE-SUBTILE_SIZE) { // figure out the tags // tags are arranged horizontally, left-to-right, starting from (0,0) @@ -553,7 +560,7 @@ class CreateTileAtlas { val wSubtileSheet = if (renderMask >= MASK_SUBTILE_GRASS) W_SUBTILE_GRASS else W_SUBTILE_GENERIC val hSubtileSheet = H_SUBTILE - val sixSeasonal = (renderMask >= MASK_SUBTILE_GENERIC && diffuse.width == 3 * wSubtileSheet && diffuse.height == 2 * hSubtileSheet) || + val sixSeasonal = (renderMask >= MASK_SUBTILE_GENERIC && diffuse.width == 3 * wSubtileSheet && diffuse.height == 2 * hSubtileSheet - SUBTILE_SIZE) || (renderMask < MASK_SUBTILE_GENERIC && diffuse.width == 336 && diffuse.height == 224) val txOfPixmap = diffuse.width / TILE_SIZE val txOfPixmapGlow = glow.width / TILE_SIZE @@ -575,9 +582,9 @@ class CreateTileAtlas { _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 1*wSubtileSheet, srcY, VERNAL) _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 2*wSubtileSheet, srcY, AESTIVAL) - _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 2*wSubtileSheet, srcY + hSubtileSheet, SEROTINAL) - _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 1*wSubtileSheet, srcY + hSubtileSheet, AUTUMNAL) - _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 0*wSubtileSheet, srcY + hSubtileSheet, HIBERNAL) + _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 2*wSubtileSheet, srcY + hSubtileSheet - SUBTILE_SIZE, SEROTINAL) + _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 1*wSubtileSheet, srcY + hSubtileSheet - SUBTILE_SIZE, AUTUMNAL) + _drawToAtlantesFourSubtiles(diffuse, atlasCursor, srcX + 0*wSubtileSheet, srcY + hSubtileSheet - SUBTILE_SIZE, HIBERNAL) _drawToAtlantesFourSubtiles(glow, atlasCursor, srcX, srcY, GLOW) _drawToAtlantesFourSubtiles(emissive, atlasCursor, srcX, srcY, EMISSIVE) diff --git a/work_files/graphics/terrain/terrain_variable_subtiling_full.kra b/work_files/graphics/terrain/terrain_variable_subtiling_full.kra index a9ae32082..1f09d0586 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:41fd40263e5fcf01a3250dfe3994b9daf687c3ed5586c3f719409ebba56af832 -size 819317 +oid sha256:06dadc8a7fec2e5a1269f691317158a1fbbd0e5e5e345a571d6ac139502af784 +size 1096488