mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
no autocorrect on biomegen; code structure improvements
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.worldgenerator
|
package net.torvald.terrarum.modulebasegame.worldgenerator
|
||||||
|
|
||||||
import com.sudoplay.joise.Joise
|
import com.sudoplay.joise.Joise
|
||||||
import com.sudoplay.joise.module.ModuleAutoCorrect
|
import com.sudoplay.joise.module.*
|
||||||
import com.sudoplay.joise.module.ModuleBasisFunction
|
|
||||||
import com.sudoplay.joise.module.ModuleFractal
|
|
||||||
import com.sudoplay.joise.module.ModuleScaleDomain
|
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.concurrent.ThreadExecutor
|
import net.torvald.terrarum.concurrent.ThreadExecutor
|
||||||
@@ -76,7 +73,7 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun draw(x: Int, y: Int, noiseValue: List<Double>, world: GameWorld) {
|
private fun draw(x: Int, y: Int, noiseValue: List<Double>, world: GameWorld) {
|
||||||
val control = noiseValue[0].times(slices).minus(0.00001f).toInt().fmod(slices)
|
val control = noiseValue[0].coerceIn(0.0, 0.99999).times(slices).toInt().coerceIn(0 until slices)
|
||||||
|
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
val tileThis = world.getTileFromTerrain(x, y)
|
val tileThis = world.getTileFromTerrain(x, y)
|
||||||
@@ -123,22 +120,26 @@ class Biomegen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
|||||||
//biome.setType(ModuleBasisFunction.BasisType.SIMPLEX)
|
//biome.setType(ModuleBasisFunction.BasisType.SIMPLEX)
|
||||||
|
|
||||||
// simplex AND fractal for more noisy edges, mmmm..!
|
// simplex AND fractal for more noisy edges, mmmm..!
|
||||||
val fractal = ModuleFractal()
|
val fractal = ModuleFractal().also {
|
||||||
fractal.setType(ModuleFractal.FractalType.MULTI)
|
it.setType(ModuleFractal.FractalType.MULTI)
|
||||||
fractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.SIMPLEX)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.SIMPLEX)
|
||||||
fractal.setNumOctaves(4)
|
it.setNumOctaves(4)
|
||||||
fractal.setFrequency(1.0)
|
it.setFrequency(1.0)
|
||||||
fractal.seed = seed shake 0x7E22A
|
it.seed = seed shake 0x7E22A
|
||||||
|
}
|
||||||
|
|
||||||
val autocorrect = ModuleAutoCorrect()
|
val scaleDomain = ModuleScaleDomain().also {
|
||||||
autocorrect.setSource(fractal)
|
it.setSource(fractal)
|
||||||
autocorrect.setRange(0.0, 1.0)
|
it.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
||||||
|
it.setScaleY(1.0 / params.featureSize)
|
||||||
|
it.setScaleZ(1.0 / params.featureSize)
|
||||||
|
}
|
||||||
|
|
||||||
val scale = ModuleScaleDomain()
|
val scale = ModuleScaleOffset().also {
|
||||||
scale.setSource(autocorrect)
|
it.setSource(scaleDomain)
|
||||||
scale.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
it.setOffset(1.0)
|
||||||
scale.setScaleY(1.0 / params.featureSize)
|
it.setScale(1.0)
|
||||||
scale.setScaleZ(1.0 / params.featureSize)
|
}
|
||||||
|
|
||||||
val last = scale
|
val last = scale
|
||||||
|
|
||||||
|
|||||||
@@ -144,223 +144,259 @@ class Terragen(world: GameWorld, seed: Long, params: Any) : Gen(world, seed, par
|
|||||||
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 lowlandScale = ModuleScaleOffset()
|
val lowlandScale = ModuleScaleOffset().also {
|
||||||
lowlandScale.setSource(lowlandShapeFractal)
|
it.setSource(lowlandShapeFractal)
|
||||||
lowlandScale.setScale(0.22)
|
it.setScale(0.22)
|
||||||
lowlandScale.setOffset(params.lowlandScaleOffset) // TODO linearly alters the height
|
it.setOffset(params.lowlandScaleOffset) // linearly alters the height
|
||||||
|
}
|
||||||
|
|
||||||
val lowlandYScale = ModuleScaleDomain()
|
val lowlandYScale = ModuleScaleDomain().also {
|
||||||
lowlandYScale.setSource(lowlandScale)
|
it.setSource(lowlandScale)
|
||||||
lowlandYScale.setScaleY(0.02) // greater = more distortion, overhangs
|
it.setScaleY(0.02) // greater = more distortion, overhangs
|
||||||
|
}
|
||||||
|
|
||||||
val lowlandTerrain = ModuleTranslateDomain()
|
val lowlandTerrain = ModuleTranslateDomain().also {
|
||||||
lowlandTerrain.setSource(groundGradient)
|
it.setSource(groundGradient)
|
||||||
lowlandTerrain.setAxisYSource(lowlandYScale)
|
it.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 highlandScale = ModuleScaleOffset()
|
val highlandScale = ModuleScaleOffset().also {
|
||||||
highlandScale.setSource(highlandShapeFractal)
|
it.setSource(highlandShapeFractal)
|
||||||
highlandScale.setScale(0.5)
|
it.setScale(0.5)
|
||||||
highlandScale.setOffset(params.highlandScaleOffset) // TODO linearly alters the height
|
it.setOffset(params.highlandScaleOffset) // linearly alters the height
|
||||||
|
}
|
||||||
|
|
||||||
val highlandYScale = ModuleScaleDomain()
|
val highlandYScale = ModuleScaleDomain().also {
|
||||||
highlandYScale.setSource(highlandScale)
|
it.setSource(highlandScale)
|
||||||
highlandYScale.setScaleY(0.14) // greater = more distortion, overhangs
|
it.setScaleY(0.14) // greater = more distortion, overhangs
|
||||||
|
}
|
||||||
|
|
||||||
val highlandTerrain = ModuleTranslateDomain()
|
val highlandTerrain = ModuleTranslateDomain().also {
|
||||||
highlandTerrain.setSource(groundGradient)
|
it.setSource(groundGradient)
|
||||||
highlandTerrain.setAxisYSource(highlandYScale)
|
it.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 mountainScale = ModuleScaleOffset()
|
val mountainScale = ModuleScaleOffset().also {
|
||||||
mountainScale.setSource(mountainShapeFractal)
|
it.setSource(mountainShapeFractal)
|
||||||
mountainScale.setScale(1.0)
|
it.setScale(1.0)
|
||||||
mountainScale.setOffset(params.mountainScaleOffset) // TODO linearly alters the height
|
it.setOffset(params.mountainScaleOffset) // linearly alters the height
|
||||||
|
}
|
||||||
|
|
||||||
val mountainYScale = ModuleScaleDomain()
|
val mountainYScale = ModuleScaleDomain().also {
|
||||||
mountainYScale.setSource(mountainScale)
|
it.setSource(mountainScale)
|
||||||
mountainYScale.setScaleY(params.mountainDisturbance) // greater = more distortion, overhangs
|
it.setScaleY(params.mountainDisturbance) // greater = more distortion, overhangs
|
||||||
|
}
|
||||||
|
|
||||||
val mountainTerrain = ModuleTranslateDomain()
|
val mountainTerrain = ModuleTranslateDomain().also {
|
||||||
mountainTerrain.setSource(groundGradient)
|
it.setSource(groundGradient)
|
||||||
mountainTerrain.setAxisYSource(mountainYScale)
|
it.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() // absolutely required
|
val terrainAutocorrect = ModuleAutoCorrect().also { // absolutely required
|
||||||
terrainAutocorrect.setSource(terrainTypeFractal)
|
it.setSource(terrainTypeFractal)
|
||||||
terrainAutocorrect.setLow(0.0)
|
it.setLow(0.0)
|
||||||
terrainAutocorrect.setHigh(1.0)
|
it.setHigh(1.0)
|
||||||
|
} // TODO REPLACE WITH ScaleOffset and play with the both values
|
||||||
|
|
||||||
val terrainTypeYScale = ModuleScaleDomain()
|
val terrainTypeYScale = ModuleScaleDomain().also {
|
||||||
terrainTypeYScale.setSource(terrainAutocorrect)
|
it.setSource(terrainAutocorrect)
|
||||||
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(3.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)
|
||||||
|
}
|
||||||
|
|
||||||
// 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(
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import kotlin.math.cos
|
|||||||
import kotlin.math.sin
|
import kotlin.math.sin
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
const val NOISEBOX_WIDTH = 768
|
const val NOISEBOX_WIDTH = 1024
|
||||||
const val NOISEBOX_HEIGHT = 512
|
const val NOISEBOX_HEIGHT = 768
|
||||||
const val TWO_PI = Math.PI * 2
|
const val TWO_PI = Math.PI * 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,6 +259,7 @@ fun main(args: Array<String>) {
|
|||||||
appConfig.setResizable(false)
|
appConfig.setResizable(false)
|
||||||
appConfig.setWindowedMode(NOISEBOX_WIDTH, NOISEBOX_HEIGHT)
|
appConfig.setWindowedMode(NOISEBOX_WIDTH, NOISEBOX_HEIGHT)
|
||||||
appConfig.setForegroundFPS(60)
|
appConfig.setForegroundFPS(60)
|
||||||
|
appConfig.setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.GL30, 3, 2)
|
||||||
|
|
||||||
Lwjgl3Application(WorldgenNoiseSandbox(), appConfig)
|
Lwjgl3Application(WorldgenNoiseSandbox(), appConfig)
|
||||||
}
|
}
|
||||||
@@ -274,7 +275,7 @@ internal object BiomeMaker : NoiseMaker {
|
|||||||
|
|
||||||
override fun draw(x: Int, y: Int, noiseValue: List<Double>, outTex: Pixmap) {
|
override fun draw(x: Int, y: Int, noiseValue: List<Double>, outTex: Pixmap) {
|
||||||
val colPal = biomeColors
|
val colPal = biomeColors
|
||||||
val control = noiseValue[0].times(colPal.size).minus(0.00001f).toInt().fmod(colPal.size)
|
val control = noiseValue[0].coerceIn(0.0, 0.99999).times(colPal.size).toInt().coerceIn(colPal.indices)
|
||||||
|
|
||||||
outTex.setColor(colPal[control])
|
outTex.setColor(colPal[control])
|
||||||
outTex.drawPixel(x, y)
|
outTex.drawPixel(x, y)
|
||||||
@@ -286,22 +287,26 @@ internal object BiomeMaker : NoiseMaker {
|
|||||||
//biome.setType(ModuleBasisFunction.BasisType.SIMPLEX)
|
//biome.setType(ModuleBasisFunction.BasisType.SIMPLEX)
|
||||||
|
|
||||||
// simplex AND fractal for more noisy edges, mmmm..!
|
// simplex AND fractal for more noisy edges, mmmm..!
|
||||||
val fractal = ModuleFractal()
|
val fractal = ModuleFractal().also {
|
||||||
fractal.setType(ModuleFractal.FractalType.MULTI)
|
it.setType(ModuleFractal.FractalType.MULTI)
|
||||||
fractal.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.SIMPLEX)
|
it.setAllSourceBasisTypes(ModuleBasisFunction.BasisType.SIMPLEX)
|
||||||
fractal.setNumOctaves(4)
|
it.setNumOctaves(4)
|
||||||
fractal.setFrequency(1.0)
|
it.setFrequency(1.0)
|
||||||
fractal.seed = seed shake 0x7E22A
|
it.seed = seed shake 0x7E22A
|
||||||
|
}
|
||||||
|
|
||||||
val autocorrect = ModuleAutoCorrect()
|
val scaleDomain = ModuleScaleDomain().also {
|
||||||
autocorrect.setSource(fractal)
|
it.setSource(fractal)
|
||||||
autocorrect.setRange(0.0, 1.0)
|
it.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
||||||
|
it.setScaleY(1.0 / params.featureSize)
|
||||||
|
it.setScaleZ(1.0 / params.featureSize)
|
||||||
|
}
|
||||||
|
|
||||||
val scale = ModuleScaleDomain()
|
val scale = ModuleScaleOffset().also {
|
||||||
scale.setSource(autocorrect)
|
it.setSource(scaleDomain)
|
||||||
scale.setScaleX(1.0 / params.featureSize) // adjust this value to change features size
|
it.setOffset(1.0)
|
||||||
scale.setScaleY(1.0 / params.featureSize)
|
it.setScale(1.0)
|
||||||
scale.setScaleZ(1.0 / params.featureSize)
|
}
|
||||||
|
|
||||||
val last = scale
|
val last = scale
|
||||||
|
|
||||||
@@ -310,12 +315,13 @@ internal object BiomeMaker : NoiseMaker {
|
|||||||
|
|
||||||
// with this method, only TWO distinct (not bland) biomes are possible. CLUT order is important here.
|
// with this method, only TWO distinct (not bland) biomes are possible. CLUT order is important here.
|
||||||
val biomeColors = intArrayOf(
|
val biomeColors = intArrayOf(
|
||||||
//0x2288ccff.toInt(), // ísland
|
//0x2288ccff.toInt(), // ísland
|
||||||
0x229944ff.toInt(), // woodlands
|
0x229944ff.toInt(), // woodlands
|
||||||
0x77bb77ff.toInt(), // shrubland
|
0x77bb77ff.toInt(), // shrubland
|
||||||
0x88bb66ff.toInt(), // plains
|
0xbbdd99ff.toInt(), // plains
|
||||||
0xeeddbbff.toInt(), // sands
|
0xbbdd99ff.toInt(), // plains
|
||||||
0x888888ff.toInt() // rockyland
|
// 0xeeddbbff.toInt(), // sands
|
||||||
|
0x888888ff.toInt() // rockyland
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user