See Github issue #15

This commit is contained in:
minjaesong
2019-01-15 05:50:36 +09:00
parent 81f9c92e48
commit 078cdfefa4
23 changed files with 58 additions and 56 deletions

View File

@@ -157,7 +157,7 @@ public class AppLoader implements ApplicationListener {
ShaderProgram.pedantic = false;
LwjglApplicationConfiguration appConfig = new LwjglApplicationConfiguration();
appConfig.useGL30 = true;
//appConfig.useGL30 = true; // used: loads GL 3.2, unused: loads GL 4.6; what the fuck?
appConfig.vSyncEnabled = false;
appConfig.resizable = false;//true;
//appConfig.width = 1072; // IMAX ratio

View File

@@ -577,26 +577,25 @@ fun SpriteBatch.drawStraightLine(x: Float, y: Float, otherEnd: Float, thickness:
infix fun Color.mul(other: Color): Color = this.cpy().mul(other)
/*inline fun Color.toRGB10(): RGB10 {
val bits = this.toIntBits() // ABGR
// 0bxxRRRRRRRRRRGGGGGGGGGGBBBBBBBBBB
// 0bAAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR
return bits.and(0x0000FF).shl(20) or bits.and(0x00FF00).shl(2) or bits.and(0xFF0000).ushr(16)
}*/
fun blendMul(batch: SpriteBatch? = null) {
// will break if the colour image contains semitransparency
(batch ?: Terrarum.batch).enableBlending()
(batch ?: Terrarum.batch).setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD) // batch.flush does not touch blend equation
}
fun blendScreen(batch: SpriteBatch? = null) {
// will break if the colour image contains semitransparency
(batch ?: Terrarum.batch).enableBlending()
(batch ?: Terrarum.batch).setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR)
}
fun blendDisable(batch: SpriteBatch? = null) {
(batch ?: Terrarum.batch).disableBlending()
}
fun blendNormal(batch: SpriteBatch? = null) {
(batch ?: Terrarum.batch).enableBlending()
(batch ?: Terrarum.batch).setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
(batch ?: Terrarum.batch).setBlendFunctionSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_SRC_ALPHA, GL20.GL_ONE)
// ALPHA *MUST BE* PREMULTIPLIED //
@@ -613,17 +612,6 @@ fun blendNormal(batch: SpriteBatch? = null) {
// - https://www.andersriggelsen.dk/glblendfunc.php
}
fun blendScreen(batch: SpriteBatch? = null) {
// will break if the colour image contains semitransparency
(batch ?: Terrarum.batch).enableBlending()
(batch ?: Terrarum.batch).setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR)
Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD) // batch.flush does not touch blend equation
}
fun blendDisable(batch: SpriteBatch? = null) {
(batch ?: Terrarum.batch).disableBlending()
}
fun gdxClearAndSetBlend(r: Float, g: Float, b: Float, a: Float) {
Gdx.gl.glClearColor(r,g,b,a)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
@@ -637,8 +625,8 @@ fun gdxSetBlend() {
fun gdxSetBlendNormal() {
gdxSetBlend()
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD)
Gdx.gl.glBlendFuncSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_SRC_ALPHA, GL20.GL_ONE)
//Gdx.gl.glBlendEquationSeparate(GL20.GL_FUNC_ADD, GL30.GL_MAX) // batch.flush does not touch blend equation
// ALPHA *MUST BE* PREMULTIPLIED //

View File

@@ -94,7 +94,7 @@ object IngameRenderer {
// clear main or whatever super-FBO being used
//clearBuffer()
gdxClearAndSetBlend(.64f, .754f, .84f, 1f)
gdxClearAndSetBlend(.64f, .754f, .84f, 0f)
///////////////////////////////////////////////////////////////////////
@@ -544,21 +544,21 @@ object IngameRenderer {
lightmapFboB.dispose()
}
fboRGB = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false)
fboRGB_lightMixed = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false)
fboA = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false)
fboA_lightMixed = FrameBuffer(Pixmap.Format.RGBA8888, width, height, false)
fboRGB = FrameBuffer(Pixmap.Format.RGBA8888, width, height, true)
fboRGB_lightMixed = FrameBuffer(Pixmap.Format.RGBA8888, width, height, true)
fboA = FrameBuffer(Pixmap.Format.RGBA8888, width, height, true)
fboA_lightMixed = FrameBuffer(Pixmap.Format.RGBA8888, width, height, true)
lightmapFboA = FrameBuffer(
Pixmap.Format.RGBA8888,
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
false
true
)
lightmapFboB = FrameBuffer(
Pixmap.Format.RGBA8888,
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
false
true
)
BlocksDrawer.resize(width, height)

View File

@@ -190,14 +190,15 @@ object LightmapRenderer {
* Updating order:
* ,--------. ,--+-----. ,-----+--. ,--------. -
* |↘ | | | 3| |3 | | | ↙| ↕︎ overscan_open / overscan_opaque
* | +-----+ | | 2 | | 2 | | +-----+ | - depending on the noop_mask
* | |1 | | |1 | | 1| | | 1| |
* | | 2 | | +-----+ +-----+ | | 2 | |
* | ,-----+ | | 2 | | 2 | | +-----. | - depending on the noop_mask
* | |1 | | |1 | | 1| | | 1| |
* | | 2 | | `-----+ +-----' | | 2 | |
* | | 3| |↗ | | ↖| |3 | |
* `--+-----' `--------' `--------' `-----+--'
* round: 1 2 3 4
* for all lightmap[y][x], run in this order: 2-3-4-1
* for some reason, this setup removes (or mitigates) directional artefacts.
* for all lightmap[y][x], run in this order: 2-3-4-1-2
* If you run only 4 sets, orthogonal/diagonal artefacts are bound to occur,
* it seems 5-pass is mandatory
*/
AppLoader.debugTimers["Renderer.Lanterns"] = measureNanoTime {
@@ -247,11 +248,21 @@ object LightmapRenderer {
}
}
// Round 2
AppLoader.debugTimers["Renderer.Light5"] = measureNanoTime {
for (y in for_y_end + overscan_open downTo for_y_start) {
for (x in for_x_start - overscan_open..for_x_end) {
setLight(x, y, calculate(x, y, 5))
}
}
}
AppLoader.debugTimers["Renderer.LightSequential"] =
(AppLoader.debugTimers["Renderer.Light1"]!! as Long) +
(AppLoader.debugTimers["Renderer.Light2"]!! as Long) +
(AppLoader.debugTimers["Renderer.Light3"]!! as Long) +
(AppLoader.debugTimers["Renderer.Light4"]!! as Long)
(AppLoader.debugTimers["Renderer.Light4"]!! as Long) +
(AppLoader.debugTimers["Renderer.Light5"]!! as Long)
}
else {
AppLoader.debugTimers["Renderer.LightPre"] = measureNanoTime {