lightmap downsample works, sampling bug fixed with Filter.NEAREST, now having shrinkage issue

This commit is contained in:
minjaesong
2017-07-12 14:33:59 +09:00
parent bad6ff296a
commit 6bff02d91e
5 changed files with 34 additions and 22 deletions

View File

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

View File

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

View File

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