mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
orebfuscator impl
This commit is contained in:
@@ -445,6 +445,8 @@ class Cvec {
|
||||
)
|
||||
}
|
||||
|
||||
fun fastLum() = (3*r + 4*g + b)/8f
|
||||
|
||||
companion object {
|
||||
val WHITE = Cvec(1f, 1f, 1f, 1f)
|
||||
|
||||
|
||||
@@ -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:
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user