diff --git a/src/net/torvald/gdx/graphics/Cvec.kt b/src/net/torvald/gdx/graphics/Cvec.kt index 5f6722bda..035b50452 100644 --- a/src/net/torvald/gdx/graphics/Cvec.kt +++ b/src/net/torvald/gdx/graphics/Cvec.kt @@ -445,6 +445,8 @@ class Cvec { ) } + fun fastLum() = (3*r + 4*g + b)/8f + companion object { val WHITE = Cvec(1f, 1f, 1f, 1f) diff --git a/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt b/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt index 375634c6a..2567198b7 100644 --- a/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt +++ b/src/net/torvald/terrarum/modulebasegame/IngameRenderer.kt @@ -528,14 +528,19 @@ object IngameRenderer : Disposable { else blendMul(batch) - batch.shader = shaderRGBOnly - batch.shader.setUniformi("rnd", rng.nextInt(8192), rng.nextInt(8192)) - batch.shader.setUniformi("u_pattern", 1) - batch.draw(lightTex, +// if (!KeyToggler.isOn(Input.Keys.F9)) { + batch.shader = shaderRGBOnly + batch.shader.setUniformi("rnd", rng.nextInt(8192), rng.nextInt(8192)) + batch.shader.setUniformi("u_pattern", 1) + batch.draw( + lightTex, xrem, yrem, lightTex.regionWidth * lightmapDownsample, lightTex.regionHeight * lightmapDownsample - ) + ) +// } + + // if right texture coord for lightTex and fboRGB are obtainable, you can try this: /* diff --git a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt index c8b2182af..f9e81f943 100644 --- a/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt +++ b/src/net/torvald/terrarum/worlddrawer/BlocksDrawer.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.Input.Keys import com.badlogic.gdx.graphics.* import com.badlogic.gdx.math.Matrix4 import com.jme3.math.FastMath +import net.torvald.gdx.graphics.Cvec import net.torvald.terrarum.* import net.torvald.terrarum.App.measureDebugTime import net.torvald.terrarum.App.printdbg @@ -350,7 +351,7 @@ internal object BlocksDrawer { App.tileMaker.fluidToTileNumber(world.getFluid(x, y)) else renderTag.tileNumber - val tileNumber = if (thisTile == Block.AIR) 0 + var tileNumber = if (thisTile == Block.AIR) 0 // special case: actorblocks and F3 key else if (BlockCodex.hasProp(thisTile) && BlockCodex[thisTile].isActorBlock && !BlockCodex[thisTile].hasTag("DORENDER") && !KeyToggler.isOn(Keys.F3)) @@ -367,6 +368,12 @@ internal object BlocksDrawer { else -> throw IllegalArgumentException("Unknown mask type: ${renderTag.maskType}") } + // hide tiles with super low lights, kinda like Minecraft's Orebfuscator + val lightAtXY = LightmapRenderer.getLight(x, y) ?: Cvec(0) + if (lightAtXY.fastLum() <= 2f / 255f) { + tileNumber = 2 // black solid + } + var thisTileX = tileNumber % App.tileMaker.TILES_IN_X var thisTileY = tileNumber / App.tileMaker.TILES_IN_X