From d9151377f6de701e3c764e8c80476592fa70e8ea Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 26 Sep 2023 00:37:35 +0900 Subject: [PATCH] longer sunsets to the skybox model --- assets/clut/skybox.png | 4 ++-- assets/clut/skyboxavr.png | 4 ++-- .../mods/basegame/weathers/clut_daylight.kra | 4 ++-- .../mods/basegame/weathers/clut_daylight.tga | 2 +- src/net/torvald/parametricsky/Application.kt | 18 +++++++++++++++--- .../clut/GenerateSkyboxTextureAtlas.kt | 6 +++--- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/assets/clut/skybox.png b/assets/clut/skybox.png index fc5c91d13..970f86427 100644 --- a/assets/clut/skybox.png +++ b/assets/clut/skybox.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:935e08e8ba6eae2f793d151608b58de855e740ca3756c6d72fad96e819241da0 -size 1407682 +oid sha256:ee43f7e28b10207a124c6409d833d05a8bf8fc755841d8652f81f47f07f0628d +size 1785978 diff --git a/assets/clut/skyboxavr.png b/assets/clut/skyboxavr.png index 4c236e231..1ecb6f785 100644 --- a/assets/clut/skyboxavr.png +++ b/assets/clut/skyboxavr.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d2f0af8d985231ecc60056922352bfd83475746f7e7c8ce34c1707c62ea0acc9 -size 49211 +oid sha256:4201e1a48b9d4435adbcc5d9ae8e77e7c4c0ed19c182e754bd5a29a1da53581a +size 50461 diff --git a/assets/mods/basegame/weathers/clut_daylight.kra b/assets/mods/basegame/weathers/clut_daylight.kra index 12ebd1851..5df16adcd 100644 --- a/assets/mods/basegame/weathers/clut_daylight.kra +++ b/assets/mods/basegame/weathers/clut_daylight.kra @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06703574c58523bea910f3c1d98a77940997666670ff8e017641538e26f9959a -size 97812 +oid sha256:b4fabcd25cbdf5d34afa13170f8d70bf8e430a9fc4a2a7ec217b248cee0f4fcb +size 107669 diff --git a/assets/mods/basegame/weathers/clut_daylight.tga b/assets/mods/basegame/weathers/clut_daylight.tga index 3eb520fcf..f86f3f901 100644 --- a/assets/mods/basegame/weathers/clut_daylight.tga +++ b/assets/mods/basegame/weathers/clut_daylight.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16323d626a2fb566817e0dfab989c3772c31677af959d8fdcba821a1bc6f3577 +oid sha256:9802568673b66298416101889f75f830abfbe8bb1e6f5c7d4f484978c337fa7a size 3618 diff --git a/src/net/torvald/parametricsky/Application.kt b/src/net/torvald/parametricsky/Application.kt index b98f2f3f6..ee02beec5 100644 --- a/src/net/torvald/parametricsky/Application.kt +++ b/src/net/torvald/parametricsky/Application.kt @@ -188,8 +188,12 @@ class Application(val WIDTH: Int, val HEIGHT: Int) : Game() { val ys2 = ArrayList() val halfHeight = oneScreen.height * 0.5 + + val elevation = if (elevation.abs() < 0.0001) Math.toRadians(0.5) else elevation // dealing with the edge case val elevationDeg = Math.toDegrees(elevation) + + for (x in 0 until oneScreen.width) { for (y in 0 until oneScreen.height) { @@ -204,9 +208,10 @@ class Application(val WIDTH: Int, val HEIGHT: Int) : Game() { val yi = yp - 3 val xf = -elevationDeg / 90.0 var yf = (yi / 58.0).coerceIn(0.0, 1.0).mapCircle().coerceInSmoothly(0.0, 0.95) - if (elevationDeg < 0) yf *= Skybox.superellipsoidDecay(1.0 / 3.0, xf) +// if (elevationDeg < 0) yf *= Skybox.superellipsoidDecay(1.0 / 3.0, xf) val theta = yf * HALF_PI - val gamma = if (y < halfHeight) Math.toRadians(cameraHeading) else Math.toRadians(cameraHeading + 180) + val gammaPair = if (y < halfHeight) 0 else 1 + val gamma = Math.toRadians(115 + 25 * cos(PI * elevationDeg / 40)) + (gammaPair * PI) val xyz = CIEXYZ( @@ -217,7 +222,7 @@ class Application(val WIDTH: Int, val HEIGHT: Int) : Game() { val xyz2 = xyz.scaleToFit(elevation) ys.add(xyz.Y) ys2.add(xyz2.Y) - val rgb = xyz2.toRGB().toColor() + val rgb = xyz2.toRGB().toColor().gamma(1.2f) rgb.a = 1f /*val rgb2 = Color( @@ -241,6 +246,13 @@ class Application(val WIDTH: Int, val HEIGHT: Int) : Game() { //System.exit(0) } + private fun Color.gamma(gam: Float): Color { + this.r = this.r.pow(gam) + this.g = this.g.pow(gam) + this.b = this.b.pow(gam) + return this + } + override fun create() { batch = SpriteBatch() diff --git a/src/net/torvald/terrarum/clut/GenerateSkyboxTextureAtlas.kt b/src/net/torvald/terrarum/clut/GenerateSkyboxTextureAtlas.kt index 8844c6d65..5a33725d5 100644 --- a/src/net/torvald/terrarum/clut/GenerateSkyboxTextureAtlas.kt +++ b/src/net/torvald/terrarum/clut/GenerateSkyboxTextureAtlas.kt @@ -48,9 +48,9 @@ class GenerateSkyboxTextureAtlas { var yf = (yi / 58.0).coerceIn(0.0, 1.0).mapCircle().coerceInSmoothly(0.0, 0.95) // experiments visualisation: https://www.desmos.com/calculator/5crifaekwa -// if (elevationDeg < 0) yf *= 1.0 - pow(xf, 0.333) -// if (elevationDeg < 0) yf *= -2.0 * asin(xf - 1.0) / PI - if (elevationDeg < 0) yf *= Skybox.superellipsoidDecay(1.0 / 3.0, xf) +// if (elevationDeg < 0) yf *= 1.0 - pow(xf, 0.333) +// if (elevationDeg < 0) yf *= -2.0 * asin(xf - 1.0) / PI +// if (elevationDeg < 0) yf *= Skybox.superellipsoidDecay(1.0 / 3.0, xf) val theta = yf * HALF_PI // vertical angle, where 0 is zenith, ±90 is ground (which is odd)