new dithering shaders

This commit is contained in:
minjaesong
2021-10-06 11:13:44 +09:00
parent 2c6dc8750a
commit fb13922ad9
11 changed files with 235 additions and 123 deletions

View File

@@ -17,8 +17,8 @@ class ChunkLoadingLoadScreen(screenToBeLoaded: IngameInstance, private val world
private val world: GameWorld // must use Getter, as the field WILL BE redefined by the TerrarumIngame.enterCreateNewWorld() !
get() = screenToLoad!!.world
private var previewWidth = (App.scr.width * WorldgenLoadScreen.WIDTH_RATIO).roundToInt()
private var previewHeight = (App.scr.width * WorldgenLoadScreen.WIDTH_RATIO * worldheight / worldwidth).roundToInt()
private var previewWidth = (Toolkit.drawWidth * WorldgenLoadScreen.WIDTH_RATIO).roundToInt()
private var previewHeight = (Toolkit.drawWidth * WorldgenLoadScreen.WIDTH_RATIO * worldheight / worldwidth).roundToInt()
private lateinit var previewPixmap: Pixmap
private lateinit var previewTexture: Texture
@@ -40,6 +40,7 @@ class ChunkLoadingLoadScreen(screenToBeLoaded: IngameInstance, private val world
override fun render(delta: Float) {
gdxClearAndSetBlend(.094f, .094f, .094f, 0f)
val drawWidth = Toolkit.drawWidth
if (worldwidth != -1 && worldheight != -1) {
@@ -54,7 +55,7 @@ class ChunkLoadingLoadScreen(screenToBeLoaded: IngameInstance, private val world
App.batch.inUse {
it.color = Color.WHITE
val previewX = (App.scr.width - previewWidth).div(2f).round()
val previewX = (drawWidth - previewWidth).div(2f).round()
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
Toolkit.drawBoxBorder(it, previewX.toInt() - 1, previewY.toInt() - 1, previewWidth + 2, previewHeight + 2)
it.draw(previewTexture,
@@ -64,7 +65,7 @@ class ChunkLoadingLoadScreen(screenToBeLoaded: IngameInstance, private val world
val text = messages.getHeadElem() ?: ""
App.fontGame.draw(it,
text,
(App.scr.width - App.fontGame.getWidth(text)).div(2f).round(),
(drawWidth - App.fontGame.getWidth(text)).div(2f).round(),
previewY + previewHeight + 98 - App.fontGame.lineHeight
)
}

View File

@@ -57,6 +57,7 @@ object IngameRenderer : Disposable {
val shaderRGBOnly: ShaderProgram
val shaderAtoGrey: ShaderProgram
val shaderPassthru = SpriteBatch.createDefaultShader()
val shaderAlphaDither: ShaderProgram
private val WIDTH = App.scr.width
private val HEIGHT = App.scr.height
@@ -98,11 +99,13 @@ object IngameRenderer : Disposable {
shaderBayer.setUniformf("rcount", 64f)
shaderBayer.setUniformf("gcount", 64f)
shaderBayer.setUniformf("bcount", 64f)
}
else {
shaderBayer = App.loadShaderFromFile("assets/4096.vert", "assets/passthrurgb.frag")
}
shaderAlphaDither = App.loadShaderFromFile("assets/4096.vert", "assets/alphadither.frag")
shaderBlendGlow = App.loadShaderFromFile("assets/blendGlow.vert", "assets/blendGlow.frag")
@@ -406,12 +409,16 @@ object IngameRenderer : Disposable {
batch.inUse {
moveCameraToWorldCoord()
actorsRenderBehind?.forEach { it.drawBody(batch) }
}
batch.shader = shaderAlphaDither
batch.inUse {
particlesContainer?.forEach { it.drawBody(batch) }
}
setCameraPosition(0f, 0f)
BlocksDrawer.drawTerrain(batch.projectionMatrix, false)
batch.shader = null
batch.inUse {
/////////////////
// draw actors //
@@ -739,6 +746,7 @@ object IngameRenderer : Disposable {
shaderRGBOnly.dispose()
shaderAtoGrey.dispose()
shaderPassthru.dispose()
shaderAlphaDither.dispose()
try {
fboRGBexport.dispose()

View File

@@ -34,8 +34,8 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
val COL_AIR = Color.BLACK
}
private val previewWidth = (App.scr.width * WIDTH_RATIO).roundToInt()
private val previewHeight = (App.scr.width * WIDTH_RATIO * worldheight / worldwidth).roundToInt()
private val previewWidth = (Toolkit.drawWidth * WIDTH_RATIO).roundToInt()
private val previewHeight = (Toolkit.drawWidth * WIDTH_RATIO * worldheight / worldwidth).roundToInt()
private lateinit var previewPixmap: Pixmap
private lateinit var previewTexture: Texture
@@ -57,6 +57,8 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
override fun render(delta: Float) {
gdxClearAndSetBlend(.094f, .094f, .094f, 0f)
val drawWidth = Toolkit.drawWidth
previewRenderCounter += delta
if (previewRenderCounter >= PREVIEW_UPDATE_RATE) {
previewRenderCounter -= PREVIEW_UPDATE_RATE
@@ -68,7 +70,7 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
App.batch.inUse {
it.color = Color.WHITE
val previewX = (App.scr.width - previewWidth).div(2f).round()
val previewX = (drawWidth - previewWidth).div(2f).round()
val previewY = (App.scr.height - previewHeight.times(1.5f)).div(2f).round()
Toolkit.drawBoxBorder(it, previewX.toInt()-1, previewY.toInt()-1, previewWidth+2, previewHeight+2)
it.draw(previewTexture,
@@ -78,7 +80,7 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
val text = messages.getHeadElem() ?: ""
App.fontGame.draw(it,
text,
(App.scr.width - App.fontGame.getWidth(text)).div(2f).round(),
(drawWidth - App.fontGame.getWidth(text)).div(2f).round(),
previewY + previewHeight + 98 - App.fontGame.lineHeight
)
}

View File

@@ -0,0 +1,18 @@
package net.torvald.terrarum.modulebasegame.console
import net.torvald.terrarum.App
import net.torvald.terrarum.console.ConsoleCommand
import net.torvald.terrarum.console.Echo
/**
* Created by minjaesong on 2021-10-06.
*/
object StreamerMode : ConsoleCommand {
override fun execute(args: Array<String>) {
App.setConfig("fx_streamerslayout", !App.getConfigBoolean("fx_streamerslayout"))
}
override fun printUsage() {
Echo("Toggles Streamer Mode")
}
}