fixed bad color rendering on blocksdrawer and lightmaprenderer

This commit is contained in:
minjaesong
2017-07-02 21:53:50 +09:00
parent bea125b66d
commit bbc68110d9
15 changed files with 61 additions and 66 deletions

View File

@@ -352,8 +352,7 @@ object BlocksDrawer {
*/
blendNormal()
batch.color = wallOverlayColour
drawTiles(batch, WALL, false)
drawTiles(batch, WALL, false, wallOverlayColour)
}
fun renderTerrain(batch: SpriteBatch) {
@@ -362,8 +361,7 @@ object BlocksDrawer {
*/
blendNormal()
batch.color = Color.WHITE
drawTiles(batch, TERRAIN, false) // regular tiles
drawTiles(batch, TERRAIN, false, Color.WHITE) // regular tiles
}
fun renderFront(batch: SpriteBatch, drawWires: Boolean) {
@@ -372,11 +370,10 @@ object BlocksDrawer {
*/
blendMul()
batch.color = Color.WHITE
drawTiles(batch, TERRAIN, true) // blendmul tiles
drawTiles(batch, TERRAIN, true, Color.WHITE) // blendmul tiles
if (drawWires) {
drawTiles(batch, WIRE, false)
drawTiles(batch, WIRE, false, Color.WHITE)
}
blendNormal()
@@ -384,7 +381,7 @@ object BlocksDrawer {
private val tileDrawLightThreshold = 2
private fun drawTiles(batch: SpriteBatch, mode: Int, drawModeTilesBlendMul: Boolean) {
private fun drawTiles(batch: SpriteBatch, mode: Int, drawModeTilesBlendMul: Boolean, color: Color) {
val for_y_start = y / TILE_SIZE
val for_y_end = BlocksDrawer.clampHTile(for_y_start + (height / TILE_SIZE) + 2)
@@ -393,6 +390,8 @@ object BlocksDrawer {
var zeroTileCounter = 0
batch.color = color
// loop
for (y in for_y_start..for_y_end) {
for (x in for_x_start..for_x_end - 1) {
@@ -490,7 +489,7 @@ object BlocksDrawer {
batch.fillRect(x.toFloat(), y.toFloat(), TILE_SIZEF, TILE_SIZEF)
batch.color = Color.WHITE
batch.color = color
}
} // end if (not an air)
} catch (e: NullPointerException) {

View File

@@ -320,6 +320,8 @@ object LightmapRenderer {
val this_y_end = for_y_end// + overscan_open
val originalColour = batch.color.cpy()
// draw to the
try {
// loop for "scanlines"
@@ -329,7 +331,7 @@ object LightmapRenderer {
while (x < this_x_end) {
// smoothing enabled and zoom is 0.75 or greater
// (zoom of 0.5 should not smoothed, for performance)
if (TerrarumGDX.getConfigBoolean("smoothlighting") ?: false &&
if (TerrarumGDX.getConfigBoolean("smoothlighting") &&
TerrarumGDX.ingame!!.screenZoom >= 0.75) {
val thisLightLevel = getLightForOpaque(x, y) ?: 0
@@ -435,6 +437,8 @@ object LightmapRenderer {
}
batch.color = originalColour
}
val lightScalingMagic = 8f