parallax (sky looks bluer when you go up)

This commit is contained in:
minjaesong
2017-07-20 18:39:05 +09:00
parent 5d86f054e8
commit 6f2c1e578e
35 changed files with 144 additions and 17 deletions

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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
)

View File

@@ -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()
}

View File

@@ -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