mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 01:54:04 +09:00
Ingame: great, nothing renders :(
This commit is contained in:
@@ -145,7 +145,7 @@ class FuckingWorldRenderer(val batch: SpriteBatch) : Screen {
|
|||||||
//demoWorld.time.timeDelta = 150
|
//demoWorld.time.timeDelta = 150
|
||||||
|
|
||||||
|
|
||||||
LightmapRendererNew.world = demoWorld
|
LightmapRenderer.world = demoWorld
|
||||||
BlocksDrawer.world = demoWorld
|
BlocksDrawer.world = demoWorld
|
||||||
FeaturesDrawer.world = demoWorld
|
FeaturesDrawer.world = demoWorld
|
||||||
|
|
||||||
@@ -220,12 +220,12 @@ class FuckingWorldRenderer(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LightmapRendererNew.fireRecalculateEvent() // don't half-frame update; it will jitter!
|
LightmapRenderer.fireRecalculateEvent() // don't half-frame update; it will jitter!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun renderScreen() {
|
fun renderScreen() {
|
||||||
|
|
||||||
processBlur(LightmapRendererNew.DRAW_FOR_RGB)
|
processBlur(LightmapRenderer.DRAW_FOR_RGB)
|
||||||
//camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
//camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||||
|
|
||||||
// render world
|
// render world
|
||||||
@@ -360,7 +360,7 @@ class FuckingWorldRenderer(val batch: SpriteBatch) : Screen {
|
|||||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
LightmapRendererNew.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
LightmapRenderer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
if (loadDone) {
|
if (loadDone) {
|
||||||
// resize UI by re-creating it (!!)
|
// resize UI by re-creating it (!!)
|
||||||
@@ -374,14 +374,14 @@ class FuckingWorldRenderer(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
lightmapFboA = FrameBuffer(
|
lightmapFboA = FrameBuffer(
|
||||||
lightFBOformat,
|
lightFBOformat,
|
||||||
LightmapRendererNew.lightBuffer.width * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
LightmapRendererNew.lightBuffer.height * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
lightmapFboB = FrameBuffer(
|
lightmapFboB = FrameBuffer(
|
||||||
lightFBOformat,
|
lightFBOformat,
|
||||||
LightmapRendererNew.lightBuffer.width * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
LightmapRendererNew.lightBuffer.height * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
lightmapInitialised = true // are you the first time?
|
lightmapInitialised = true // are you the first time?
|
||||||
@@ -420,13 +420,13 @@ class FuckingWorldRenderer(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mode == LightmapRendererNew.DRAW_FOR_RGB) {
|
if (mode == LightmapRenderer.DRAW_FOR_RGB) {
|
||||||
// initialise readBuffer with untreated lightmap
|
// initialise readBuffer with untreated lightmap
|
||||||
blurReadBuffer.inAction(camera, batch) {
|
blurReadBuffer.inAction(camera, batch) {
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
LightmapRendererNew.draw(batch, LightmapRendererNew.DRAW_FOR_RGB)
|
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_RGB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -436,7 +436,7 @@ class FuckingWorldRenderer(val batch: SpriteBatch) : Screen {
|
|||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
LightmapRendererNew.draw(batch, LightmapRendererNew.DRAW_FOR_ALPHA)
|
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_ALPHA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import javax.swing.JOptionPane
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.ui.*
|
import net.torvald.terrarum.ui.*
|
||||||
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
||||||
import net.torvald.terrarum.worldgenerator.WorldGenerator
|
import net.torvald.terrarum.worldgenerator.WorldGenerator
|
||||||
@@ -93,13 +94,11 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
var worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
var worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
||||||
var worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
var worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
||||||
// RGB elements of Lightmap for Color Vec4(R, G, B, 1.0) 24-bit
|
// RGB elements of Lightmap for Color Vec4(R, G, B, 1.0) 24-bit
|
||||||
var lightmapFboA = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
|
private lateinit var lightmapFboA: FrameBuffer
|
||||||
var lightmapFboB = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
|
private lateinit var lightmapFboB: FrameBuffer
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
println("worldDrawFrameBuffer.colorBufferTexture.textureData.format: ${worldDrawFrameBuffer.colorBufferTexture.textureData.format}")
|
|
||||||
println("lightmapFboB.colorBufferTexture.textureData.format: ${lightmapFboB.colorBufferTexture.textureData.format}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -157,6 +156,8 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
|
|
||||||
|
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
// GDX code //
|
// GDX code //
|
||||||
//////////////
|
//////////////
|
||||||
@@ -523,9 +524,6 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private var blurWriteBuffer = lightmapFboA
|
|
||||||
private var blurReadBuffer = lightmapFboB
|
|
||||||
|
|
||||||
private fun renderGame(batch: SpriteBatch) {
|
private fun renderGame(batch: SpriteBatch) {
|
||||||
Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||||
@@ -539,10 +537,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// update lightmap on every other frames, OR full-frame if the option is true
|
LightmapRenderer.fireRecalculateEvent()
|
||||||
if (Terrarum.getConfigBoolean("fullframelightupdate") or (TerrarumAppLoader.GLOBAL_RENDER_TIMER % 2 == 1)) {
|
|
||||||
LightmapRenderer.fireRecalculateEvent()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -608,17 +603,20 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
batch.shader.setUniformf("gcount", 64f)
|
batch.shader.setUniformf("gcount", 64f)
|
||||||
batch.shader.setUniformf("bcount", 64f) // de-banding
|
batch.shader.setUniformf("bcount", 64f) // de-banding
|
||||||
|
|
||||||
val lightTex = blurWriteBuffer.colorBufferTexture // TODO zoom!
|
val lightTex = lightmapFboB.colorBufferTexture // A or B? flipped in Y means you chose wrong buffer; use one that works correctly
|
||||||
|
lightTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) // blocky feeling for A E S T H E T I C S
|
||||||
lightTex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
|
||||||
|
|
||||||
if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal()
|
if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal()
|
||||||
else blendMul()
|
else blendMul()
|
||||||
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
val xrem = -(WorldCamera.x.toFloat() fmod TILE_SIZEF)
|
||||||
|
val yrem = -(WorldCamera.y.toFloat() fmod TILE_SIZEF)
|
||||||
batch.draw(lightTex,
|
batch.draw(lightTex,
|
||||||
0f, 0f,
|
xrem,
|
||||||
lightTex.width * lightmapDownsample, lightTex.height * lightmapDownsample
|
yrem,
|
||||||
|
lightTex.width * Ingame.lightmapDownsample, lightTex.height * Ingame.lightmapDownsample
|
||||||
|
//lightTex.width.toFloat(), lightTex.height.toFloat() // for debugging
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -677,17 +675,20 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
batch.shader.setUniformf("gcount", 64f)
|
batch.shader.setUniformf("gcount", 64f)
|
||||||
batch.shader.setUniformf("bcount", 64f) // de-banding
|
batch.shader.setUniformf("bcount", 64f) // de-banding
|
||||||
|
|
||||||
val lightTex = blurWriteBuffer.colorBufferTexture // TODO zoom!
|
val lightTex = lightmapFboB.colorBufferTexture // A or B? flipped in Y means you chose wrong buffer; use one that works correctly
|
||||||
|
lightTex.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest) // blocky feeling for A E S T H E T I C S
|
||||||
lightTex.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
|
||||||
|
|
||||||
if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal()
|
if (KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendNormal()
|
||||||
else blendMul()
|
else blendMul()
|
||||||
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
|
val xrem = -(WorldCamera.x.toFloat() fmod TILE_SIZEF)
|
||||||
|
val yrem = -(WorldCamera.y.toFloat() fmod TILE_SIZEF)
|
||||||
batch.draw(lightTex,
|
batch.draw(lightTex,
|
||||||
0f, 0f,
|
xrem,
|
||||||
lightTex.width * lightmapDownsample, lightTex.height * lightmapDownsample
|
yrem,
|
||||||
|
lightTex.width * Ingame.lightmapDownsample, lightTex.height * Ingame.lightmapDownsample
|
||||||
|
//lightTex.width.toFloat(), lightTex.height.toFloat() // for debugging
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -856,8 +857,8 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
val blurIterations = 5 // ideally, 4 * radius; must be even/odd number -- odd/even number will flip the image
|
val blurIterations = 5 // ideally, 4 * radius; must be even/odd number -- odd/even number will flip the image
|
||||||
val blurRadius = 4f / lightmapDownsample // (5, 4f); using low numbers for pixel-y aesthetics
|
val blurRadius = 4f / lightmapDownsample // (5, 4f); using low numbers for pixel-y aesthetics
|
||||||
|
|
||||||
blurWriteBuffer = lightmapFboA
|
var blurWriteBuffer = lightmapFboA
|
||||||
blurReadBuffer = lightmapFboB
|
var blurReadBuffer = lightmapFboB
|
||||||
|
|
||||||
|
|
||||||
lightmapFboA.inAction(null, null) {
|
lightmapFboA.inAction(null, null) {
|
||||||
@@ -874,17 +875,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
// initialise readBuffer with untreated lightmap
|
// initialise readBuffer with untreated lightmap
|
||||||
blurReadBuffer.inAction(camera, batch) {
|
blurReadBuffer.inAction(camera, batch) {
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
// using custom code for camera; this is obscure and tricky
|
blendNormal(batch)
|
||||||
camera.position.set(
|
|
||||||
(WorldCamera.gdxCamX / lightmapDownsample).round(),
|
|
||||||
(WorldCamera.gdxCamY / lightmapDownsample).round(),
|
|
||||||
0f
|
|
||||||
) // make camara work
|
|
||||||
camera.update()
|
|
||||||
batch.projectionMatrix = camera.combined
|
|
||||||
|
|
||||||
|
|
||||||
blendNormal()
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_RGB)
|
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_RGB)
|
||||||
}
|
}
|
||||||
@@ -894,17 +885,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
// initialise readBuffer with untreated lightmap
|
// initialise readBuffer with untreated lightmap
|
||||||
blurReadBuffer.inAction(camera, batch) {
|
blurReadBuffer.inAction(camera, batch) {
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
// using custom code for camera; this is obscure and tricky
|
blendNormal(batch)
|
||||||
camera.position.set(
|
|
||||||
(WorldCamera.gdxCamX / lightmapDownsample).round(),
|
|
||||||
(WorldCamera.gdxCamY / lightmapDownsample).round(),
|
|
||||||
0f
|
|
||||||
) // make camara work
|
|
||||||
camera.update()
|
|
||||||
batch.projectionMatrix = camera.combined
|
|
||||||
|
|
||||||
|
|
||||||
blendNormal()
|
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_ALPHA)
|
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_ALPHA)
|
||||||
}
|
}
|
||||||
@@ -1346,6 +1327,10 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private var lightmapInitialised = false // to avoid nullability of lightmapFBO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param width same as Terrarum.WIDTH
|
* @param width same as Terrarum.WIDTH
|
||||||
* @param height same as Terrarum.HEIGHT
|
* @param height same as Terrarum.HEIGHT
|
||||||
@@ -1354,6 +1339,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
|
|
||||||
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
LightmapRenderer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
worldDrawFrameBuffer.dispose()
|
worldDrawFrameBuffer.dispose()
|
||||||
worldDrawFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
worldDrawFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
||||||
@@ -1361,10 +1347,24 @@ class Ingame(val batch: SpriteBatch) : Screen {
|
|||||||
worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
||||||
worldBlendFrameBuffer.dispose()
|
worldBlendFrameBuffer.dispose()
|
||||||
worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
||||||
lightmapFboA.dispose()
|
|
||||||
lightmapFboA = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
|
if (lightmapInitialised) {
|
||||||
lightmapFboB.dispose()
|
lightmapFboA.dispose()
|
||||||
lightmapFboB = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
|
lightmapFboB.dispose()
|
||||||
|
}
|
||||||
|
lightmapFboA = FrameBuffer(
|
||||||
|
lightFBOformat,
|
||||||
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
lightmapFboB = FrameBuffer(
|
||||||
|
lightFBOformat,
|
||||||
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
lightmapInitialised = true // are you the first time?
|
||||||
|
|
||||||
|
|
||||||
// Set up viewport when window is resized
|
// Set up viewport when window is resized
|
||||||
|
|||||||
@@ -442,8 +442,8 @@ object Terrarum : Screen {
|
|||||||
|
|
||||||
|
|
||||||
// title screen
|
// title screen
|
||||||
//appLoader.setScreen(TitleScreen(batch))
|
appLoader.setScreen(TitleScreen(batch))
|
||||||
appLoader.setScreen(FuckingWorldRenderer(batch))
|
//appLoader.setScreen(FuckingWorldRenderer(batch))
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun setScreen(screen: Screen) {
|
internal fun setScreen(screen: Screen) {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
setHitboxDimension(2, 2, 0, 0)
|
setHitboxDimension(2, 2, 0, 0)
|
||||||
hitbox.setPosition(
|
hitbox.setPosition(
|
||||||
HQRNG().nextInt(demoWorld.width) * FeaturesDrawer.TILE_SIZE.toDouble(),
|
HQRNG().nextInt(demoWorld.width) * FeaturesDrawer.TILE_SIZE.toDouble(),
|
||||||
0.0 // placeholder; camera AI will take it over
|
0.0 // Y pos: placeholder; camera AI will take it over
|
||||||
)
|
)
|
||||||
noClip = true
|
noClip = true
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
demoWorld.time.timeDelta = 150
|
demoWorld.time.timeDelta = 150
|
||||||
|
|
||||||
|
|
||||||
LightmapRendererNew.world = demoWorld
|
LightmapRenderer.world = demoWorld
|
||||||
BlocksDrawer.world = demoWorld
|
BlocksDrawer.world = demoWorld
|
||||||
FeaturesDrawer.world = demoWorld
|
FeaturesDrawer.world = demoWorld
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateScreen(delta: Float) {
|
fun updateScreen(delta: Float) {
|
||||||
Gdx.graphics.setTitle(TerrarumAppLoader.GAME_NAME +
|
Gdx.graphics.setTitle("WorldRenderTest" +
|
||||||
" — F: ${Gdx.graphics.framesPerSecond} (${Terrarum.TARGET_INTERNAL_FPS})" +
|
" — F: ${Gdx.graphics.framesPerSecond} (${Terrarum.TARGET_INTERNAL_FPS})" +
|
||||||
" — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M"
|
" — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M"
|
||||||
)
|
)
|
||||||
@@ -220,12 +220,12 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
LightmapRendererNew.fireRecalculateEvent() // don't half-frame update; it will jitter!
|
LightmapRenderer.fireRecalculateEvent() // don't half-frame update; it will jitter!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun renderScreen() {
|
fun renderScreen() {
|
||||||
|
|
||||||
processBlur(LightmapRendererNew.DRAW_FOR_RGB)
|
processBlur(LightmapRenderer.DRAW_FOR_RGB)
|
||||||
//camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
//camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||||
|
|
||||||
// render world
|
// render world
|
||||||
@@ -248,6 +248,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun renderDemoWorld() {
|
private fun renderDemoWorld() {
|
||||||
|
|
||||||
// draw skybox //
|
// draw skybox //
|
||||||
|
|
||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
@@ -354,7 +355,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
LightmapRendererNew.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
LightmapRenderer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||||
|
|
||||||
if (loadDone) {
|
if (loadDone) {
|
||||||
// resize UI by re-creating it (!!)
|
// resize UI by re-creating it (!!)
|
||||||
@@ -368,14 +369,14 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
lightmapFboA = FrameBuffer(
|
lightmapFboA = FrameBuffer(
|
||||||
lightFBOformat,
|
lightFBOformat,
|
||||||
LightmapRendererNew.lightBuffer.width * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
LightmapRendererNew.lightBuffer.height * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
lightmapFboB = FrameBuffer(
|
lightmapFboB = FrameBuffer(
|
||||||
lightFBOformat,
|
lightFBOformat,
|
||||||
LightmapRendererNew.lightBuffer.width * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
LightmapRendererNew.lightBuffer.height * LightmapRendererNew.DRAW_TILE_SIZE.toInt(),
|
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
lightmapInitialised = true // are you the first time?
|
lightmapInitialised = true // are you the first time?
|
||||||
@@ -414,13 +415,13 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mode == LightmapRendererNew.DRAW_FOR_RGB) {
|
if (mode == LightmapRenderer.DRAW_FOR_RGB) {
|
||||||
// initialise readBuffer with untreated lightmap
|
// initialise readBuffer with untreated lightmap
|
||||||
blurReadBuffer.inAction(camera, batch) {
|
blurReadBuffer.inAction(camera, batch) {
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
LightmapRendererNew.draw(batch, LightmapRendererNew.DRAW_FOR_RGB)
|
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_RGB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,7 +431,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
batch.inUse {
|
batch.inUse {
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
LightmapRendererNew.draw(batch, LightmapRendererNew.DRAW_FOR_ALPHA)
|
LightmapRenderer.draw(batch, LightmapRenderer.DRAW_FOR_ALPHA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,10 +55,6 @@ object BlocksDrawer {
|
|||||||
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
||||||
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
||||||
|
|
||||||
// TODO modular
|
|
||||||
//val tilesTerrain = SpriteSheet(ModMgr.getPath("basegame", "blocks/terrain.tga.gz"), TILE_SIZE, TILE_SIZE) // 64 MB
|
|
||||||
//val tilesWire = SpriteSheet(ModMgr.getPath("basegame", "blocks/wire.tga.gz"), TILE_SIZE, TILE_SIZE) // 4 MB
|
|
||||||
|
|
||||||
val tilesTerrain: TextureRegionPack
|
val tilesTerrain: TextureRegionPack
|
||||||
val tilesWire: TextureRegionPack
|
val tilesWire: TextureRegionPack
|
||||||
val tileItemWall: TextureRegionPack
|
val tileItemWall: TextureRegionPack
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.*
|
|||||||
|
|
||||||
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
||||||
|
|
||||||
object LightmapRenderer {
|
object LightmapRendererOld {
|
||||||
lateinit var world: GameWorld
|
lateinit var world: GameWorld
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.*
|
|||||||
|
|
||||||
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
||||||
|
|
||||||
object LightmapRendererNew {
|
object LightmapRenderer {
|
||||||
lateinit var world: GameWorld
|
lateinit var world: GameWorld
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user