dithering for semitransparent tiles

This commit is contained in:
minjaesong
2021-10-10 23:47:03 +09:00
parent 0925ec2580
commit 8b3f07eddd
7 changed files with 135 additions and 7 deletions

View File

@@ -34,6 +34,8 @@ import kotlin.system.exitProcess
* NOTE: config "fx_dither" only controls the skybox (which is capable of having more than 256 colours
* thanks to the hardware linear intp.) because this dithering shader is somewhat heavy.
*
* Semitransparency is rendered using dithering, so it is good idea to avoid them.
* If you must add semitransparency to the tile, they must have alpha NOT premultiplied.
* Actors' transparency (and not an UI) still uses its own lightweight ditherrer
*/
object IngameRenderer : Disposable {
@@ -282,8 +284,6 @@ object IngameRenderer : Disposable {
)
}
// blending is correct... somewhat. Alpha must be premultiplied
}
// something about RGB
else if (KeyToggler.isOn(Input.Keys.F6) &&

View File

@@ -11,9 +11,9 @@ import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.gameitem.ItemID
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarum.gameworld.WorldSimulator
import net.torvald.terrarum.gameworld.WorldTime
import net.torvald.terrarum.gameworld.fmod
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import kotlin.math.roundToInt
@@ -85,7 +85,7 @@ internal object BlocksDrawer {
private lateinit var tilesQuad: Mesh
private val shader = App.loadShaderFromFile("assets/4096.vert", "assets/tiling.frag")
private val shader = App.loadShaderFromFile("assets/4096.vert", "assets/tiling_dither.frag")
init {