From 6f2c1e578ef0ffadc6b49edd501c0b827f7fc2fe Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 20 Jul 2017 18:39:05 +0900 Subject: [PATCH] parallax (sky looks bluer when you go up) --- .gitignore | 2 ++ assets/4096_bayer_skyboxfill.frag | 20 +++++++++++++-- assets/locales/bgBG/terrarum.json | 3 +++ assets/locales/csCZ/terrarum.json | 3 +++ assets/locales/daDK/terrarum.json | 3 +++ assets/locales/de/terrarum.json | 3 +++ assets/locales/elGR/terrarum.json | 3 +++ assets/locales/en/terrarum.json | 3 +++ assets/locales/es/terrarum.json | 3 +++ assets/locales/fiFI/terrarum.json | 3 +++ assets/locales/frFR/terrarum.json | 3 +++ assets/locales/huHU/terrarum.json | 3 +++ assets/locales/isIC/terrarum.json | 3 +++ assets/locales/it/terrarum.json | 3 +++ assets/locales/jaJP/terrarum.json | 3 +++ assets/locales/jakanaJP/terrarum.json | 3 +++ assets/locales/koKR/terrarum.json | 3 +++ assets/locales/nlNL/terrarum.json | 3 +++ assets/locales/noNB/terrarum.json | 3 +++ assets/locales/plPL/terrarum.json | 3 +++ assets/locales/ptBR/terrarum.json | 3 +++ assets/locales/ptPT/terrarum.json | 3 +++ assets/locales/roRO/terrarum.json | 3 +++ assets/locales/ruRU/terrarum.json | 3 +++ assets/locales/svSE/terrarum.json | 3 +++ assets/locales/thTH/terrarum.json | 3 +++ assets/locales/trTR/terrarum.json | 3 +++ assets/locales/zhCN/terrarum.json | 3 +++ assets/locales/zhTW/terrarum.json | 3 +++ .../basegame/weathers/generic_skybox.tga | 2 +- src/net/torvald/terrarum/Terrarum.kt | 12 ++++----- src/net/torvald/terrarum/TitleScreen.kt | 2 +- src/net/torvald/terrarum/ui/UIStartMenu.kt | 3 +++ .../torvald/terrarum/weather/WeatherMixer.kt | 25 +++++++++++++++++++ .../terrarum/worldgenerator/WorldGenerator.kt | 14 +++++------ 35 files changed, 144 insertions(+), 17 deletions(-) create mode 100644 assets/locales/bgBG/terrarum.json create mode 100644 assets/locales/csCZ/terrarum.json create mode 100644 assets/locales/daDK/terrarum.json create mode 100644 assets/locales/de/terrarum.json create mode 100644 assets/locales/elGR/terrarum.json create mode 100644 assets/locales/en/terrarum.json create mode 100644 assets/locales/es/terrarum.json create mode 100644 assets/locales/fiFI/terrarum.json create mode 100644 assets/locales/frFR/terrarum.json create mode 100644 assets/locales/huHU/terrarum.json create mode 100644 assets/locales/isIC/terrarum.json create mode 100644 assets/locales/it/terrarum.json create mode 100644 assets/locales/jaJP/terrarum.json create mode 100644 assets/locales/jakanaJP/terrarum.json create mode 100644 assets/locales/koKR/terrarum.json create mode 100644 assets/locales/nlNL/terrarum.json create mode 100644 assets/locales/noNB/terrarum.json create mode 100644 assets/locales/plPL/terrarum.json create mode 100644 assets/locales/ptBR/terrarum.json create mode 100644 assets/locales/ptPT/terrarum.json create mode 100644 assets/locales/roRO/terrarum.json create mode 100644 assets/locales/ruRU/terrarum.json create mode 100644 assets/locales/svSE/terrarum.json create mode 100644 assets/locales/thTH/terrarum.json create mode 100644 assets/locales/trTR/terrarum.json create mode 100644 assets/locales/zhCN/terrarum.json create mode 100644 assets/locales/zhTW/terrarum.json diff --git a/.gitignore b/.gitignore index 03a63cb97..580e3b816 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ Thumbs.db *.jar .DS_Store ~$* +assets/modules/basegame/demoworld +assets/modules/basegame/demoworld.gz diff --git a/assets/4096_bayer_skyboxfill.frag b/assets/4096_bayer_skyboxfill.frag index 4ff0f119f..c3dbcdae1 100644 --- a/assets/4096_bayer_skyboxfill.frag +++ b/assets/4096_bayer_skyboxfill.frag @@ -5,6 +5,8 @@ uniform sampler2D u_texture; uniform vec3 topColor; uniform vec3 bottomColor; +uniform float parallax = 0.0; // +1.0: all top col, -1.0: all bototm col, 0.0: normal grad +uniform float parallax_size = 1.0/3.0; // 0: no parallax // "steps" of R, G and B. Must be integer && equal or greater than 2 @@ -48,7 +50,9 @@ vec4 nearestColour(vec4 incolor) { void main(void) { float spread = 1.0 / (0.299 * (rcount - 1.0) + 0.587 * (gcount - 1.0) + 0.114 * (bcount - 1.0)); // this spread value is optimised one -- try your own values for various effects! - float scale = v_texCoords.y; + float scale = v_texCoords.y * (1.0 - parallax_size) + (parallax_size / 2.0) + (parallax * parallax_size / 2.0); + + float inR = mix(bottomColor.r, topColor.r, scale); float inG = mix(bottomColor.g, topColor.g, scale); float inB = mix(bottomColor.b, topColor.b, scale); @@ -58,4 +62,16 @@ void main(void) { vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize)); gl_FragColor = nearestColour(inColor + spread * (bayer[int(entry.y)][int(entry.x)] / bayerDivider - 0.5)); -} \ No newline at end of file +} + +/* +UV mapping coord.y + +-+ <- 1.0 = +D| = // parallax of +1 +i| = = +s| = // parallax of 0 +p| = = +.| = // parallax of -1 +-+ <- 0.0 = +*/ \ No newline at end of file diff --git a/assets/locales/bgBG/terrarum.json b/assets/locales/bgBG/terrarum.json new file mode 100644 index 000000000..8cf679699 --- /dev/null +++ b/assets/locales/bgBG/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Модули" +} \ No newline at end of file diff --git a/assets/locales/csCZ/terrarum.json b/assets/locales/csCZ/terrarum.json new file mode 100644 index 000000000..9e2264387 --- /dev/null +++ b/assets/locales/csCZ/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduly" +} \ No newline at end of file diff --git a/assets/locales/daDK/terrarum.json b/assets/locales/daDK/terrarum.json new file mode 100644 index 000000000..9a7f47b2e --- /dev/null +++ b/assets/locales/daDK/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduler" +} \ No newline at end of file diff --git a/assets/locales/de/terrarum.json b/assets/locales/de/terrarum.json new file mode 100644 index 000000000..9a9cdb47e --- /dev/null +++ b/assets/locales/de/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Modulen" +} \ No newline at end of file diff --git a/assets/locales/elGR/terrarum.json b/assets/locales/elGR/terrarum.json new file mode 100644 index 000000000..4b4428008 --- /dev/null +++ b/assets/locales/elGR/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Ενότητες" +} \ No newline at end of file diff --git a/assets/locales/en/terrarum.json b/assets/locales/en/terrarum.json new file mode 100644 index 000000000..2901ccd29 --- /dev/null +++ b/assets/locales/en/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Modules" +} \ No newline at end of file diff --git a/assets/locales/es/terrarum.json b/assets/locales/es/terrarum.json new file mode 100644 index 000000000..eae772fd3 --- /dev/null +++ b/assets/locales/es/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Módulos" +} \ No newline at end of file diff --git a/assets/locales/fiFI/terrarum.json b/assets/locales/fiFI/terrarum.json new file mode 100644 index 000000000..4cc125743 --- /dev/null +++ b/assets/locales/fiFI/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduulit" +} \ No newline at end of file diff --git a/assets/locales/frFR/terrarum.json b/assets/locales/frFR/terrarum.json new file mode 100644 index 000000000..2901ccd29 --- /dev/null +++ b/assets/locales/frFR/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Modules" +} \ No newline at end of file diff --git a/assets/locales/huHU/terrarum.json b/assets/locales/huHU/terrarum.json new file mode 100644 index 000000000..a94941ffb --- /dev/null +++ b/assets/locales/huHU/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Modulok" +} \ No newline at end of file diff --git a/assets/locales/isIC/terrarum.json b/assets/locales/isIC/terrarum.json new file mode 100644 index 000000000..07288b0e6 --- /dev/null +++ b/assets/locales/isIC/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Einingar" +} \ No newline at end of file diff --git a/assets/locales/it/terrarum.json b/assets/locales/it/terrarum.json new file mode 100644 index 000000000..f84ba84f7 --- /dev/null +++ b/assets/locales/it/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduli" +} \ No newline at end of file diff --git a/assets/locales/jaJP/terrarum.json b/assets/locales/jaJP/terrarum.json new file mode 100644 index 000000000..a63e9ce55 --- /dev/null +++ b/assets/locales/jaJP/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "モジュール" +} \ No newline at end of file diff --git a/assets/locales/jakanaJP/terrarum.json b/assets/locales/jakanaJP/terrarum.json new file mode 100644 index 000000000..a63e9ce55 --- /dev/null +++ b/assets/locales/jakanaJP/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "モジュール" +} \ No newline at end of file diff --git a/assets/locales/koKR/terrarum.json b/assets/locales/koKR/terrarum.json new file mode 100644 index 000000000..3a50162a7 --- /dev/null +++ b/assets/locales/koKR/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "모듈" +} \ No newline at end of file diff --git a/assets/locales/nlNL/terrarum.json b/assets/locales/nlNL/terrarum.json new file mode 100644 index 000000000..2901ccd29 --- /dev/null +++ b/assets/locales/nlNL/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Modules" +} \ No newline at end of file diff --git a/assets/locales/noNB/terrarum.json b/assets/locales/noNB/terrarum.json new file mode 100644 index 000000000..9a7f47b2e --- /dev/null +++ b/assets/locales/noNB/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduler" +} \ No newline at end of file diff --git a/assets/locales/plPL/terrarum.json b/assets/locales/plPL/terrarum.json new file mode 100644 index 000000000..eefdf0345 --- /dev/null +++ b/assets/locales/plPL/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduły" +} \ No newline at end of file diff --git a/assets/locales/ptBR/terrarum.json b/assets/locales/ptBR/terrarum.json new file mode 100644 index 000000000..eae772fd3 --- /dev/null +++ b/assets/locales/ptBR/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Módulos" +} \ No newline at end of file diff --git a/assets/locales/ptPT/terrarum.json b/assets/locales/ptPT/terrarum.json new file mode 100644 index 000000000..eae772fd3 --- /dev/null +++ b/assets/locales/ptPT/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Módulos" +} \ No newline at end of file diff --git a/assets/locales/roRO/terrarum.json b/assets/locales/roRO/terrarum.json new file mode 100644 index 000000000..3312c16d4 --- /dev/null +++ b/assets/locales/roRO/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Module" +} \ No newline at end of file diff --git a/assets/locales/ruRU/terrarum.json b/assets/locales/ruRU/terrarum.json new file mode 100644 index 000000000..8cf679699 --- /dev/null +++ b/assets/locales/ruRU/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Модули" +} \ No newline at end of file diff --git a/assets/locales/svSE/terrarum.json b/assets/locales/svSE/terrarum.json new file mode 100644 index 000000000..9a7f47b2e --- /dev/null +++ b/assets/locales/svSE/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Moduler" +} \ No newline at end of file diff --git a/assets/locales/thTH/terrarum.json b/assets/locales/thTH/terrarum.json new file mode 100644 index 000000000..4f6e94eaf --- /dev/null +++ b/assets/locales/thTH/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "โมดูล" +} \ No newline at end of file diff --git a/assets/locales/trTR/terrarum.json b/assets/locales/trTR/terrarum.json new file mode 100644 index 000000000..3be2773ba --- /dev/null +++ b/assets/locales/trTR/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "Modüller" +} \ No newline at end of file diff --git a/assets/locales/zhCN/terrarum.json b/assets/locales/zhCN/terrarum.json new file mode 100644 index 000000000..cfc34265b --- /dev/null +++ b/assets/locales/zhCN/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "模块" +} \ No newline at end of file diff --git a/assets/locales/zhTW/terrarum.json b/assets/locales/zhTW/terrarum.json new file mode 100644 index 000000000..d31c85807 --- /dev/null +++ b/assets/locales/zhTW/terrarum.json @@ -0,0 +1,3 @@ +{ + "MENU_MODULES" : "模塊" +} \ No newline at end of file diff --git a/assets/modules/basegame/weathers/generic_skybox.tga b/assets/modules/basegame/weathers/generic_skybox.tga index 3f35465d3..89a28fbe3 100644 --- a/assets/modules/basegame/weathers/generic_skybox.tga +++ b/assets/modules/basegame/weathers/generic_skybox.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7eadb9bcc2664d7e8542291e7468a8014ff1eb665ba6545faf9fa3d032b390b0 +oid sha256:f8258add341db69a499b23b2f5df92422d203c1f85eba45b0eecb7e5df5217f4 size 3212 diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index f27c58c49..7c128985d 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -400,18 +400,18 @@ object Terrarum : Game() { - //ingame = Ingame(batch) + ingame = Ingame(batch) //ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(8192, 2048, HQRNG().nextLong()) // TODO: create world being used by title screen, and serialise it. - //ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong()) - //ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW + ingame!!.gameLoadInfoPayload = Ingame.NewWorldParameters(2400, 800, HQRNG().nextLong()) + ingame!!.gameLoadMode = Ingame.GameLoadMode.CREATE_NEW - //LoadScreen.screenToLoad = ingame!! + LoadScreen.screenToLoad = ingame!! - super.setScreen(TitleScreen(batch)) - //super.setScreen(LoadScreen) + //super.setScreen(TitleScreen(batch)) + super.setScreen(LoadScreen) //super.setScreen(ingame) } diff --git a/src/net/torvald/terrarum/TitleScreen.kt b/src/net/torvald/terrarum/TitleScreen.kt index f7c5e2d8c..f9b25a6f4 100644 --- a/src/net/torvald/terrarum/TitleScreen.kt +++ b/src/net/torvald/terrarum/TitleScreen.kt @@ -79,7 +79,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen { ) cameraPlayer.hitbox.setDimension(2.0, 2.0) - demoWorld.time.timeDelta = 45 + demoWorld.time.timeDelta = 60 LightmapRenderer.world = demoWorld diff --git a/src/net/torvald/terrarum/ui/UIStartMenu.kt b/src/net/torvald/terrarum/ui/UIStartMenu.kt index 570841a10..a578365f7 100644 --- a/src/net/torvald/terrarum/ui/UIStartMenu.kt +++ b/src/net/torvald/terrarum/ui/UIStartMenu.kt @@ -12,6 +12,7 @@ class UIStartMenu : UICanvas() { "MENU_MODE_SINGLEPLAYER", "MENU_OPTIONS", "MENU_MODULES", + "MENU_LABEL_LANGUAGE", "MENU_LABEL_EXIT" ) @@ -34,6 +35,8 @@ class UIStartMenu : UICanvas() { readFromLang = true, activeBackCol = Color(0), highlightBackCol = Color(0), + backgroundCol = Color(0), + inactiveCol = Color.WHITE, defaultSelection = null ) diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 17f6398d3..e74d22531 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -2,6 +2,7 @@ package net.torvald.terrarum.weather import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.* +import javafx.scene.effect.Light import net.torvald.terrarum.utils.JsonFetcher import net.torvald.colourutil.* import net.torvald.random.HQRNG @@ -11,6 +12,10 @@ import net.torvald.terrarum.gameactors.ParticleTestRain import net.torvald.terrarum.gamecontroller.KeyToggler import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.WorldTime +import net.torvald.terrarum.worlddrawer.FeaturesDrawer +import net.torvald.terrarum.worlddrawer.LightmapRenderer +import net.torvald.terrarum.worlddrawer.WorldCamera +import net.torvald.terrarum.worldgenerator.WorldGenerator import java.io.File import java.util.* @@ -89,6 +94,9 @@ object WeatherMixer { } + private val parallaxZeroPos = WorldGenerator.TERRAIN_AVERAGE_HEIGHT// + WorldGenerator.TERRAIN_UNDULATION.div(2) + private val parallaxDomainSize = WorldGenerator.TERRAIN_UNDULATION / 2f + fun render(camera: Camera, world: GameWorld) { // we will not care for nextSkybox for now @@ -100,16 +108,33 @@ object WeatherMixer { globalLightNow.set(globalLight) + /* (copied from the shader source) + UV mapping coord.y + + -+ <- 1.0 = + D| = // parallax of +1 + i| = = + s| = // parallax of 0 + p| = = + .| = // parallax of -1 + -+ <- 0.0 = + */ + val parallax: Float = (parallaxZeroPos - WorldCamera.gdxCamY.div(FeaturesDrawer.TILE_SIZE.toFloat())) / parallaxDomainSize + + // draw skybox to provided graphics instance val topCol = getGradientColour(skyboxColourMap, 0, timeNow) val bottomCol = getGradientColour(skyboxColourMap, 1, timeNow) + println("zero pos: $parallaxZeroPos, domain_size: $parallaxDomainSize") + //Terrarum.textureWhiteSquare.bind(0) Terrarum.shaderBayerSkyboxFill.begin() Terrarum.shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined) Terrarum.shaderBayerSkyboxFill.setUniformf("topColor", topCol.r, topCol.g, topCol.b) Terrarum.shaderBayerSkyboxFill.setUniformf("bottomColor", bottomCol.r, bottomCol.g, bottomCol.b) + Terrarum.shaderBayerSkyboxFill.setUniformf("parallax", parallax) Terrarum.fullscreenQuad.render(Terrarum.shaderBayerSkyboxFill, GL20.GL_TRIANGLES) Terrarum.shaderBayerSkyboxFill.end() } diff --git a/src/net/torvald/terrarum/worldgenerator/WorldGenerator.kt b/src/net/torvald/terrarum/worldgenerator/WorldGenerator.kt index 7c3f624b8..a438d0596 100644 --- a/src/net/torvald/terrarum/worldgenerator/WorldGenerator.kt +++ b/src/net/torvald/terrarum/worldgenerator/WorldGenerator.kt @@ -39,16 +39,16 @@ object WorldGenerator { private val NOISE_SIMPLEX_ORE_START = 1.42 private val NOISE_SIMPLEX_ORE_END = 1.28 - private val TERRAIN_UNDULATION = 200 + val TERRAIN_UNDULATION = 200 - private val SIMPLEXGEN_LARGEST_FEATURE = 200 + val SIMPLEXGEN_LARGEST_FEATURE = 200 - private var OCEAN_WIDTH = 400 - private var SHORE_WIDTH = 120 - private val MAX_OCEAN_DEPTH = 200 + var OCEAN_WIDTH = 400 + var SHORE_WIDTH = 120 + val MAX_OCEAN_DEPTH = 200 - private var GLACIER_MOUNTAIN_WIDTH = 900 - private val GLACIER_MOUNTAIN_HEIGHT = 300 + var GLACIER_MOUNTAIN_WIDTH = 900 + val GLACIER_MOUNTAIN_HEIGHT = 300 private val CAVEGEN_THRE_START = 0.4 private val CAVEGEN_THRE_END = 0.1