mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
dithering on grad overlay
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user