mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
halved the number of dither pattern textures and added even more variations using the swizzling
This commit is contained in:
Binary file not shown.
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
BIN
src/shaders/dither_512_0.tga
LFS
BIN
src/shaders/dither_512_0.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_1.tga
LFS
BIN
src/shaders/dither_512_1.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_2.tga
LFS
BIN
src/shaders/dither_512_2.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_3.tga
LFS
BIN
src/shaders/dither_512_3.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_4.tga
LFS
BIN
src/shaders/dither_512_4.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_5.tga
LFS
BIN
src/shaders/dither_512_5.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_6.tga
LFS
BIN
src/shaders/dither_512_6.tga
LFS
Binary file not shown.
BIN
src/shaders/dither_512_7.tga
LFS
BIN
src/shaders/dither_512_7.tga
LFS
Binary file not shown.
@@ -22,7 +22,12 @@ varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_pattern;
|
||||
uniform ivec2 rnd = ivec2(0,0);
|
||||
|
||||
uniform mat4 swizzler = mat4(
|
||||
1.0,0.0,0.0,0.0,
|
||||
0.0,1.0,0.0,0.0,
|
||||
0.0,0.0,1.0,0.0,
|
||||
0.0,0.0,0.0,1.0
|
||||
);
|
||||
uniform float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
@@ -50,7 +55,7 @@ vec4 nearestColour(vec4 inColor) {
|
||||
}
|
||||
|
||||
vec4 getDitherredDot(vec4 inColor) {
|
||||
vec4 bayerThreshold = vec4(matrixNormaliser + texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize));
|
||||
vec4 bayerThreshold = swizzler * vec4(matrixNormaliser + texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize));
|
||||
return nearestColour(bayerThreshold * vec4(1.0 / quant) + inColor);
|
||||
}
|
||||
|
||||
@@ -71,5 +76,10 @@ void main(void) {
|
||||
// Dither the output
|
||||
vec4 graded = ycocg_to_rgb * newColour;
|
||||
vec4 selvec = getDitherredDot(graded);
|
||||
gl_FragColor = selvec * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A
|
||||
vec4 outcol = selvec * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A
|
||||
|
||||
gl_FragColor = outcol;
|
||||
// ivec4 bytes = ivec4(255.0 * outcol);
|
||||
// ivec4 mask = ivec4(0x55);
|
||||
// gl_FragColor = (bytes ^ mask) / 255.0;
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user