mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
scrolling weatherbox; new skybox clut
This commit is contained in:
@@ -133,17 +133,21 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
weatherbox = Weatherbox()
|
||||
// TEST FILL WITH RANDOM VALUES
|
||||
(0..3).map { takeUniformRand(0f..1f) }.let {
|
||||
weatherbox.windDir.p0 = it[0]
|
||||
weatherbox.windDir.p1 = it[1]
|
||||
weatherbox.windDir.p2 = it[2]
|
||||
weatherbox.windDir.p3 = it[3]
|
||||
(0..5).map { takeUniformRand(0f..1f) }.let {
|
||||
weatherbox.windDir.pM1 = it[0]
|
||||
weatherbox.windDir.p0 = it[1]
|
||||
weatherbox.windDir.p1 = it[2]
|
||||
weatherbox.windDir.p2 = it[3]
|
||||
weatherbox.windDir.p3 = it[4]
|
||||
weatherbox.windDir.p4 = it[5]
|
||||
}
|
||||
(0..3).map { takeUniformRand(-1f..1f) }.let {
|
||||
weatherbox.windSpeed.p0 = currentWeather.getRandomWindSpeed(it[0])
|
||||
weatherbox.windSpeed.p1 = currentWeather.getRandomWindSpeed(it[1])
|
||||
weatherbox.windSpeed.p2 = currentWeather.getRandomWindSpeed(it[2])
|
||||
weatherbox.windSpeed.p3 = currentWeather.getRandomWindSpeed(it[3])
|
||||
(0..5).map { takeUniformRand(-1f..1f) }.let {
|
||||
weatherbox.windSpeed.pM1 = currentWeather.getRandomWindSpeed(it[0])
|
||||
weatherbox.windSpeed.p0 = currentWeather.getRandomWindSpeed(it[1])
|
||||
weatherbox.windSpeed.p1 = currentWeather.getRandomWindSpeed(it[2])
|
||||
weatherbox.windSpeed.p2 = currentWeather.getRandomWindSpeed(it[3])
|
||||
weatherbox.windSpeed.p3 = currentWeather.getRandomWindSpeed(it[4])
|
||||
weatherbox.windSpeed.p4 = currentWeather.getRandomWindSpeed(it[5])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +583,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
gdxBlendNormalStraightAlpha()
|
||||
|
||||
turbidity = (3.5 + turbidityCoeff * 2.5).coerceIn(1.0, 6.0)
|
||||
turbidity = (currentWeather.json.getDouble("atmoTurbidity") + turbidityCoeff * 2.5).coerceIn(1.0, 10.0)
|
||||
val thisTurbidity = forceTurbidity ?: turbidity
|
||||
|
||||
val gradY = -(gH - App.scr.height) * ((parallax + 1f) / 2f)
|
||||
|
||||
@@ -9,9 +9,20 @@ class Weatherbox {
|
||||
}
|
||||
|
||||
|
||||
data class WeatherStateBox(var x: Float = 0f, var p0: Float = 0f, var p1: Float = 0f, var p2: Float = 0f, var p3: Float = 0f) {
|
||||
data class WeatherStateBox(
|
||||
var x: Float = 0f,
|
||||
var pM2: Float = 0f,
|
||||
var pM1: Float = 0f,
|
||||
var p0: Float = 0f,
|
||||
var p1: Float = 0f,
|
||||
var p2: Float = 0f,
|
||||
var p3: Float = 0f,
|
||||
var p4: Float = 0f,
|
||||
var p5: Float = 0f,
|
||||
// pM1 and p4 only exists for the sake of better weather forecasting
|
||||
) {
|
||||
|
||||
fun get() = interpolateCatmullRom(x, p0, p1, p2, p3)
|
||||
fun get() = interpolate(x, p0, p1, p2, p3)
|
||||
|
||||
fun getAndUpdate(xdelta: Float, next: () -> Float): Float {
|
||||
synchronized(WeatherMixer.RNG) {
|
||||
@@ -19,10 +30,14 @@ data class WeatherStateBox(var x: Float = 0f, var p0: Float = 0f, var p1: Float
|
||||
x += xdelta
|
||||
while (x >= 1.0) {
|
||||
x -= 1.0f
|
||||
pM2 = pM1
|
||||
pM1 = p0
|
||||
p0 = p1
|
||||
p1 = p2
|
||||
p2 = p3
|
||||
p3 = next()
|
||||
p3 = p4
|
||||
p4 = p5
|
||||
p5 = next()
|
||||
}
|
||||
return y
|
||||
}
|
||||
@@ -30,7 +45,7 @@ data class WeatherStateBox(var x: Float = 0f, var p0: Float = 0f, var p1: Float
|
||||
|
||||
companion object {
|
||||
// fixed with T=0.5
|
||||
fun interpolateCatmullRom(u: Float, p0: Float, p1: Float, p2: Float, p3: Float): Float {
|
||||
fun interpolate(u: Float, p0: Float, p1: Float, p2: Float, p3: Float): Float {
|
||||
val c1: Float = p1
|
||||
val c2: Float = -0.5f * p0 + 0.5f * p2
|
||||
val c3: Float = p0 - 2.5f * p1 + 2.0f * p2 - 0.5f * p3
|
||||
|
||||
Reference in New Issue
Block a user