mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-14 23:56:07 +09:00
current terragen code backported to the noise sandbox
This commit is contained in:
@@ -16,16 +16,16 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
|||||||
import com.sudoplay.joise.Joise
|
import com.sudoplay.joise.Joise
|
||||||
import com.sudoplay.joise.module.*
|
import com.sudoplay.joise.module.*
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.random.XXHash32
|
||||||
import net.torvald.terrarum.DefaultGL32Shaders
|
import net.torvald.terrarum.DefaultGL32Shaders
|
||||||
import net.torvald.terrarum.FlippingSpriteBatch
|
import net.torvald.terrarum.FlippingSpriteBatch
|
||||||
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.concurrent.RunnableFun
|
import net.torvald.terrarum.concurrent.RunnableFun
|
||||||
import net.torvald.terrarum.concurrent.ThreadExecutor
|
import net.torvald.terrarum.concurrent.ThreadExecutor
|
||||||
import net.torvald.terrarum.concurrent.sliceEvenly
|
import net.torvald.terrarum.concurrent.sliceEvenly
|
||||||
import net.torvald.terrarum.inUse
|
import net.torvald.terrarum.inUse
|
||||||
import net.torvald.terrarum.modulebasegame.worldgenerator.BiomegenParams
|
import net.torvald.terrarum.modulebasegame.worldgenerator.*
|
||||||
import net.torvald.terrarum.modulebasegame.worldgenerator.OregenParams
|
import net.torvald.terrarum.tests.Oregen
|
||||||
import net.torvald.terrarum.modulebasegame.worldgenerator.TerragenParams
|
|
||||||
import net.torvald.terrarum.modulebasegame.worldgenerator.shake
|
|
||||||
import net.torvald.terrarum.worlddrawer.toRGBA
|
import net.torvald.terrarum.worlddrawer.toRGBA
|
||||||
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
import net.torvald.terrarumsansbitmap.gdx.TerrarumSansBitmap
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
@@ -83,9 +83,16 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
|
|
||||||
private var generationTime = 0f
|
private var generationTime = 0f
|
||||||
|
|
||||||
|
private val NM_TERR = Terragen to TerragenParams()
|
||||||
|
private val NM_BIOME = BiomeMaker to BiomegenParams()
|
||||||
|
private val NM_ORES = Oregen to OregenParams()
|
||||||
|
|
||||||
|
private val NOISEMAKER = NM_TERR
|
||||||
|
|
||||||
override fun render() {
|
override fun render() {
|
||||||
|
|
||||||
if (!initialGenDone) {
|
if (!initialGenDone) {
|
||||||
renderNoise()
|
renderNoise(NOISEMAKER)
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw using pixmap
|
// draw using pixmap
|
||||||
@@ -99,7 +106,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
if (!generateKeyLatched && Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
|
if (!generateKeyLatched && Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
|
||||||
generateKeyLatched = true
|
generateKeyLatched = true
|
||||||
seed = RNG.nextLong()
|
seed = RNG.nextLong()
|
||||||
renderNoise()
|
renderNoise(NOISEMAKER)
|
||||||
}
|
}
|
||||||
|
|
||||||
val coroutineExecFinished = genFutures.fold(true) { acc, it -> acc and (it?.isDone ?: true) }
|
val coroutineExecFinished = genFutures.fold(true) { acc, it -> acc and (it?.isDone ?: true) }
|
||||||
@@ -126,16 +133,6 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private val NOISE_MAKER = AccidentalCave
|
|
||||||
// private val NOISE_MAKER = BiomeMaker
|
|
||||||
private val NOISE_MAKER = Oregen
|
|
||||||
|
|
||||||
private fun getNoiseGenerator(SEED: Long): List<Joise> {
|
|
||||||
// return NOISE_MAKER.getGenerator(SEED, TerragenParams())
|
|
||||||
// return NOISE_MAKER.getGenerator(SEED, BiomegenParams())
|
|
||||||
return NOISE_MAKER.getGenerator(SEED, OregenParams())
|
|
||||||
}
|
|
||||||
|
|
||||||
val colourNull = Color(0x1b3281ff)
|
val colourNull = Color(0x1b3281ff)
|
||||||
|
|
||||||
private val sampleOffset = NOISEBOX_WIDTH / 8.0
|
private val sampleOffset = NOISEBOX_WIDTH / 8.0
|
||||||
@@ -173,7 +170,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun renderNoise() {
|
private fun renderNoise(noiseMaker: Pair<NoiseMaker, Any>) {
|
||||||
generationStartTime = System.nanoTime()
|
generationStartTime = System.nanoTime()
|
||||||
generationTimeInMeasure = true
|
generationTimeInMeasure = true
|
||||||
|
|
||||||
@@ -229,7 +226,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
|
|
||||||
// 2. each runner gets their own copy of Joise
|
// 2. each runner gets their own copy of Joise
|
||||||
val runnables: List<RunnableFun> = (0 until testTex.width).sliceEvenly(genSlices).map { range -> {
|
val runnables: List<RunnableFun> = (0 until testTex.width).sliceEvenly(genSlices).map { range -> {
|
||||||
val localJoise = getNoiseGenerator(seed)
|
val localJoise = noiseMaker.first.getGenerator(seed, noiseMaker.second)
|
||||||
for (x in range) {
|
for (x in range) {
|
||||||
for (y in 0 until NOISEBOX_HEIGHT) {
|
for (y in 0 until NOISEBOX_HEIGHT) {
|
||||||
val sampleTheta = (x.toDouble() / NOISEBOX_WIDTH) * TWO_PI
|
val sampleTheta = (x.toDouble() / NOISEBOX_WIDTH) * TWO_PI
|
||||||
@@ -237,7 +234,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
|
|||||||
val sampleZ = cos(sampleTheta) * sampleOffset + sampleOffset // positive points are to be sampled
|
val sampleZ = cos(sampleTheta) * sampleOffset + sampleOffset // positive points are to be sampled
|
||||||
val sampleY = y.toDouble()
|
val sampleY = y.toDouble()
|
||||||
|
|
||||||
NOISE_MAKER.draw(x, y, localJoise.map { it.get(sampleX, sampleY, sampleZ) }, testTex)
|
noiseMaker.first.draw(x, y, localJoise.map { it.get(sampleX, sampleY, sampleZ) }, testTex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
@@ -334,7 +331,7 @@ internal object BiomeMaker : NoiseMaker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// http://accidentalnoise.sourceforge.net/minecraftworlds.html
|
// http://accidentalnoise.sourceforge.net/minecraftworlds.html
|
||||||
internal object AccidentalCave : NoiseMaker {
|
internal object Terragen : NoiseMaker {
|
||||||
|
|
||||||
private infix fun Color.mul(other: Color) = this.mul(other)
|
private infix fun Color.mul(other: Color) = this.mul(other)
|
||||||
|
|
||||||
@@ -347,46 +344,41 @@ internal object AccidentalCave : NoiseMaker {
|
|||||||
Color(0.97f, 0.6f, 0.56f, 1f)
|
Color(0.97f, 0.6f, 0.56f, 1f)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val groundDepthBlock = listOf(
|
||||||
|
Block.AIR, Block.DIRT, Block.STONE, Block.STONE_SLATE
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun Double.tiered(vararg tiers: Double): Int {
|
||||||
|
tiers.reversed().forEachIndexed { index, it ->
|
||||||
|
if (this >= it) return (tiers.lastIndex - index) // why??
|
||||||
|
}
|
||||||
|
return tiers.lastIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
private val BACK = Color(0.6f, 0.66f, 0.78f, 1f).toRGBA()
|
||||||
|
|
||||||
|
private val blockToCol = hashMapOf(
|
||||||
|
Block.AIR to Color(0f, 0f, 0f, 1f),
|
||||||
|
Block.DIRT to Color(0.588f, 0.45f, 0.3f, 1f),
|
||||||
|
Block.STONE to Color(0.533f, 0.533f, 0.533f, 1f),
|
||||||
|
Block.STONE_SLATE to Color(0.233f, 0.233f, 0.233f, 1f),
|
||||||
|
)
|
||||||
|
|
||||||
override fun draw(x: Int, y: Int, noiseValue: List<Double>, outTex: Pixmap) {
|
override fun draw(x: Int, y: Int, noiseValue: List<Double>, outTex: Pixmap) {
|
||||||
// simple one-source draw
|
val terr = noiseValue[0].tiered(.0, .5, .88, 1.88)
|
||||||
/*val c = noiseValue[0].toFloat()
|
val cave = if (noiseValue[1] < 0.5) 0 else 1
|
||||||
val selector = c.minus(0.0001).floorToInt() fmod notationColours.size
|
|
||||||
val selecteeColour = Color(c - selector, c - selector, c - selector, 1f)
|
|
||||||
if (c < 0) {
|
|
||||||
outTex.setColor(-c, 0f, 0f, 1f)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
outTex.setColor(selecteeColour.mul(notationColours[selector]))
|
|
||||||
}
|
|
||||||
outTex.drawPixel(x, y)*/
|
|
||||||
|
|
||||||
|
val wallBlock = groundDepthBlock[terr]
|
||||||
|
val terrBlock = if (cave == 0) Block.AIR else wallBlock
|
||||||
|
|
||||||
fun Double.tiered(vararg tiers: Double): Int {
|
outTex.drawPixel(x, y,
|
||||||
tiers.reversed().forEachIndexed { index, it ->
|
if (wallBlock == Block.AIR && terrBlock == Block.AIR) BACK
|
||||||
if (this >= it) return (tiers.lastIndex - index) // why??
|
else blockToCol[terrBlock]!!.toRGBA()
|
||||||
}
|
|
||||||
return tiers.lastIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
val groundDepthCol = listOf(
|
|
||||||
Color(0f, 0f, 0f, 1f),
|
|
||||||
Color(0.55f, 0.4f, 0.24f, 1f),
|
|
||||||
Color(.6f, .6f, .6f, 1f)
|
|
||||||
)
|
)
|
||||||
val n1 = noiseValue[0].tiered(.0, .5, .88)
|
|
||||||
//var n2 = noiseValue[1].toFloat()
|
|
||||||
//if (n2 != 1f) n2 = 0.5f
|
|
||||||
val c1 = groundDepthCol[n1]
|
|
||||||
//val c2 = Color(n2, n2, n2, 1f)
|
|
||||||
//val cout = c1 mul c23
|
|
||||||
val cout = c1
|
|
||||||
|
|
||||||
outTex.drawPixel(x, y, cout.toRGBA())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getGenerator(seed: Long, params: Any): List<Joise> {
|
override fun getGenerator(seed: Long, params: Any): List<Joise> {
|
||||||
val params = params as TerragenParams
|
val params = params as TerragenParams
|
||||||
|
|
||||||
val lowlandMagic: Long = 0x41A21A114DBE56 // Maria Lindberg
|
val lowlandMagic: Long = 0x41A21A114DBE56 // Maria Lindberg
|
||||||
val highlandMagic: Long = 0x0114E091 // Olive Oyl
|
val highlandMagic: Long = 0x0114E091 // Olive Oyl
|
||||||
val mountainMagic: Long = 0x115AA4DE2504 // Lisa Anderson
|
val mountainMagic: Long = 0x115AA4DE2504 // Lisa Anderson
|
||||||
@@ -397,248 +389,264 @@ internal object AccidentalCave : NoiseMaker {
|
|||||||
val caveBlockageMagic: Long = 0xD15A57E5 // Disaster
|
val caveBlockageMagic: Long = 0xD15A57E5 // Disaster
|
||||||
|
|
||||||
|
|
||||||
val groundGradient = ModuleGradient()
|
val groundGradient = ModuleGradient().also {
|
||||||
groundGradient.setGradient(0.0, 0.0, 0.0, 1.0)
|
it.setGradient(0.0, 0.0, 0.0, 1.0)
|
||||||
|
}
|
||||||
|
|
||||||
/* lowlands */
|
/* lowlands */
|
||||||
|
|
||||||
val lowlandShapeFractal = ModuleFractal()
|
val lowlandShapeFractal = ModuleFractal().also {
|
||||||
lowlandShapeFractal.setType(ModuleFractal.FractalType.BILLOW)
|
it.setType(ModuleFractal.FractalType.BILLOW)
|
||||||
lowlandShapeFractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
lowlandShapeFractal.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
lowlandShapeFractal.setNumOctaves(2)
|
it.setNumOctaves(2)
|
||||||
lowlandShapeFractal.setFrequency(0.25)
|
it.setFrequency(0.25)
|
||||||
lowlandShapeFractal.seed = seed shake lowlandMagic
|
it.seed = seed shake lowlandMagic
|
||||||
|
}
|
||||||
|
|
||||||
val lowlandAutoCorrect = ModuleAutoCorrect()
|
val lowlandScale = ModuleScaleOffset().also {
|
||||||
lowlandAutoCorrect.setSource(lowlandShapeFractal)
|
it.setSource(lowlandShapeFractal)
|
||||||
lowlandAutoCorrect.setLow(0.0)
|
it.setScale(0.22)
|
||||||
lowlandAutoCorrect.setHigh(1.0)
|
it.setOffset(params.lowlandScaleOffset) // linearly alters the height
|
||||||
|
}
|
||||||
|
|
||||||
val lowlandScale = ModuleScaleOffset()
|
val lowlandYScale = ModuleScaleDomain().also {
|
||||||
lowlandScale.setScale(0.125)
|
it.setSource(lowlandScale)
|
||||||
lowlandScale.setOffset(params.lowlandScaleOffset) // TODO linearly alters the height
|
it.setScaleY(0.02) // greater = more distortion, overhangs
|
||||||
|
}
|
||||||
|
|
||||||
val lowlandYScale = ModuleScaleDomain()
|
val lowlandTerrain = ModuleTranslateDomain().also {
|
||||||
lowlandYScale.setSource(lowlandScale)
|
it.setSource(groundGradient)
|
||||||
lowlandYScale.setScaleY(0.02) // greater = more distortion, overhangs
|
it.setAxisYSource(lowlandYScale)
|
||||||
|
}
|
||||||
val lowlandTerrain = ModuleTranslateDomain()
|
|
||||||
lowlandTerrain.setSource(groundGradient)
|
|
||||||
lowlandTerrain.setAxisYSource(lowlandYScale)
|
|
||||||
|
|
||||||
/* highlands */
|
/* highlands */
|
||||||
|
|
||||||
val highlandShapeFractal = ModuleFractal()
|
val highlandShapeFractal = ModuleFractal().also {
|
||||||
highlandShapeFractal.setType(ModuleFractal.FractalType.FBM)
|
it.setType(ModuleFractal.FractalType.FBM)
|
||||||
highlandShapeFractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
highlandShapeFractal.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
highlandShapeFractal.setNumOctaves(4)
|
it.setNumOctaves(4)
|
||||||
highlandShapeFractal.setFrequency(2.0)
|
it.setFrequency(2.0)
|
||||||
highlandShapeFractal.seed = seed shake highlandMagic
|
it.seed = seed shake highlandMagic
|
||||||
|
}
|
||||||
|
|
||||||
val highlandAutocorrect = ModuleAutoCorrect()
|
val highlandScale = ModuleScaleOffset().also {
|
||||||
highlandAutocorrect.setSource(highlandShapeFractal)
|
it.setSource(highlandShapeFractal)
|
||||||
highlandAutocorrect.setLow(-1.0)
|
it.setScale(0.5)
|
||||||
highlandAutocorrect.setHigh(1.0)
|
it.setOffset(params.highlandScaleOffset) // linearly alters the height
|
||||||
|
}
|
||||||
|
|
||||||
val highlandScale = ModuleScaleOffset()
|
val highlandYScale = ModuleScaleDomain().also {
|
||||||
highlandScale.setSource(highlandAutocorrect)
|
it.setSource(highlandScale)
|
||||||
highlandScale.setScale(0.25)
|
it.setScaleY(0.14) // greater = more distortion, overhangs
|
||||||
highlandScale.setOffset(params.highlandScaleOffset) // TODO linearly alters the height
|
}
|
||||||
|
|
||||||
val highlandYScale = ModuleScaleDomain()
|
val highlandTerrain = ModuleTranslateDomain().also {
|
||||||
highlandYScale.setSource(highlandScale)
|
it.setSource(groundGradient)
|
||||||
highlandYScale.setScaleY(0.14) // greater = more distortion, overhangs
|
it.setAxisYSource(highlandYScale)
|
||||||
|
}
|
||||||
val highlandTerrain = ModuleTranslateDomain()
|
|
||||||
highlandTerrain.setSource(groundGradient)
|
|
||||||
highlandTerrain.setAxisYSource(highlandYScale)
|
|
||||||
|
|
||||||
/* mountains */
|
/* mountains */
|
||||||
|
|
||||||
val mountainShapeFractal = ModuleFractal()
|
val mountainShapeFractal = ModuleFractal().also {
|
||||||
mountainShapeFractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
mountainShapeFractal.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
mountainShapeFractal.setNumOctaves(8)
|
it.setNumOctaves(8)
|
||||||
mountainShapeFractal.setFrequency(1.0)
|
it.setFrequency(1.0)
|
||||||
mountainShapeFractal.seed = seed shake mountainMagic
|
it.seed = seed shake mountainMagic
|
||||||
|
}
|
||||||
|
|
||||||
val mountainAutocorrect = ModuleAutoCorrect()
|
val mountainScale = ModuleScaleOffset().also {
|
||||||
mountainAutocorrect.setSource(mountainShapeFractal)
|
it.setSource(mountainShapeFractal)
|
||||||
mountainAutocorrect.setLow(-1.0)
|
it.setScale(1.0)
|
||||||
mountainAutocorrect.setHigh(1.0)
|
it.setOffset(params.mountainScaleOffset) // linearly alters the height
|
||||||
|
}
|
||||||
|
|
||||||
val mountainScale = ModuleScaleOffset()
|
val mountainYScale = ModuleScaleDomain().also {
|
||||||
mountainScale.setSource(mountainAutocorrect)
|
it.setSource(mountainScale)
|
||||||
mountainScale.setScale(0.45)
|
it.setScaleY(params.mountainDisturbance) // greater = more distortion, overhangs
|
||||||
mountainScale.setOffset(params.mountainScaleOffset) // TODO linearly alters the height
|
}
|
||||||
|
|
||||||
val mountainYScale = ModuleScaleDomain()
|
val mountainTerrain = ModuleTranslateDomain().also {
|
||||||
mountainYScale.setSource(mountainScale)
|
it.setSource(groundGradient)
|
||||||
mountainYScale.setScaleY(params.mountainDisturbance) // greater = more distortion, overhangs
|
it.setAxisYSource(mountainYScale)
|
||||||
|
}
|
||||||
val mountainTerrain = ModuleTranslateDomain()
|
|
||||||
mountainTerrain.setSource(groundGradient)
|
|
||||||
mountainTerrain.setAxisYSource(mountainYScale)
|
|
||||||
|
|
||||||
/* selection */
|
/* selection */
|
||||||
|
|
||||||
val terrainTypeFractal = ModuleFractal()
|
val terrainTypeFractal = ModuleFractal().also {
|
||||||
terrainTypeFractal.setType(ModuleFractal.FractalType.FBM)
|
it.setType(ModuleFractal.FractalType.FBM)
|
||||||
terrainTypeFractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
terrainTypeFractal.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
terrainTypeFractal.setNumOctaves(3)
|
it.setNumOctaves(3)
|
||||||
terrainTypeFractal.setFrequency(0.125)
|
it.setFrequency(0.125)
|
||||||
terrainTypeFractal.seed = seed shake selectionMagic
|
it.seed = seed shake selectionMagic
|
||||||
|
}
|
||||||
|
|
||||||
val terrainAutocorrect = ModuleAutoCorrect()
|
val terrainScaleOffset = ModuleScaleOffset().also {
|
||||||
terrainAutocorrect.setSource(terrainTypeFractal)
|
it.setSource(terrainTypeFractal)
|
||||||
terrainAutocorrect.setLow(0.0)
|
it.setOffset(0.5)
|
||||||
terrainAutocorrect.setHigh(1.0)
|
it.setScale(0.666666) // greater = more dynamic terrain
|
||||||
|
}
|
||||||
|
|
||||||
val terrainTypeYScale = ModuleScaleDomain()
|
val terrainTypeYScale = ModuleScaleDomain().also {
|
||||||
terrainTypeYScale.setSource(terrainAutocorrect)
|
it.setSource(terrainScaleOffset)
|
||||||
terrainTypeYScale.setScaleY(0.0)
|
it.setScaleY(0.0)
|
||||||
|
}
|
||||||
|
|
||||||
val terrainTypeCache = ModuleCache()
|
val terrainTypeCache = ModuleCache().also {
|
||||||
terrainTypeCache.setSource(terrainTypeYScale)
|
it.setSource(terrainTypeYScale)
|
||||||
|
}
|
||||||
|
|
||||||
val highlandMountainSelect = ModuleSelect()
|
val highlandMountainSelect = ModuleSelect().also {
|
||||||
highlandMountainSelect.setLowSource(highlandTerrain)
|
it.setLowSource(highlandTerrain)
|
||||||
highlandMountainSelect.setHighSource(mountainTerrain)
|
it.setHighSource(mountainTerrain)
|
||||||
highlandMountainSelect.setControlSource(terrainTypeCache)
|
it.setControlSource(terrainTypeCache)
|
||||||
highlandMountainSelect.setThreshold(0.55)
|
it.setThreshold(0.55)
|
||||||
highlandMountainSelect.setFalloff(0.2)
|
it.setFalloff(0.2)
|
||||||
|
}
|
||||||
|
|
||||||
val highlandLowlandSelect = ModuleSelect()
|
val highlandLowlandSelect = ModuleSelect().also {
|
||||||
highlandLowlandSelect.setLowSource(lowlandTerrain)
|
it.setLowSource(lowlandTerrain)
|
||||||
highlandLowlandSelect.setHighSource(highlandMountainSelect)
|
it.setHighSource(highlandMountainSelect)
|
||||||
highlandLowlandSelect.setControlSource(terrainTypeCache)
|
it.setControlSource(terrainTypeCache)
|
||||||
highlandLowlandSelect.setThreshold(0.25)
|
it.setThreshold(0.25)
|
||||||
highlandLowlandSelect.setFalloff(0.15)
|
it.setFalloff(0.15)
|
||||||
|
}
|
||||||
|
|
||||||
val highlandLowlandSelectCache = ModuleCache()
|
val highlandLowlandSelectCache = ModuleCache().also {
|
||||||
highlandLowlandSelectCache.setSource(highlandLowlandSelect)
|
it.setSource(highlandLowlandSelect)
|
||||||
|
}
|
||||||
|
|
||||||
val groundSelect = ModuleSelect()
|
val groundSelect = ModuleSelect().also {
|
||||||
groundSelect.setLowSource(0.0)
|
it.setLowSource(0.0)
|
||||||
groundSelect.setHighSource(1.0)
|
it.setHighSource(1.0)
|
||||||
groundSelect.setThreshold(0.5)
|
it.setThreshold(0.5)
|
||||||
groundSelect.setControlSource(highlandLowlandSelectCache)
|
it.setControlSource(highlandLowlandSelectCache)
|
||||||
|
}
|
||||||
|
|
||||||
val groundSelect2 = ModuleSelect()
|
val groundSelect2 = ModuleSelect().also {
|
||||||
groundSelect2.setLowSource(0.0)
|
it.setLowSource(0.0)
|
||||||
groundSelect2.setHighSource(1.0)
|
it.setHighSource(1.0)
|
||||||
groundSelect2.setThreshold(0.8)
|
it.setThreshold(0.8)
|
||||||
groundSelect2.setControlSource(highlandLowlandSelectCache)
|
it.setControlSource(highlandLowlandSelectCache)
|
||||||
|
}
|
||||||
|
|
||||||
/* caves */
|
/* caves */
|
||||||
|
|
||||||
val caveShape = ModuleFractal()
|
val caveShape = ModuleFractal().also {
|
||||||
caveShape.setType(ModuleFractal.FractalType.RIDGEMULTI)
|
it.setType(ModuleFractal.FractalType.RIDGEMULTI)
|
||||||
caveShape.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
caveShape.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
caveShape.setNumOctaves(1)
|
it.setNumOctaves(1)
|
||||||
caveShape.setFrequency(params.caveShapeFreq) // TODO adjust the "density" of the caves
|
it.setFrequency(params.caveShapeFreq) // adjust the "density" of the caves
|
||||||
caveShape.seed = seed shake caveMagic
|
it.seed = seed shake caveMagic
|
||||||
|
}
|
||||||
|
|
||||||
val caveAttenuateBias = ModuleBias()
|
val caveAttenuateBias = ModuleBias().also {
|
||||||
caveAttenuateBias.setSource(highlandLowlandSelectCache)
|
it.setSource(highlandLowlandSelectCache)
|
||||||
caveAttenuateBias.setBias(params.caveAttenuateBias) // TODO (0.5+) adjust the "concentration" of the cave gen. Lower = larger voids
|
it.setBias(params.caveAttenuateBias) // (0.5+) adjust the "concentration" of the cave gen. Lower = larger voids
|
||||||
|
}
|
||||||
|
|
||||||
val caveShapeAttenuate = ModuleCombiner()
|
val caveShapeAttenuate = ModuleCombiner().also {
|
||||||
caveShapeAttenuate.setType(ModuleCombiner.CombinerType.MULT)
|
it.setType(ModuleCombiner.CombinerType.MULT)
|
||||||
caveShapeAttenuate.setSource(0, caveShape)
|
it.setSource(0, caveShape)
|
||||||
caveShapeAttenuate.setSource(1, caveAttenuateBias)
|
it.setSource(1, caveAttenuateBias)
|
||||||
|
}
|
||||||
|
|
||||||
val cavePerturbFractal = ModuleFractal()
|
val cavePerturbFractal = ModuleFractal().also {
|
||||||
cavePerturbFractal.setType(ModuleFractal.FractalType.FBM)
|
it.setType(ModuleFractal.FractalType.FBM)
|
||||||
cavePerturbFractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
cavePerturbFractal.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
cavePerturbFractal.setNumOctaves(6)
|
it.setNumOctaves(6)
|
||||||
cavePerturbFractal.setFrequency(3.0)
|
it.setFrequency(params.caveShapeFreq * 3.0 / 4.0)
|
||||||
cavePerturbFractal.seed = seed shake cavePerturbMagic
|
it.seed = seed shake cavePerturbMagic
|
||||||
|
}
|
||||||
|
|
||||||
val cavePerturbScale = ModuleScaleOffset()
|
val cavePerturbScale = ModuleScaleOffset().also {
|
||||||
cavePerturbScale.setSource(cavePerturbFractal)
|
it.setSource(cavePerturbFractal)
|
||||||
cavePerturbScale.setScale(0.45)
|
it.setScale(0.45)
|
||||||
cavePerturbScale.setOffset(0.0)
|
it.setOffset(0.0)
|
||||||
|
}
|
||||||
|
|
||||||
val cavePerturb = ModuleTranslateDomain()
|
val cavePerturb = ModuleTranslateDomain().also {
|
||||||
cavePerturb.setSource(caveShapeAttenuate)
|
it.setSource(caveShapeAttenuate)
|
||||||
cavePerturb.setAxisXSource(cavePerturbScale)
|
it.setAxisXSource(cavePerturbScale)
|
||||||
|
}
|
||||||
|
|
||||||
val caveSelect = ModuleSelect()
|
val caveSelect = ModuleSelect().also {
|
||||||
caveSelect.setLowSource(1.0)
|
it.setLowSource(1.0)
|
||||||
caveSelect.setHighSource(0.0)
|
it.setHighSource(0.0)
|
||||||
caveSelect.setControlSource(cavePerturb)
|
it.setControlSource(cavePerturb)
|
||||||
caveSelect.setThreshold(params.caveSelectThre) // TODO also adjust this if you've touched the bias value. Number can be greater than 1.0
|
it.setThreshold(params.caveSelectThre) // also adjust this if you've touched the bias value. Number can be greater than 1.0
|
||||||
caveSelect.setFalloff(0.0)
|
it.setFalloff(0.0)
|
||||||
|
}
|
||||||
|
|
||||||
val caveBlockageFractal = ModuleFractal()
|
val caveBlockageFractal = ModuleFractal().also {
|
||||||
caveBlockageFractal.setType(ModuleFractal.FractalType.RIDGEMULTI)
|
it.setType(ModuleFractal.FractalType.RIDGEMULTI)
|
||||||
caveBlockageFractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.GRADIENT)
|
||||||
caveBlockageFractal.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
it.setAllSourceInterpolationTypes(ModuleBasisFunction.InterpolationType.QUINTIC)
|
||||||
caveBlockageFractal.setNumOctaves(2)
|
it.setNumOctaves(2)
|
||||||
caveBlockageFractal.setFrequency(params.caveBlockageFractalFreq) // TODO same as caveShape frequency?
|
it.setFrequency(params.caveBlockageFractalFreq) // same as caveShape frequency?
|
||||||
caveBlockageFractal.seed = seed shake caveBlockageMagic
|
it.seed = seed shake caveBlockageMagic
|
||||||
|
}
|
||||||
|
|
||||||
// will only close-up deeper caves. Shallow caves will be less likely to be closed up
|
// will only close-up deeper caves. Shallow caves will be less likely to be closed up
|
||||||
val caveBlockageAttenuate = ModuleCombiner()
|
val caveBlockageAttenuate = ModuleCombiner().also {
|
||||||
caveBlockageAttenuate.setType(ModuleCombiner.CombinerType.MULT)
|
it.setType(ModuleCombiner.CombinerType.MULT)
|
||||||
caveBlockageAttenuate.setSource(0, caveBlockageFractal)
|
it.setSource(0, caveBlockageFractal)
|
||||||
caveBlockageAttenuate.setSource(1, caveAttenuateBias)
|
it.setSource(1, caveAttenuateBias)
|
||||||
|
}
|
||||||
|
|
||||||
val caveBlockageSelect = ModuleSelect()
|
val caveBlockageSelect = ModuleSelect().also {
|
||||||
caveBlockageSelect.setLowSource(0.0)
|
it.setLowSource(0.0)
|
||||||
caveBlockageSelect.setHighSource(1.0)
|
it.setHighSource(1.0)
|
||||||
caveBlockageSelect.setControlSource(caveBlockageAttenuate)
|
it.setControlSource(caveBlockageAttenuate)
|
||||||
caveBlockageSelect.setThreshold(params.caveBlockageSelectThre) // TODO adjust cave cloing-up strength. Larger = more closing
|
it.setThreshold(params.caveBlockageSelectThre) // adjust cave cloing-up strength. Larger = more closing
|
||||||
caveBlockageSelect.setFalloff(0.0)
|
it.setFalloff(0.0)
|
||||||
|
}
|
||||||
|
|
||||||
// note: gradient-multiply DOESN'T generate "naturally cramped" cave entrance
|
// note: gradient-multiply DOESN'T generate "naturally cramped" cave entrance
|
||||||
|
|
||||||
val caveInMix = ModuleCombiner()
|
val caveInMix = ModuleCombiner().also {
|
||||||
caveInMix.setType(ModuleCombiner.CombinerType.ADD)
|
it.setType(ModuleCombiner.CombinerType.ADD)
|
||||||
caveInMix.setSource(0, caveSelect)
|
it.setSource(0, caveSelect)
|
||||||
caveInMix.setSource(1, caveBlockageSelect)
|
it.setSource(1, caveBlockageSelect)
|
||||||
|
}
|
||||||
/*val groundCaveMult = ModuleCombiner()
|
|
||||||
groundCaveMult.setType(ModuleCombiner.CombinerType.MULT)
|
|
||||||
groundCaveMult.setSource(0, caveInMix)
|
|
||||||
//groundCaveMult.setSource(0, caveSelect) // disables the cave-in for quick cavegen testing
|
|
||||||
groundCaveMult.setSource(1, groundSelect)*/
|
|
||||||
|
|
||||||
// this noise tree WILL generate noise value greater than 1.0
|
// this noise tree WILL generate noise value greater than 1.0
|
||||||
// they should be treated properly when you actually generate the world out of the noisemap
|
// 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.
|
// for the visualisation, no treatment will be done in this demo app.
|
||||||
|
|
||||||
val groundClamp = ModuleClamp()
|
val groundClamp = ModuleClamp().also {
|
||||||
groundClamp.setRange(0.0, 100.0)
|
it.setRange(0.0, 100.0)
|
||||||
groundClamp.setSource(highlandLowlandSelectCache)
|
it.setSource(highlandLowlandSelectCache)
|
||||||
|
}
|
||||||
|
|
||||||
val groundScaling = ModuleScaleDomain()
|
val groundScaling = ModuleScaleDomain().also {
|
||||||
groundScaling.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
it.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
||||||
groundScaling.setScaleY(1.0 / params.featureSize)
|
it.setScaleY(1.0 / params.featureSize)
|
||||||
groundScaling.setScaleZ(1.0 / params.featureSize)
|
it.setScaleZ(1.0 / params.featureSize)
|
||||||
groundScaling.setSource(groundClamp)
|
it.setSource(groundClamp)
|
||||||
|
}
|
||||||
|
|
||||||
|
val caveClamp = ModuleClamp().also {
|
||||||
|
it.setRange(0.0, 1.0)
|
||||||
|
it.setSource(caveInMix)
|
||||||
|
}
|
||||||
|
|
||||||
val caveClamp = ModuleClamp()
|
val caveScaling = ModuleScaleDomain().also {
|
||||||
caveClamp.setRange(0.0, 1.0)
|
it.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
||||||
caveClamp.setSource(caveInMix)
|
it.setScaleY(1.0 / params.featureSize)
|
||||||
|
it.setScaleZ(1.0 / params.featureSize)
|
||||||
val caveScaling = ModuleScaleDomain()
|
it.setSource(caveClamp)
|
||||||
caveScaling.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
}
|
||||||
caveScaling.setScaleY(1.0 / params.featureSize)
|
|
||||||
caveScaling.setScaleZ(1.0 / params.featureSize)
|
|
||||||
caveScaling.setSource(caveClamp)
|
|
||||||
|
|
||||||
//return Joise(caveInMix)
|
//return Joise(caveInMix)
|
||||||
return listOf(
|
return listOf(
|
||||||
Joise(groundScaling),
|
Joise(groundScaling),
|
||||||
Joise(caveScaling)
|
Joise(caveScaling)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -701,7 +709,7 @@ internal object Oregen : NoiseMaker {
|
|||||||
|
|
||||||
val oreSelectAttenuate = ModulePow().also {
|
val oreSelectAttenuate = ModulePow().also {
|
||||||
it.setSource(ModuleGradient().also {
|
it.setSource(ModuleGradient().also {
|
||||||
it.setGradient(0.0, 0.0, NOISEBOX_HEIGHT.toDouble() * 4, 100.0)
|
it.setGradient(0.0, 0.0, NOISEBOX_HEIGHT.toDouble() * 5, 100.0)
|
||||||
})
|
})
|
||||||
it.setPower(1.0 / 4.0)
|
it.setPower(1.0 / 4.0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user