From 2a62435712304d7b18707cd24b9168a5a11e3b31 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 26 Jul 2023 00:58:17 +0900 Subject: [PATCH] wtf was that --- src/net/torvald/parametricsky/Application.kt | 3 ++- src/net/torvald/terrarum/modulebasegame/clut/Skybox.kt | 7 ++++--- src/net/torvald/terrarum/weather/WeatherMixer.kt | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/net/torvald/parametricsky/Application.kt b/src/net/torvald/parametricsky/Application.kt index 77a72359b..a1c5d32c0 100644 --- a/src/net/torvald/parametricsky/Application.kt +++ b/src/net/torvald/parametricsky/Application.kt @@ -22,6 +22,7 @@ import java.awt.BorderLayout import java.awt.Dimension import java.awt.FlowLayout import java.awt.GridLayout +import java.lang.Math.pow import javax.swing.* import kotlin.math.* @@ -186,7 +187,7 @@ class Application(val WIDTH: Int, val HEIGHT: Int) : Game() { // AM-PM mapping (use with WIDTH=1) var yf = (y * 2.0 / oneScreen.height) % 1.0 - if (elevation < 0) yf -= (elevation / HALF_PI) + if (elevation < 0) yf *= 1.0 - pow(-elevation / HALF_PI, 0.333) val gamma = if (y < halfHeight) HALF_PI else 3 * HALF_PI val theta = yf.mapCircle() * HALF_PI diff --git a/src/net/torvald/terrarum/modulebasegame/clut/Skybox.kt b/src/net/torvald/terrarum/modulebasegame/clut/Skybox.kt index 03422a468..74fc30f10 100644 --- a/src/net/torvald/terrarum/modulebasegame/clut/Skybox.kt +++ b/src/net/torvald/terrarum/modulebasegame/clut/Skybox.kt @@ -11,6 +11,7 @@ import net.torvald.terrarum.App import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.abs import net.torvald.terrarum.modulebasegame.worldgenerator.HALF_PI +import java.lang.Math.pow import kotlin.math.* /** @@ -103,8 +104,8 @@ object Skybox : Disposable { // printdbg(this, "elev $elevationDeg turb $turbidity") for (y in 0 until gradSize) { - var yf = (y.toDouble() / gradSize * 1.0).coerceIn(0.0, 1.0) - if (elevationDeg < 0) yf += (elevationDeg / 90.0) + var yf = (y + 0.5) / gradSize.toDouble() + if (elevationDeg < 0) yf *= 1.0 - pow(-elevationDeg / 90.0, 0.333) val theta = yf.mapCircle() * HALF_PI // vertical angle, where 0 is zenith, ±90 is ground (which is odd) @@ -117,7 +118,7 @@ object Skybox : Disposable { val rgb = xyz2.toRGB().toColor() pixmap.setColor(rgb) - pixmap.drawPixel(0, gradSize - 1 - y) + pixmap.drawPixel(0, y) } val texture = Texture(pixmap).also { diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 28e04b46a..a486b2d85 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -152,7 +152,7 @@ internal object WeatherMixer : RNGConsumer { } var turbidity = 4.0; private set - private var gH = 2f * App.scr.height + private var gH = 1.5f * App.scr.height private val HALF_DAY = DAY_LENGTH / 2 /** @@ -160,7 +160,7 @@ internal object WeatherMixer : RNGConsumer { */ internal fun render(camera: Camera, batch: FlippingSpriteBatch, world: GameWorld) { val parallaxZeroPos = (world.height / 3f) - val parallaxDomainSize = world.height / 6f + val parallaxDomainSize = 300f // we will not care for nextSkybox for now val timeNow = (forceTimeAt ?: world.worldTime.TIME_T.toInt()) % WorldTime.DAY_LENGTH @@ -206,10 +206,10 @@ internal object WeatherMixer : RNGConsumer { batch.inUse { batch.shader = null batch.color = Color.WHITE - batch.drawFlipped(texture1, 0f, gradY, App.scr.wf, gH) + batch.draw(texture1, 0f, gradY, App.scr.wf, gH) batch.color = Color(1f, 1f, 1f, lerpScale) - batch.drawFlipped(texture2, 0f, gradY, App.scr.wf, gH) + batch.draw(texture2, 0f, gradY, App.scr.wf, gH) batch.color = Color.WHITE }