vibrancy is applied to the world only, as it should be

This commit is contained in:
minjaesong
2023-09-13 15:09:31 +09:00
parent f34a9db24c
commit 79892f2525
8 changed files with 102 additions and 79 deletions

View File

@@ -191,4 +191,25 @@ public class HQRNG extends Random {
state0 = 1L;
}
/**
* Returns a random value whose probability is distributed in triangular manner, of which 0.5 is the most and 0.0 and 1.0 are the least likely.
*/
public double nextTriangular() {
return (nextDouble() + nextDouble()) / 2.0;
}
/**
* Returns a random value whose probability is distributed in triangular manner, of which 0.0 is the most and 1.0 is the least likely.
*/
public double nextBrown() {
return Math.abs(nextDouble() + nextDouble() - 1);
}
/**
* Returns a random value whose probability is distributed in triangular manner, of which 1.0 is the most and 0.0 is the least likely.
*/
public double nextBlue() {
return 1.0 - nextBrown();
}
}

View File

@@ -237,13 +237,6 @@ object TerrarumPostProcessor : Disposable {
else
shaderPostNoDither
val (vo, vg) = INGAME.world.weatherbox.let {
if (it.currentWeather.identifier == "titlescreen")
1f to 1f
else
it.currentVibrancy.x to it.currentVibrancy.y
}
App.getCurrentDitherTex().bind(1)
fbo.colorBufferTexture.bind(0)
@@ -253,7 +246,6 @@ object TerrarumPostProcessor : Disposable {
shader.setUniformi("rnd", rng.nextInt(8192), rng.nextInt(8192))
shader.setUniformi("u_pattern", 1)
shader.setUniformf("quant", shaderQuant[App.getConfigInt("displaycolourdepth")] ?: 255f)
shader.setUniformf("vibrancy", 1f, vo, vg, 1f)
shader.setUniformMatrix4fv("swizzler", swizzler, rng.nextInt(24), 16*4)
App.fullscreenQuad.render(shader, GL20.GL_TRIANGLE_FAN)

View File

@@ -7,6 +7,7 @@ import net.torvald.terrarum.*
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.Fluid
import net.torvald.terrarum.concurrent.ThreadExecutor
import net.torvald.terrarum.gameactors.ActorID
import net.torvald.terrarum.gameitems.ItemID
import net.torvald.terrarum.itemproperties.ItemRemapTable

View File

@@ -88,6 +88,8 @@ object IngameRenderer : Disposable {
val shaderForActors: ShaderProgram
val shaderDemultiply: ShaderProgram
val shaderVibrancy: ShaderProgram
private val WIDTH = App.scr.width
private val HEIGHT = App.scr.height
private val WIDTHF = WIDTH.toFloat()
@@ -131,6 +133,8 @@ object IngameRenderer : Disposable {
shaderKawaseDown = App.loadShaderFromClasspath("shaders/default.vert", "shaders/kawasedown.frag")
shaderKawaseUp = App.loadShaderFromClasspath("shaders/default.vert", "shaders/kawaseup.frag")
shaderVibrancy = App.loadShaderFromClasspath("shaders/default.vert", "shaders/vibrancy.frag")
if (!shaderBlendGlow.isCompiled) {
Gdx.app.log("shaderBlendGlow", shaderBlendGlow.log)
exitProcess(1)
@@ -352,17 +356,20 @@ object IngameRenderer : Disposable {
blendNormalStraightAlpha(batch)
batch.inUse {
// it's no use applying dithering here: colours are no longer "floats" once they're written to the FBO
// proof: disable dithering on skybox and enable dither here -- banding is still visible
// it would work if GDX supported HDR, or GL_RGBA32F as a texture format, but alas.
// but mixedOutTex is still needed for the screen capturing
//batch.shader = if (App.getConfigBoolean("fx_dither")) IngameRenderer.shaderBayer else null
batch.shader = null
batch.drawFlipped(mixedOutTex, 0f, 0f)
val (vo, vg) = world.weatherbox.let {
if (it.currentWeather.identifier == "titlescreen")
1f to 1f
else
it.currentVibrancy.x to it.currentVibrancy.y
}
mixedOutTex.texture.bind(0)
shaderVibrancy.bind()
shaderVibrancy.setUniformMatrix("u_projTrans", camera.combined)
shaderVibrancy.setUniformi("u_texture", 0)
shaderVibrancy.setUniformf("vibrancy", 1f, vo, vg, 1f)
fullscreenQuad.render(shaderVibrancy, GL20.GL_TRIANGLE_FAN)
///////////////////////////////////////////////////////////////////////
@@ -899,6 +906,8 @@ object IngameRenderer : Disposable {
shaderForActors.dispose()
shaderDemultiply.dispose()
shaderVibrancy.dispose()
if (::fboRGBexport.isInitialized) fboRGBexport.tryDispose()
}

View File

@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumAppConfiguration
import net.torvald.terrarum.ccE
@@ -249,7 +250,7 @@ class ConsoleWindow : UICanvas() {
override fun doOpening(delta: Float) {
Terrarum.ingame?.let {
println("Game was paused beforehand: ${it.paused}")
// printdbg(this, "Game was paused beforehand: ${it.paused}")
if (!it.paused) {
iMadeTheGameToPause = true
it.pause()
@@ -257,7 +258,7 @@ class ConsoleWindow : UICanvas() {
else {
iMadeTheGameToPause = false
}
println("I made the game to pause: $iMadeTheGameToPause")
// printdbg(this, "I made the game to pause: $iMadeTheGameToPause")
}
/*openingTimeCounter += delta
drawOffY = MovementInterpolator.fastPullOut(openingTimeCounter.toFloat() / openCloseTime.toFloat(),
@@ -282,10 +283,10 @@ class ConsoleWindow : UICanvas() {
}
override fun endClosing(delta: Float) {
println("Close -- I made the game to pause: $iMadeTheGameToPause")
// printdbg(this, "Close -- I made the game to pause: $iMadeTheGameToPause")
if (iMadeTheGameToPause) {
Terrarum.ingame?.resume()
println("Close -- resume game")
// printdbg(this, "Close -- resume game")
}
iMadeTheGameToPause = false
Terrarum.ingame?.setTooltipMessage(null)