mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 14:21:52 +09:00
newer terragen test wip
This commit is contained in:
@@ -12,8 +12,12 @@ object Block {
|
||||
const val STONE_QUARRIED = "basegame:17"
|
||||
const val STONE_TILE_WHITE = "basegame:18"
|
||||
const val STONE_BRICKS = "basegame:19"
|
||||
const val STONE_SLATE = "basegame:20"
|
||||
const val STONE_GNEISS = "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 DIRT = "basegame:32"
|
||||
const val GRASS = "basegame:33"
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.sudoplay.joise.module.*
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.LoadScreenBase
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.Worldgen.getClampedHeight
|
||||
import net.torvald.terrarum.realestate.LandUtil.CHUNK_H
|
||||
@@ -34,7 +35,7 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu
|
||||
|
||||
|
||||
private val groundDepthBlock = listOf(
|
||||
Block.AIR, Block.DIRT, Block.STONE, Block.STONE_SLATE
|
||||
Block.AIR, Block.DIRT, Block.STONE, Block.STONE_GNEISS
|
||||
)
|
||||
|
||||
private fun Double.tiered(tiers: List<Double>): Int {
|
||||
@@ -229,7 +230,10 @@ class Terragen(world: GameWorld, isFinal: Boolean, val groundScalingCached: Modu
|
||||
}
|
||||
|
||||
interface TerragenParams {
|
||||
val version: Long
|
||||
|
||||
val terragenTiers: List<Double>
|
||||
val terragenTiles: List<ItemID>
|
||||
val featureSize: Double
|
||||
val lowlandScaleOffset: Double // linearly alters the height
|
||||
val highlandScaleOffset: Double // linearly alters the height
|
||||
@@ -245,10 +249,15 @@ interface TerragenParams {
|
||||
val caveBlockageSelectThre: Double // adjust cave closing-up strength. Lower = more closing
|
||||
val rockBandCutoffFreq: Double
|
||||
|
||||
val lavaShapeFreg: Double }
|
||||
val lavaShapeFreg: Double
|
||||
|
||||
}
|
||||
|
||||
data class TerragenParamsAlpha1(
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.0, 2.5, 11.0 * 9999),
|
||||
override val version: Long = 0L,
|
||||
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.0, 2.5),
|
||||
override val terragenTiles: List<ItemID> = listOf(Block.AIR, Block.DIRT, Block.STONE, Block.STONE_GNEISS),
|
||||
|
||||
override val featureSize: Double = 333.0,
|
||||
override val lowlandScaleOffset: Double = -0.65, // linearly alters the height
|
||||
@@ -268,10 +277,36 @@ data class TerragenParamsAlpha1(
|
||||
override val rockBandCutoffFreq: Double = 4.0,
|
||||
|
||||
override val lavaShapeFreg: Double = 0.03,
|
||||
|
||||
) : TerragenParams
|
||||
|
||||
data class TerragenParamsAlpha2(
|
||||
override val terragenTiers: List<Double> = listOf(.0, .5, 1.5, 4.2, 11.0 * 9999),
|
||||
override val version: Long = 0x0000_000004_000004,
|
||||
|
||||
// override val terragenTiers: List<Double> = listOf(.0, .5, 1.5, 4.2),
|
||||
override val terragenTiers: List<Double> = 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<ItemID> = 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
|
||||
|
||||
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
|
||||
),
|
||||
|
||||
override val featureSize: Double = 333.0,
|
||||
override val lowlandScaleOffset: Double = -0.65, // linearly alters the height
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.FlippingSpriteBatch
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.concurrent.ThreadExecutor
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.inUse
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.BiomegenParams
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.TerragenParams
|
||||
@@ -43,6 +44,8 @@ const val NOISEBOX_WIDTH = 90 * 18
|
||||
const val NOISEBOX_HEIGHT = 90 * 26
|
||||
const val TWO_PI = Math.PI * 2
|
||||
|
||||
//const val WORLDGEN_YOFF = 0
|
||||
//const val WORLDGEN_YOFF = 1500
|
||||
const val WORLDGEN_YOFF = 5400 - NOISEBOX_HEIGHT
|
||||
|
||||
/**
|
||||
@@ -398,12 +401,15 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker {
|
||||
Color(0.97f, 0.6f, 0.56f, 1f)
|
||||
)
|
||||
|
||||
private val groundDepthBlockWall = listOf(
|
||||
/*private val groundDepthBlockWall = listOf(
|
||||
Block.AIR, Block.DIRT, Block.STONE, Block.STONE_SLATE, Block.STONE_SLATE
|
||||
)
|
||||
private val groundDepthBlockTERR = ArrayList(groundDepthBlockWall).also {
|
||||
it[it.lastIndex] = Block.AIR
|
||||
}
|
||||
}*/
|
||||
|
||||
private val groundDepthBlockWall = params.terragenTiles
|
||||
private val groundDepthBlockTERR = groundDepthBlockWall
|
||||
|
||||
private fun Double.tiered(tiers: List<Double>): Int {
|
||||
tiers.reversed().forEachIndexed { index, it ->
|
||||
@@ -418,8 +424,13 @@ 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_SLATE to Color(0.2f, 0.2f, 0.2f, 1f),
|
||||
Block.STONE_MARBLE to Color(0.8f, 0.8f, 0.8f, 1f)
|
||||
Block.STONE_GNEISS 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.SANDSTONE to Color(0xe0c688ff.toInt())
|
||||
)
|
||||
|
||||
private val COPPER_ORE = 0x00e9c8ff.toInt()
|
||||
@@ -445,6 +456,8 @@ 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<Double>, outTex: Pixmap) {
|
||||
val terr = noiseValue[0].tiered(terragenTiers)
|
||||
val cave = if (noiseValue[1] < 0.5) 0 else 1
|
||||
@@ -470,20 +483,20 @@ internal class TerragenTest(val params: TerragenParams) : NoiseMaker {
|
||||
outTex.drawPixel(x, y,
|
||||
if (water) WATER
|
||||
else if (waterShell) {
|
||||
if ((terrBlockNoAir == Block.STONE || terrBlockNoAir == Block.STONE_SLATE))
|
||||
if (terrBlockNoAir.isRock())
|
||||
ore ?: blockToCol[terrBlockNoAir]!!.toRGBA()
|
||||
else
|
||||
blockToCol[terrBlockNoAir]!!.toRGBA()
|
||||
}
|
||||
else if (oil) OIL
|
||||
else if (oilShell) {
|
||||
if ((terrBlockNoAir == Block.STONE || terrBlockNoAir == Block.STONE_SLATE))
|
||||
if (terrBlockNoAir.isRock())
|
||||
ore ?: blockToCol[terrBlockNoAir]!!.toRGBA()
|
||||
else
|
||||
blockToCol[terrBlockNoAir]!!.toRGBA()
|
||||
}
|
||||
else if (lava) LAVA
|
||||
else if (ore != null && (terrBlock == Block.STONE || terrBlock == Block.STONE_SLATE)) ore
|
||||
else if (ore != null && (terrBlock.isRock())) ore
|
||||
else if (wallBlock == Block.AIR && terrBlock == Block.AIR) BACK
|
||||
else blockToCol[terrBlock]!!.toRGBA()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user