mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 00:26:07 +09:00
more random dither tex
This commit is contained in:
BIN
assets/LDR_512_RGBA_0.tga
LFS
BIN
assets/LDR_512_RGBA_0.tga
LFS
Binary file not shown.
BIN
assets/dither_512_0.tga
LFS
Normal file
BIN
assets/dither_512_0.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_1.tga
LFS
Normal file
BIN
assets/dither_512_1.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_2.tga
LFS
Normal file
BIN
assets/dither_512_2.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_3.tga
LFS
Normal file
BIN
assets/dither_512_3.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_4.tga
LFS
Normal file
BIN
assets/dither_512_4.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_5.tga
LFS
Normal file
BIN
assets/dither_512_5.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_6.tga
LFS
Normal file
BIN
assets/dither_512_6.tga
LFS
Normal file
Binary file not shown.
BIN
assets/dither_512_7.tga
LFS
Normal file
BIN
assets/dither_512_7.tga
LFS
Normal file
Binary file not shown.
@@ -209,7 +209,7 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Texture ditherPattern;
|
public static Texture[] ditherPatterns = new Texture[8];
|
||||||
private static ShaderProgram shaderBayerSkyboxFill; // ONLY to be used by the splash screen
|
private static ShaderProgram shaderBayerSkyboxFill; // ONLY to be used by the splash screen
|
||||||
public static ShaderProgram shaderHicolour;
|
public static ShaderProgram shaderHicolour;
|
||||||
public static ShaderProgram shaderDebugDiff;
|
public static ShaderProgram shaderDebugDiff;
|
||||||
@@ -401,7 +401,13 @@ public class App implements ApplicationListener {
|
|||||||
CommonResourcePool.INSTANCE.addToLoadingList("title_health2", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_distance.tga")));
|
CommonResourcePool.INSTANCE.addToLoadingList("title_health2", () -> new Texture(Gdx.files.internal("./assets/graphics/gui/health_distance.tga")));
|
||||||
|
|
||||||
// set GL graphics constants
|
// set GL graphics constants
|
||||||
ditherPattern = new Texture(Gdx.files.internal("assets/LDR_512_RGBA_0.tga"));
|
for (int i = 0; i < ditherPatterns.length; i++) {
|
||||||
|
Texture t = new Texture(Gdx.files.internal("assets/dither_512_"+i+".tga"));
|
||||||
|
t.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear);
|
||||||
|
t.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
|
||||||
|
ditherPatterns[i] = t;
|
||||||
|
}
|
||||||
|
|
||||||
shaderBayerSkyboxFill = loadShaderFromFile("assets/4096.vert", "assets/4096_bayer_skyboxfill.frag");
|
shaderBayerSkyboxFill = loadShaderFromFile("assets/4096.vert", "assets/4096_bayer_skyboxfill.frag");
|
||||||
shaderHicolour = loadShaderFromFile("assets/4096.vert", "assets/hicolour.frag");
|
shaderHicolour = loadShaderFromFile("assets/4096.vert", "assets/hicolour.frag");
|
||||||
shaderDebugDiff = loadShaderFromFile("assets/4096.vert", "assets/diff.frag");
|
shaderDebugDiff = loadShaderFromFile("assets/4096.vert", "assets/diff.frag");
|
||||||
@@ -579,8 +585,21 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Texture getCurrentDitherTex() {
|
||||||
|
int hash = 31 + GLOBAL_RENDER_TIMER + 0x165667B1 + GLOBAL_RENDER_TIMER * 0xC2B2AE3D;
|
||||||
|
hash = Integer.rotateLeft(hash, 17) * 0x27D4EB2F;
|
||||||
|
hash ^= hash >>> 15;
|
||||||
|
hash *= 0x85EBCA77;
|
||||||
|
hash ^= hash >>> 13;
|
||||||
|
hash *= 0xC2B2AE3D;
|
||||||
|
hash ^= hash >>> 16;
|
||||||
|
hash = hash & 0x7FFFFFFF;
|
||||||
|
|
||||||
|
return ditherPatterns[hash % ditherPatterns.length];
|
||||||
|
}
|
||||||
|
|
||||||
private void drawSplash() {
|
private void drawSplash() {
|
||||||
ditherPattern.bind(0);
|
getCurrentDitherTex().bind(0);
|
||||||
shaderBayerSkyboxFill.bind();
|
shaderBayerSkyboxFill.bind();
|
||||||
shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined);
|
shaderBayerSkyboxFill.setUniformMatrix("u_projTrans", camera.combined);
|
||||||
shaderBayerSkyboxFill.setUniformi("u_texture", 0);
|
shaderBayerSkyboxFill.setUniformi("u_texture", 0);
|
||||||
@@ -707,7 +726,9 @@ public class App implements ApplicationListener {
|
|||||||
|
|
||||||
ThreadExecutor.INSTANCE.killAll();
|
ThreadExecutor.INSTANCE.killAll();
|
||||||
|
|
||||||
ditherPattern.dispose();
|
for (Texture texture : ditherPatterns) {
|
||||||
|
texture.dispose();
|
||||||
|
}
|
||||||
shaderBayerSkyboxFill.dispose();
|
shaderBayerSkyboxFill.dispose();
|
||||||
shaderHicolour.dispose();
|
shaderHicolour.dispose();
|
||||||
shaderDebugDiff.dispose();
|
shaderDebugDiff.dispose();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class UIFakeGradOverlay : UICanvas() {
|
|||||||
val dither = App.getConfigBoolean("fx_dither")
|
val dither = App.getConfigBoolean("fx_dither")
|
||||||
|
|
||||||
if (dither) {
|
if (dither) {
|
||||||
IngameRenderer.ditherPattern.bind(1)
|
App.getCurrentDitherTex().bind(1)
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,13 +58,6 @@ object IngameRenderer : Disposable {
|
|||||||
private lateinit var lightTex: TextureRegion
|
private lateinit var lightTex: TextureRegion
|
||||||
private lateinit var blurTex: TextureRegion
|
private lateinit var blurTex: TextureRegion
|
||||||
|
|
||||||
val ditherPattern = App.ditherPattern
|
|
||||||
|
|
||||||
init {
|
|
||||||
ditherPattern.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear)
|
|
||||||
ditherPattern.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat)
|
|
||||||
}
|
|
||||||
|
|
||||||
// you must have lightMixed FBO; otherwise you'll be reading from unbaked FBO and it freaks out GPU
|
// you must have lightMixed FBO; otherwise you'll be reading from unbaked FBO and it freaks out GPU
|
||||||
|
|
||||||
inline fun isDither() = App.getConfigBoolean("fx_dither")
|
inline fun isDither() = App.getConfigBoolean("fx_dither")
|
||||||
@@ -479,7 +472,7 @@ object IngameRenderer : Disposable {
|
|||||||
|
|
||||||
gdxSetBlend()
|
gdxSetBlend()
|
||||||
|
|
||||||
ditherPattern.bind(1)
|
App.getCurrentDitherTex().bind(1)
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
@@ -568,7 +561,7 @@ object IngameRenderer : Disposable {
|
|||||||
setCameraPosition(0f, 0f)
|
setCameraPosition(0f, 0f)
|
||||||
val (xrem, yrem) = worldCamToRenderPos()
|
val (xrem, yrem) = worldCamToRenderPos()
|
||||||
|
|
||||||
ditherPattern.bind(1)
|
App.getCurrentDitherTex().bind(1)
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
@@ -688,7 +681,7 @@ object IngameRenderer : Disposable {
|
|||||||
blurTex.texture = blurReadBuffer.colorBufferTexture
|
blurTex.texture = blurReadBuffer.colorBufferTexture
|
||||||
blurTex.texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
blurTex.texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||||
blurTex.texture.bind(0)
|
blurTex.texture.bind(0)
|
||||||
ditherPattern.bind(1) // order is important!
|
App.getCurrentDitherTex().bind(1) // order is important!
|
||||||
|
|
||||||
shaderBlur.bind()
|
shaderBlur.bind()
|
||||||
shaderBlur.setUniformMatrix("u_projTrans", camera.combined)
|
shaderBlur.setUniformMatrix("u_projTrans", camera.combined)
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ object Toolkit : Disposable {
|
|||||||
|
|
||||||
batch.end()
|
batch.end()
|
||||||
|
|
||||||
IngameRenderer.ditherPattern.bind(1)
|
App.getCurrentDitherTex().bind(1)
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
|
|
||||||
batch.begin()
|
batch.begin()
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
val dither = App.getConfigBoolean("fx_dither")
|
val dither = App.getConfigBoolean("fx_dither")
|
||||||
|
|
||||||
if (dither) {
|
if (dither) {
|
||||||
IngameRenderer.ditherPattern.bind(1)
|
App.getCurrentDitherTex().bind(1)
|
||||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user