halved the number of dither pattern textures and added even more variations using the swizzling

This commit is contained in:
minjaesong
2022-08-30 01:53:16 +09:00
parent bf962376d4
commit 2e0f55567f
14 changed files with 62 additions and 25 deletions

View File

@@ -228,7 +228,7 @@ public class App implements ApplicationListener {
public static Texture[] ditherPatterns = new Texture[8];
public static Texture[] ditherPatterns = new Texture[4];
private static ShaderProgram shaderBayerSkyboxFill; // ONLY to be used by the splash screen
public static ShaderProgram shaderHicolour;
public static ShaderProgram shaderDebugDiff;

View File

@@ -160,6 +160,36 @@ object TerrarumPostProcessor : Disposable {
}
private val rng = HQRNG()
private val swizzler = intArrayOf(
1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1,
1,0,0,0, 0,1,0,0, 0,0,0,1, 0,0,1,0,
1,0,0,0, 0,0,1,0, 0,1,0,0, 0,0,0,1,
1,0,0,0, 0,0,1,0, 0,0,0,1, 0,1,0,0,
1,0,0,0, 0,0,0,1, 0,1,0,0, 0,0,1,0,
1,0,0,0, 0,0,0,1, 0,0,1,0, 0,1,0,0,
0,1,0,0, 1,0,0,0, 0,0,1,0, 0,0,0,1,
0,1,0,0, 1,0,0,0, 0,0,0,1, 0,0,1,0,
0,1,0,0, 0,0,1,0, 1,0,0,0, 0,0,0,1,
0,1,0,0, 0,0,1,0, 0,0,0,1, 1,0,0,0,
0,1,0,0, 0,0,0,1, 1,0,0,0, 0,0,1,0,
0,1,0,0, 0,0,0,1, 0,0,1,0, 1,0,0,0,
0,0,1,0, 1,0,0,0, 0,1,0,0, 0,0,0,1,
0,0,1,0, 1,0,0,0, 0,0,0,1, 0,1,0,0,
0,0,1,0, 0,1,0,0, 1,0,0,0, 0,0,0,1,
0,0,1,0, 0,1,0,0, 0,0,0,1, 1,0,0,0,
0,0,1,0, 0,0,0,1, 1,0,0,0, 0,1,0,0,
0,0,1,0, 0,0,0,1, 0,1,0,0, 1,0,0,0,
0,0,0,1, 1,0,0,0, 0,1,0,0, 0,0,1,0,
0,0,0,1, 1,0,0,0, 0,0,1,0, 0,1,0,0,
0,0,0,1, 0,1,0,0, 1,0,0,0, 0,0,1,0,
0,0,0,1, 0,1,0,0, 0,0,1,0, 1,0,0,0,
0,0,0,1, 0,0,1,0, 1,0,0,0, 0,1,0,0,
0,0,0,1, 0,0,1,0, 0,1,0,0, 1,0,0,0,
).map { it.toFloat() }.toFloatArray()
private fun postShader(projMat: Matrix4, fbo: FrameBuffer) {
val shader = if (App.getConfigBoolean("fx_dither"))
@@ -176,10 +206,9 @@ object TerrarumPostProcessor : Disposable {
shader.setUniformi("rnd", rng.nextInt(8192), rng.nextInt(8192))
shader.setUniformi("u_pattern", 1)
shader.setUniformf("quant", shaderQuant[App.getConfigInt("displaycolourdepth")] ?: 255f)
shader.setUniformMatrix4fv("swizzler", swizzler, rng.nextInt(24), 16*4)
App.fullscreenQuad.render(shader, GL20.GL_TRIANGLES)
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
}

View File

@@ -1,7 +1,9 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.spriteanimation.SheetSpriteAnimation
import net.torvald.terrarum.gameactors.AVKey
import net.torvald.terrarum.langpack.Lang
import kotlin.math.roundToInt
/**
* Created by minjaesong on 2022-08-26.
@@ -12,6 +14,7 @@ class FixtureTypewriter : FixtureBase {
private set
private var carriagePosition = 0
private val textBuffer = Array(TYPEWRITER_ROWS) { "" }
// constructor used when new typewriter is created
constructor(keymapName: String) : this() {
@@ -35,8 +38,15 @@ class FixtureTypewriter : FixtureBase {
actorValue[AVKey.BASEMASS] = 3.6
}
override fun update(delta: Float) {
super.update(delta)
(sprite as SheetSpriteAnimation).currentRow = 1 + (carriagePosition.toFloat() / TYPEWRITER_COLUMNS * 10).roundToInt()
}
companion object {
const val TYPEWRITER_COLUMNS = 64
const val TYPEWRITER_ROWS = 30
}
}