mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
dithering on grad overlay
This commit is contained in:
@@ -218,6 +218,7 @@ public class App implements ApplicationListener {
|
||||
public static Texture ditherPattern;
|
||||
private static ShaderProgram shaderBayerSkyboxFill; // ONLY to be used by the splash screen
|
||||
public static ShaderProgram shaderHicolour;
|
||||
public static ShaderProgram shaderDebugDiff;
|
||||
public static ShaderProgram shaderPassthruRGB;
|
||||
public static ShaderProgram shaderColLUT;
|
||||
public static ShaderProgram shaderReflect;
|
||||
@@ -409,6 +410,7 @@ public class App implements ApplicationListener {
|
||||
ditherPattern = new Texture(Gdx.files.internal("assets/LDR_512_RGBA_0.tga"));
|
||||
shaderBayerSkyboxFill = loadShaderFromFile("assets/4096.vert", "assets/4096_bayer_skyboxfill.frag");
|
||||
shaderHicolour = loadShaderFromFile("assets/4096.vert", "assets/hicolour.frag");
|
||||
shaderDebugDiff = loadShaderFromFile("assets/4096.vert", "assets/diff.frag");
|
||||
shaderPassthruRGB = SpriteBatch.createDefaultShader();
|
||||
shaderColLUT = loadShaderFromFile("assets/4096.vert", "assets/passthrurgb.frag");
|
||||
shaderReflect = loadShaderFromFile("assets/4096.vert", "assets/reflect.frag");
|
||||
@@ -713,6 +715,7 @@ public class App implements ApplicationListener {
|
||||
ditherPattern.dispose();
|
||||
shaderBayerSkyboxFill.dispose();
|
||||
shaderHicolour.dispose();
|
||||
shaderDebugDiff.dispose();
|
||||
shaderPassthruRGB.dispose();
|
||||
shaderColLUT.dispose();
|
||||
shaderReflect.dispose();
|
||||
|
||||
@@ -131,6 +131,8 @@ object PostProcessor : Disposable {
|
||||
val shader: ShaderProgram? =
|
||||
if (App.getConfigBoolean("fx_retro"))
|
||||
App.shaderHicolour
|
||||
else if (App.getConfigBoolean("fx_differential"))
|
||||
App.shaderDebugDiff
|
||||
else
|
||||
App.shaderPassthruRGB
|
||||
|
||||
|
||||
@@ -183,7 +183,11 @@ class TitleScreen(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
// load a half-gradient texture that would be used throughout the titlescreen and its sub UIs
|
||||
CommonResourcePool.addToLoadingList("title_halfgrad") { Texture(Gdx.files.internal("./assets/graphics/halfgrad.png")) }
|
||||
CommonResourcePool.addToLoadingList("title_halfgrad") {
|
||||
val t = Texture(Gdx.files.internal("./assets/graphics/halfgrad.tga"))
|
||||
t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
t
|
||||
}
|
||||
CommonResourcePool.loadAll()
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.GL20
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
|
||||
@@ -24,12 +28,31 @@ class UIFakeGradOverlay : UICanvas() {
|
||||
|
||||
private val tex = CommonResourcePool.getAsTexture("title_halfgrad")
|
||||
|
||||
private val renderng = HQRNG()
|
||||
|
||||
init {
|
||||
setAsAlwaysVisible()
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {}
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
batch.end()
|
||||
val dither = App.getConfigBoolean("fx_dither")
|
||||
|
||||
if (dither) {
|
||||
IngameRenderer.ditherPattern.bind(1)
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||
}
|
||||
|
||||
|
||||
batch.begin()
|
||||
|
||||
batch.shader = if (dither) IngameRenderer.shaderBayer else null
|
||||
if (dither) {
|
||||
batch.shader.setUniformi("u_pattern", 1)
|
||||
batch.shader.setUniformi("rnd", renderng.nextInt(8192), renderng.nextInt(8192))
|
||||
}
|
||||
|
||||
blendMul(batch)
|
||||
batch.draw(tex, 0f, 0f, App.scr.wf, App.scr.hf)
|
||||
|
||||
|
||||
@@ -25,12 +25,26 @@ private fun addFile(disk: VirtualDisk, file: DiskEntry) {
|
||||
if (!dir.contains(file.entryID)) dir.add(file.entryID)
|
||||
}
|
||||
|
||||
abstract class SavingThread(private val ingame: TerrarumIngame) : Runnable {
|
||||
abstract fun save()
|
||||
|
||||
override fun run() {
|
||||
try {
|
||||
save()
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
ingame.uiAutosaveNotifier.setAsError()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-09-14.
|
||||
*/
|
||||
class WorldSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: TerrarumIngame, val hasThumbnail: Boolean, val isAuto: Boolean, val callback: () -> Unit) : Runnable {
|
||||
class WorldSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: TerrarumIngame, val hasThumbnail: Boolean, val isAuto: Boolean, val callback: () -> Unit) : SavingThread(ingame) {
|
||||
|
||||
override fun run() {
|
||||
override fun save() {
|
||||
|
||||
disk.saveMode = 2 * isAuto.toInt() // no quick
|
||||
|
||||
@@ -40,8 +54,10 @@ class WorldSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: Te
|
||||
}
|
||||
}
|
||||
|
||||
val playersList: List<IngamePlayer> = listOf(ingame.actorContainerActive, ingame.actorContainerInactive).flatMap{ it.filter { it is IngamePlayer } } as List<IngamePlayer>
|
||||
val actorsList = listOf(ingame.actorContainerActive, ingame.actorContainerInactive).flatMap { it.filter { WriteWorld.actorAcceptable(it) } }
|
||||
val allTheActors = ingame.actorContainerActive.cloneToList() + ingame.actorContainerInactive.cloneToList()
|
||||
|
||||
val playersList: List<IngamePlayer> = allTheActors.filter{ it is IngamePlayer } as List<IngamePlayer>
|
||||
val actorsList = allTheActors.filter { WriteWorld.actorAcceptable(it) }
|
||||
val layers = intArrayOf(0,1).map { ingame.world.getLayer(it) }
|
||||
val cw = ingame.world.width / LandUtil.CHUNK_W
|
||||
val ch = ingame.world.height / LandUtil.CHUNK_H
|
||||
@@ -182,9 +198,9 @@ class WorldSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: Te
|
||||
*
|
||||
* Created by minjaesong on 2021-10-08
|
||||
*/
|
||||
class PlayerSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: TerrarumIngame, val hasThumbnail: Boolean, val isAuto: Boolean, val callback: () -> Unit) : Runnable {
|
||||
class PlayerSavingThread(val disk: VirtualDisk, val outFile: File, val ingame: TerrarumIngame, val hasThumbnail: Boolean, val isAuto: Boolean, val callback: () -> Unit) : SavingThread(ingame) {
|
||||
|
||||
override fun run() {
|
||||
override fun save() {
|
||||
disk.saveMode = 2 * isAuto.toInt() // no quick
|
||||
disk.capacity = 0L
|
||||
|
||||
|
||||
@@ -178,15 +178,16 @@ internal object WeatherMixer : RNGConsumer {
|
||||
skyboxTexture.dispose()
|
||||
skyboxTexture = Texture(skyboxPixmap); skyboxTexture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
|
||||
val dither = App.getConfigBoolean("fx_dither")
|
||||
|
||||
if (App.getConfigBoolean("fx_dither")) {
|
||||
if (dither) {
|
||||
IngameRenderer.ditherPattern.bind(1)
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||
}
|
||||
|
||||
batch.inUse {
|
||||
it.shader = if (App.getConfigBoolean("fx_dither")) IngameRenderer.shaderBayer else null
|
||||
if (App.getConfigBoolean("fx_dither")) {
|
||||
it.shader = if (dither) IngameRenderer.shaderBayer else null
|
||||
if (dither) {
|
||||
it.shader.setUniformi("u_pattern", 1)
|
||||
it.shader.setUniformi("rnd", renderng.nextInt(8192), renderng.nextInt(8192))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user