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

@@ -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
}