mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
no day-night cycle on titlescreen demo
This commit is contained in:
@@ -108,7 +108,7 @@ object BlockPropUtil {
|
|||||||
return when (prop.dynamicLuminosityFunction) {
|
return when (prop.dynamicLuminosityFunction) {
|
||||||
1 -> getTorchFlicker(prop)
|
1 -> getTorchFlicker(prop)
|
||||||
2 -> (INGAME.world).globalLight.cpy() // current global light
|
2 -> (INGAME.world).globalLight.cpy() // current global light
|
||||||
3 -> WeatherMixer.getGlobalLightOfTime(INGAME.world, WorldTime.DAY_LENGTH / 2).cpy() // daylight at noon
|
3 -> WeatherMixer.getGlobalLightOfTimeOfNoon().cpy() // daylight at noon
|
||||||
4 -> getSlowBreath(prop)
|
4 -> getSlowBreath(prop)
|
||||||
5 -> getPulsate(prop)
|
5 -> getPulsate(prop)
|
||||||
else -> prop.baseLumCol
|
else -> prop.baseLumCol
|
||||||
|
|||||||
@@ -121,6 +121,17 @@ class WorldTime(initTime: Long = 0L) {
|
|||||||
inline val moonPhase: Double
|
inline val moonPhase: Double
|
||||||
get() = (TIME_T.plus(1700000L) % LUNAR_CYCLE).toDouble() / LUNAR_CYCLE
|
get() = (TIME_T.plus(1700000L) % LUNAR_CYCLE).toDouble() / LUNAR_CYCLE
|
||||||
|
|
||||||
|
fun getSolarElevationAt(ordinalDay: Int, second: Int): Double {
|
||||||
|
val TIME_T = DAY_LENGTH * ordinalDay + second
|
||||||
|
|
||||||
|
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0
|
||||||
|
val d = -23.44 * cos(TWO_PI * x / YEAR_DAYS)
|
||||||
|
|
||||||
|
// 51.56 and 23.44 will make yearly min/max elevation to be 75deg
|
||||||
|
// -0.2504264: a number that makes y=min when x=0 (x=0 is midnight)
|
||||||
|
return 51.56 * sin(TWO_PI * (x - 0.2504264)) + d
|
||||||
|
}
|
||||||
|
|
||||||
val solarElevationDeg: Double
|
val solarElevationDeg: Double
|
||||||
get() {
|
get() {
|
||||||
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0
|
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
|
|
||||||
val forcedTime = 39693
|
val forcedTime = 39693
|
||||||
// demoWorld.globalLight = WeatherMixer.globalLightNow
|
// demoWorld.globalLight = WeatherMixer.globalLightNow
|
||||||
demoWorld.globalLight = WeatherMixer.getGlobalLightOfTime(demoWorld, forcedTime)
|
demoWorld.globalLight = WeatherMixer.getGlobalLightOfTimeOfNoon()
|
||||||
demoWorld.updateWorldTime(delta)
|
demoWorld.updateWorldTime(delta)
|
||||||
// WeatherMixer.update(delta, cameraPlayer, demoWorld)
|
// WeatherMixer.update(delta, cameraPlayer, demoWorld)
|
||||||
WeatherMixer.forceTimeAt = forcedTime
|
WeatherMixer.forceTimeAt = forcedTime
|
||||||
|
|||||||
@@ -161,9 +161,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
// we will not care for nextSkybox for now
|
// we will not care for nextSkybox for now
|
||||||
val timeNow = (forceTimeAt ?: world.worldTime.TIME_T.toInt()) % WorldTime.DAY_LENGTH
|
val timeNow = (forceTimeAt ?: world.worldTime.TIME_T.toInt()) % WorldTime.DAY_LENGTH
|
||||||
val skyboxColourMap = currentWeather.skyboxGradColourMap
|
|
||||||
val daylightClut = currentWeather.daylightClut
|
val daylightClut = currentWeather.daylightClut
|
||||||
|
|
||||||
// calculate global light
|
// calculate global light
|
||||||
val globalLight = getGradientColour2(daylightClut, world.worldTime.solarElevationDeg, timeNow)
|
val globalLight = getGradientColour2(daylightClut, world.worldTime.solarElevationDeg, timeNow)
|
||||||
globalLightNow.set(globalLight)
|
globalLightNow.set(globalLight)
|
||||||
@@ -185,7 +183,10 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
gdxBlendNormalStraightAlpha()
|
gdxBlendNormalStraightAlpha()
|
||||||
|
|
||||||
val deg =world.worldTime.solarElevationDeg
|
val deg = if (forceTimeAt != null)
|
||||||
|
world.worldTime.getSolarElevationAt(world.worldTime.ordinalDay, forceTimeAt!!)
|
||||||
|
else
|
||||||
|
world.worldTime.solarElevationDeg
|
||||||
val degThis = deg.floor()
|
val degThis = deg.floor()
|
||||||
val degNext = degThis + if (timeNow < HALF_DAY) 1 else -1 // Skybox.get has internal coerceIn
|
val degNext = degThis + if (timeNow < HALF_DAY) 1 else -1 // Skybox.get has internal coerceIn
|
||||||
|
|
||||||
@@ -224,8 +225,11 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
/**
|
/**
|
||||||
* Get a GL of specific time
|
* Get a GL of specific time
|
||||||
*/
|
*/
|
||||||
fun getGlobalLightOfTime(world: GameWorld, timeInSec: Int): Cvec =
|
fun getGlobalLightOfTimeOfNoon(): Cvec {
|
||||||
getGradientColour(world, currentWeather.skyboxGradColourMap, 2, timeInSec)
|
currentWeather.daylightClut.let { it.get(it.width - 1, 0) }.let {
|
||||||
|
return Cvec(it.r, it.g, it.b, it.a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getGradientColour(world: GameWorld, colorMap: GdxColorMap, row: Int, timeInSec: Int): Cvec {
|
fun getGradientColour(world: GameWorld, colorMap: GdxColorMap, row: Int, timeInSec: Int): Cvec {
|
||||||
val dataPointDistance = WorldTime.DAY_LENGTH / colorMap.width
|
val dataPointDistance = WorldTime.DAY_LENGTH / colorMap.width
|
||||||
|
|||||||
Reference in New Issue
Block a user