diff --git a/src/net/torvald/terrarum/Ingame.kt b/src/net/torvald/terrarum/Ingame.kt index a5c253953..b593a89ec 100644 --- a/src/net/torvald/terrarum/Ingame.kt +++ b/src/net/torvald/terrarum/Ingame.kt @@ -74,7 +74,7 @@ class Ingame(val batch: SpriteBatch) : Screen { val ZOOM_MINIMUM = 0.5f companion object { - val lightmapDownsample = 1f + val lightmapDownsample = 2f //2f: still has choppy look when the camera moves but unnoticeable when blurred } @@ -488,10 +488,6 @@ class Ingame(val batch: SpriteBatch) : Screen { - - /////////////////// - // blur lightmap // - /////////////////// worldDrawFrameBuffer.inAction(null, null) { Gdx.gl.glClearColor(0f,0f,0f,0f) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) @@ -524,9 +520,7 @@ class Ingame(val batch: SpriteBatch) : Screen { BlocksDrawer.renderWall(batch) actorsRenderBehind.forEach { it.drawBody(batch) } - actorsRenderBehind.forEach { it.drawGlow(batch) } particlesContainer.forEach { it.drawBody(batch) } - particlesContainer.forEach { it.drawGlow(batch) } BlocksDrawer.renderTerrain(batch) ///////////////// @@ -604,7 +598,9 @@ class Ingame(val batch: SpriteBatch) : Screen { ////////////////////// // draw actor glows // ////////////////////// - + + actorsRenderBehind.forEach { it.drawGlow(batch) } + particlesContainer.forEach { it.drawGlow(batch) } actorsRenderMiddle.forEach { it.drawGlow(batch) } actorsRenderMidTop.forEach { it.drawGlow(batch) } player?.drawGlow(batch) @@ -645,6 +641,9 @@ class Ingame(val batch: SpriteBatch) : Screen { val worldTex = worldDrawFrameBuffer.colorBufferTexture // WORLD: light_color must be applied beforehand val glowTex = worldGlowFrameBuffer.colorBufferTexture // GLOW: light_uvlight must be applied beforehand + worldTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) + glowTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) + //Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) worldTex.bind(0) glowTex.bind(1) @@ -702,6 +701,7 @@ class Ingame(val batch: SpriteBatch) : Screen { val blendedTex = worldBlendFrameBuffer.colorBufferTexture + blendedTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) batch.color = Color.WHITE batch.shader = null blendNormal() @@ -1454,15 +1454,15 @@ class Ingame(val batch: SpriteBatch) : Screen { */ override fun resize(width: Int, height: Int) { worldDrawFrameBuffer.dispose() - worldDrawFrameBuffer = FrameBuffer(worldFBOformat, width, height, true) + worldDrawFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, true) worldGlowFrameBuffer.dispose() - worldGlowFrameBuffer = FrameBuffer(worldFBOformat, width, height, true) + worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, true) worldBlendFrameBuffer.dispose() - worldBlendFrameBuffer = FrameBuffer(worldFBOformat, width, height, true) + worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, true) lightmapFboA.dispose() - lightmapFboA = FrameBuffer(lightFBOformat, width.div(lightmapDownsample.toInt()), height.div(lightmapDownsample.toInt()), true) + lightmapFboA = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), true) lightmapFboB.dispose() - lightmapFboB = FrameBuffer(lightFBOformat, width.div(lightmapDownsample.toInt()), height.div(lightmapDownsample.toInt()), true) + lightmapFboB = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), true) //lightmapUvFboA.dispose() //lightmapUvFboA = FrameBuffer(lightUvFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), true) //lightmapUvFboB.dispose() diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index c5bd229f4..2f266228c 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -247,6 +247,9 @@ object Terrarum : ApplicationAdapter() { lateinit var shaderBlendGlow: ShaderProgram + lateinit var textureWhiteSquare: Texture + + init { println("[Terrarum] os.arch = $systemArch") // debug info @@ -299,6 +302,10 @@ object Terrarum : ApplicationAdapter() { fontSmallNumbers = TinyAlphNum + textureWhiteSquare = Texture(Gdx.files.internal("assets/graphics/ortho_line_tex_2px.tga")) + textureWhiteSquare.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) + + ShaderProgram.pedantic = false shaderBlur = ShaderProgram(Gdx.files.internal("assets/blur.vert"), Gdx.files.internal("assets/blur.frag")) shader4096 = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/4096.frag")) @@ -567,7 +574,7 @@ fun Float.round(): Float { // ShapeRenderer alternative for rects fun SpriteBatch.fillRect(x: Float, y: Float, w: Float, h: Float) { - this.draw(net.torvald.terrarum.worlddrawer.BlocksDrawer.tilesTerrain.get(1, 0), x, y, w, h) + this.draw(Terrarum.textureWhiteSquare, x, y, w, h) } inline fun SpriteBatch.drawStraightLine(x: Float, y: Float, p2: Float, thickness: Float, isVertical: Boolean) { if (!isVertical) diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt index 539b8d9c5..eb4f251eb 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer_old.kt @@ -86,7 +86,9 @@ object BlocksDrawer { gzTmpFName.forEach { File(it).delete() } tilesTerrain = TextureRegionPack(Texture(terrainPixMap), TILE_SIZE, TILE_SIZE) + tilesTerrain.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) tilesWire = TextureRegionPack(Texture(wirePixMap), TILE_SIZE, TILE_SIZE) + tilesWire.texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) // also dispose unused temp files //terrainPixMap.dispose() // commented: tileItemWall needs it diff --git a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt index 1c1844e38..129c25fed 100644 --- a/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt +++ b/src/net/torvald/terrarum/worlddrawer/LightmapRenderer.kt @@ -381,11 +381,12 @@ object LightmapRenderer { batch.color = (getLightForOpaque(x, y) ?: Color(0f,0f,0f,0f)).normaliseToAlphaHDR() } + batch.fillRect( - (x * DRAW_TILE_SIZE).round().toFloat(), - (y * DRAW_TILE_SIZE).round().toFloat(), - DRAW_TILE_SIZE.ceil() * sameLevelCounter + 1f, - DRAW_TILE_SIZE.ceil() + 1f + x * DRAW_TILE_SIZE, + y * DRAW_TILE_SIZE, + (DRAW_TILE_SIZE * sameLevelCounter).ceil().toFloat(),// + 1f, + DRAW_TILE_SIZE.ceil().toFloat()// + 1f ) x += sameLevelCounter - 1 diff --git a/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt b/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt index 502411dd8..1ec5ca658 100644 --- a/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt +++ b/src/net/torvald/terrarum/worlddrawer/WorldCamera.kt @@ -2,6 +2,8 @@ package net.torvald.terrarum.worlddrawer import com.jme3.math.FastMath import net.torvald.terrarum.Terrarum +import net.torvald.terrarum.gameactors.floor +import net.torvald.terrarum.gameactors.floorInt import net.torvald.terrarum.gameactors.roundInt import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.round @@ -40,16 +42,16 @@ object WorldCamera { // position - (WH / 2) x = (// X only: ROUNDWORLD implementation - (player?.hitbox?.centeredX?.toFloat() ?: 0f) - width / 2).roundInt() + (player?.hitbox?.centeredX?.toFloat() ?: 0f) - width / 2).floorInt() y = (FastMath.clamp( (player?.hitbox?.centeredY?.toFloat() ?: 0f) - height / 2, TILE_SIZE.toFloat(), world!!.height * TILE_SIZE - height - TILE_SIZE.toFloat() - )).roundInt() + )).floorInt() - gdxCamX = x + (width / 2f).round() - gdxCamY = y + (height / 2f).round() + gdxCamX = x + (width / 2f).floor() + gdxCamY = y + (height / 2f).floor() } } } \ No newline at end of file