mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
better ore texture
This commit is contained in:
BIN
assets/mods/basegame/ores/1.tga
LFS
BIN
assets/mods/basegame/ores/1.tga
LFS
Binary file not shown.
BIN
assets/mods/basegame/ores/2.tga
LFS
BIN
assets/mods/basegame/ores/2.tga
LFS
Binary file not shown.
BIN
assets/mods/basegame/ores/3.tga
LFS
Normal file
BIN
assets/mods/basegame/ores/3.tga
LFS
Normal file
Binary file not shown.
@@ -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"
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 3.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 2.
|
@@ -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<It
|
||||
threadExecutor.join()
|
||||
}
|
||||
|
||||
private fun getHashCoord(x: Int, y: Int, mod: Int) =
|
||||
(XXHash64.hash((y.toLong().shl(32) or x.toLong().and(0xFFFFFFFF)).toBig64(), mod.toLong()).and(0x7FFFFFFFFFFFFFFFL) % mod).toInt()
|
||||
|
||||
private fun draw(x: Int) {
|
||||
for (y in 0 until world.height) {
|
||||
@@ -52,6 +55,22 @@ class OregenAutotiling(world: GameWorld, seed: Long, val tilingModes: HashMap<It
|
||||
BlocksDrawer.connectLut16[autotiled]
|
||||
|
||||
}
|
||||
"a16x4" -> {
|
||||
// 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<It
|
||||
BlocksDrawer.connectLut47[autotiled]
|
||||
}
|
||||
"r16" -> {
|
||||
(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")
|
||||
}
|
||||
|
||||
@@ -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)),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
BIN
work_files/graphics/terrain/coal_layer.kra
LFS
Normal file
BIN
work_files/graphics/terrain/coal_layer.kra
LFS
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user