From 5069e90aa1beadf3aea148102726c26496719063 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 19 Sep 2023 01:45:59 +0900 Subject: [PATCH] fix: clouds not using their alpha value to draw --- src/net/torvald/terrarum/weather/WeatherObjectCloud.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt b/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt index 3284f7435..72a777da0 100644 --- a/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt +++ b/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt @@ -47,7 +47,7 @@ class WeatherObjectCloud( scl(world.worldTime.timeDelta.toFloat()) ) - eigenAlpha = if (posZ < 1f) posZ.pow(0.5f) else cosh((posZ - CLOUD_STAGE_DEPTH) / (0.75636f * CLOUD_STAGE_DEPTH)) - 1f //-((posZ - 1f) / CLOUD_STAGE_DEPTH) + 1f + eigenAlpha = if (posZ >= CLOUD_STAGE_DEPTH) 0f else if (posZ < 1f) posZ.pow(0.5f) else cosh((posZ - CLOUD_STAGE_DEPTH) / (0.75636f * CLOUD_STAGE_DEPTH)) - 1f //-((posZ - 1f) / CLOUD_STAGE_DEPTH) + 1f val alphaMult = if (life < NEWBORN_GROWTH_TIME) life / NEWBORN_GROWTH_TIME @@ -78,12 +78,15 @@ class WeatherObjectCloud( private val vecMult = Vector3(1f, 1f, 1f / (4f * H)) - fun render(batch: UnpackedColourSpriteBatch, cloudDrawColour: Color) { + fun render(batch: UnpackedColourSpriteBatch, cloudDrawColour0: Color) { val sc = screenCoord // printdbg(this, "gamma: (${rgbGamma}, ${aGamma}) index: ($rgbGammaIndex, $aGammaIndex)") - batch.color = cloudDrawColour + val cloudCol = cloudDrawColour0.cpy().also { + it.a = alpha + } + batch.color = cloudCol batch.generic.set(rgbGamma, aGamma, 0f, 0f) if (flipW)