From 90495b613794852b8c149e50fb1a6f87e1d22385 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 10 Dec 2019 18:04:37 +0900 Subject: [PATCH] wip2 --- .../terrarum/modulebasegame/weather/WeatherMixer.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/net/torvald/terrarum/modulebasegame/weather/WeatherMixer.kt b/src/net/torvald/terrarum/modulebasegame/weather/WeatherMixer.kt index b9659c02e..04c6613ed 100644 --- a/src/net/torvald/terrarum/modulebasegame/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/modulebasegame/weather/WeatherMixer.kt @@ -140,14 +140,14 @@ internal object WeatherMixer : RNGConsumer { UV mapping coord.y -+ <- 1.0 = - D| = // parallax of +1 + D| = // parallax of -1 i| = = s| = // parallax of 0 p| = = - .| = // parallax of -1 + .| = // parallax of +1 -+ <- 0.0 = */ - val parallax = ((parallaxZeroPos - WorldCamera.gdxCamY.div(CreateTileAtlas.TILE_SIZE.toFloat())) / parallaxDomainSize).coerceIn(-1f, 1f) + val parallax = -((parallaxZeroPos - WorldCamera.gdxCamY.div(CreateTileAtlas.TILE_SIZE.toFloat())) / parallaxDomainSize).coerceIn(-1f, 1f) val parallaxSize = 1f / 3f // draw skybox to provided graphics instance @@ -155,6 +155,8 @@ internal object WeatherMixer : RNGConsumer { val colBottommost = getGradientColour(world, skyboxColourMap, 1, timeNow).toGdxColor() val colMid = colorMix(colTopmost, colBottommost, 0.5f) + //println(parallax) // parallax value works as intended. + val colTop = colorMix(colTopmost, colBottommost, (parallax + parallaxSize / 2f) * 2f - 1f) val colBottom = colorMix(colTopmost, colBottommost, (parallax - parallaxSize / 2f) * 2f - 1f) @@ -169,11 +171,11 @@ internal object WeatherMixer : RNGConsumer { skyboxPixmap.setColor(colBottom) skyboxPixmap.drawPixel(0, 1); skyboxPixmap.drawPixel(1, 1) skyboxTexture.dispose() - skyboxTexture = Texture(skyboxPixmap) + skyboxTexture = Texture(skyboxPixmap); skyboxTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear) batch.shader = IngameRenderer.shaderBayer batch.inUse { - it.draw(skyboxTexture, 0f, 0f, AppLoader.screenWf, AppLoader.screenHf) + it.draw(skyboxTexture, 0f, -AppLoader.halfScreenHf, AppLoader.screenWf, AppLoader.screenHf * 2f) // because of how the linear filter works, we extend the image by two } // don't use shader to just fill the whole screen... frag shader will be called a million times and it's best to not burden it