mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 04:24:05 +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 {
|
companion object {
|
||||||
val WHITE = Cvec(1f, 1f, 1f, 1f)
|
val WHITE = Cvec(1f, 1f, 1f, 1f)
|
||||||
|
|
||||||
|
|||||||
@@ -528,14 +528,19 @@ object IngameRenderer : Disposable {
|
|||||||
else
|
else
|
||||||
blendMul(batch)
|
blendMul(batch)
|
||||||
|
|
||||||
batch.shader = shaderRGBOnly
|
// if (!KeyToggler.isOn(Input.Keys.F9)) {
|
||||||
batch.shader.setUniformi("rnd", rng.nextInt(8192), rng.nextInt(8192))
|
batch.shader = shaderRGBOnly
|
||||||
batch.shader.setUniformi("u_pattern", 1)
|
batch.shader.setUniformi("rnd", rng.nextInt(8192), rng.nextInt(8192))
|
||||||
batch.draw(lightTex,
|
batch.shader.setUniformi("u_pattern", 1)
|
||||||
|
batch.draw(
|
||||||
|
lightTex,
|
||||||
xrem, yrem,
|
xrem, yrem,
|
||||||
lightTex.regionWidth * lightmapDownsample,
|
lightTex.regionWidth * lightmapDownsample,
|
||||||
lightTex.regionHeight * lightmapDownsample
|
lightTex.regionHeight * lightmapDownsample
|
||||||
)
|
)
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if right texture coord for lightTex and fboRGB are obtainable, you can try this:
|
// 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.graphics.*
|
||||||
import com.badlogic.gdx.math.Matrix4
|
import com.badlogic.gdx.math.Matrix4
|
||||||
import com.jme3.math.FastMath
|
import com.jme3.math.FastMath
|
||||||
|
import net.torvald.gdx.graphics.Cvec
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.App.measureDebugTime
|
import net.torvald.terrarum.App.measureDebugTime
|
||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
@@ -350,7 +351,7 @@ internal object BlocksDrawer {
|
|||||||
App.tileMaker.fluidToTileNumber(world.getFluid(x, y))
|
App.tileMaker.fluidToTileNumber(world.getFluid(x, y))
|
||||||
else
|
else
|
||||||
renderTag.tileNumber
|
renderTag.tileNumber
|
||||||
val tileNumber = if (thisTile == Block.AIR) 0
|
var tileNumber = if (thisTile == Block.AIR) 0
|
||||||
// special case: actorblocks and F3 key
|
// special case: actorblocks and F3 key
|
||||||
else if (BlockCodex.hasProp(thisTile) && BlockCodex[thisTile].isActorBlock &&
|
else if (BlockCodex.hasProp(thisTile) && BlockCodex[thisTile].isActorBlock &&
|
||||||
!BlockCodex[thisTile].hasTag("DORENDER") && !KeyToggler.isOn(Keys.F3))
|
!BlockCodex[thisTile].hasTag("DORENDER") && !KeyToggler.isOn(Keys.F3))
|
||||||
@@ -367,6 +368,12 @@ internal object BlocksDrawer {
|
|||||||
else -> throw IllegalArgumentException("Unknown mask type: ${renderTag.maskType}")
|
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 thisTileX = tileNumber % App.tileMaker.TILES_IN_X
|
||||||
var thisTileY = tileNumber / App.tileMaker.TILES_IN_X
|
var thisTileY = tileNumber / App.tileMaker.TILES_IN_X
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user