mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
lightmap edge-case fixed
when camera.x is in -15..-1, all thing shifts to left
This commit is contained in:
@@ -23,7 +23,6 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
* This will be rendered to a postprocessor FBO
|
||||
*/
|
||||
object IngameRenderer {
|
||||
|
||||
/** for non-private use, use with care! */
|
||||
lateinit var batch: SpriteBatch
|
||||
private lateinit var camera: OrthographicCamera
|
||||
@@ -274,8 +273,7 @@ object IngameRenderer {
|
||||
fboRGB_lightMixed.inAction(camera, batch) {
|
||||
|
||||
setCameraPosition(0f, 0f)
|
||||
val xrem = -(WorldCamera.x.toFloat() fmod TILE_SIZEF)
|
||||
val yrem = -(WorldCamera.y.toFloat() fmod TILE_SIZEF)
|
||||
val (xrem, yrem) = worldCamToRenderPos()
|
||||
|
||||
batch.inUse {
|
||||
// draw world
|
||||
@@ -357,8 +355,7 @@ object IngameRenderer {
|
||||
fboA_lightMixed.inAction(camera, batch) {
|
||||
|
||||
setCameraPosition(0f, 0f)
|
||||
val xrem = -(WorldCamera.x.toFloat() fmod TILE_SIZEF)
|
||||
val yrem = -(WorldCamera.y.toFloat() fmod TILE_SIZEF)
|
||||
val (xrem, yrem) = worldCamToRenderPos()
|
||||
|
||||
batch.inUse {
|
||||
// draw world
|
||||
@@ -557,4 +554,12 @@ object IngameRenderer {
|
||||
|
||||
LightmapRenderer.dispose()
|
||||
}
|
||||
|
||||
private fun worldCamToRenderPos(): Pair<Float, Float> {
|
||||
// for some reason it does not like integer. No, really; it breaks (jitter when you move) when you try to "fix" that.
|
||||
val xrem = -(WorldCamera.x.toFloat() fmod TILE_SIZEF)
|
||||
val yrem = -(WorldCamera.y.toFloat() fmod TILE_SIZEF)
|
||||
|
||||
return xrem to yrem
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ object PlayerBuilderSigrid {
|
||||
Block.ILLUMINATOR_WHITE, Block.ILLUMINATOR_BLACK, Block.ILLUMINATOR_ORANGE,
|
||||
Block.ILLUMINATOR_GREEN, Block.ILLUMINATOR_CYAN, Block.SUNSTONE,
|
||||
Block.ORE_COPPER,
|
||||
Block.PLATFORM_WOODEN
|
||||
Block.PLATFORM_STONE, Block.PLATFORM_WOODEN, Block.PLATFORM_BIRCH, Block.PLATFORM_BLOODROSE, Block.PLATFORM_EBONY
|
||||
)
|
||||
val walls = arrayOf(
|
||||
Block.AIR, Block.DIRT, Block.GLASS_CRUDE,
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-14.
|
||||
@@ -49,10 +50,6 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
fun Int.rawR() = this / LightmapRenderer.MUL_2
|
||||
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
|
||||
fun Int.rawB() = this % LightmapRenderer.MUL
|
||||
|
||||
val player = ingame.actorNowPlaying
|
||||
|
||||
batch.color = Color(0xFFEE88FF.toInt())
|
||||
@@ -77,6 +74,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
+ " ("
|
||||
+ "${(hitbox?.endX?.div(FeaturesDrawer.TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLineColumn(batch, 3, 1, "camX "
|
||||
+ ccG
|
||||
+ "${WorldCamera.x}")
|
||||
printLineColumn(batch, 1, 2, "startY "
|
||||
+ ccG
|
||||
+ "${hitbox?.startY}"
|
||||
@@ -89,6 +89,9 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
+ " ("
|
||||
+ "${(hitbox?.endY?.div(FeaturesDrawer.TILE_SIZE))?.toInt()}"
|
||||
+ ")")
|
||||
printLineColumn(batch, 3, 2, "camY "
|
||||
+ ccG
|
||||
+ "${WorldCamera.y}")
|
||||
|
||||
printLine(batch, 3, "veloX reported $ccG${player.externalForce.x}")
|
||||
printLine(batch, 4, "veloY reported $ccG${player.externalForce.y}")
|
||||
|
||||
@@ -37,8 +37,6 @@ import kotlin.system.measureNanoTime
|
||||
*/
|
||||
object LightmapRenderer {
|
||||
|
||||
// FIXME lightmap shifts to left, ONLY AT x=33.5-34.5
|
||||
|
||||
private var world: GameWorld = GameWorld.makeNullWorld()
|
||||
|
||||
/** do not call this yourself! Let your game renderer handle this! */
|
||||
@@ -173,7 +171,7 @@ object LightmapRenderer {
|
||||
world.getTileFromTerrain(0, 0) // test inquiry
|
||||
}
|
||||
catch (e: UninitializedPropertyAccessException) {
|
||||
return // quit prematually
|
||||
return // quit prematurely
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +181,8 @@ object LightmapRenderer {
|
||||
if (for_x_start < 0) for_x_start -= 1 // to fix that the light shifts 1 tile to the left when WorldCamera < 0
|
||||
//if (for_y_start < 0) for_y_start -= 1 // not needed when we only wrap at x axis
|
||||
|
||||
if (WorldCamera.x in -(TILE_SIZE - 1)..-1) for_x_start -= 1 // another edge-case fix
|
||||
|
||||
for_x_end = for_x_start + WorldCamera.width / TILE_SIZE + 3
|
||||
for_y_end = for_y_start + WorldCamera.height / TILE_SIZE + 2 // same fix as above
|
||||
|
||||
@@ -763,7 +763,7 @@ object LightmapRenderer {
|
||||
|
||||
|
||||
val rgbHDRLookupTable = floatArrayOf( // polynomial of 6.0 please refer to work_files/HDRcurveBezierLinIntp.kts
|
||||
0.0000f,0.0000f,0.0020f,0.0060f,0.0100f,0.0139f,0.0179f,0.0219f,0.0259f,0.0299f,0.0338f,0.0378f,0.0418f,0.0458f,0.0497f,0.0537f,
|
||||
0.0000f,0.0004f,0.0020f,0.0060f,0.0100f,0.0139f,0.0179f,0.0219f,0.0259f,0.0299f,0.0338f,0.0378f,0.0418f,0.0458f,0.0497f,0.0537f,
|
||||
0.0577f,0.0617f,0.0656f,0.0696f,0.0736f,0.0776f,0.0816f,0.0855f,0.0895f,0.0935f,0.0975f,0.1014f,0.1054f,0.1094f,0.1134f,0.1173f,
|
||||
0.1213f,0.1253f,0.1293f,0.1332f,0.1372f,0.1412f,0.1451f,0.1491f,0.1531f,0.1571f,0.1610f,0.1650f,0.1690f,0.1730f,0.1769f,0.1809f,
|
||||
0.1849f,0.1888f,0.1928f,0.1968f,0.2007f,0.2047f,0.2087f,0.2127f,0.2166f,0.2206f,0.2246f,0.2285f,0.2325f,0.2365f,0.2404f,0.2444f,
|
||||
|
||||
Reference in New Issue
Block a user