Color noise client option

Fixes #142
This commit is contained in:
DBotThePony 2022-10-23 22:56:47 +07:00
parent b0f820e6f0
commit 3f3d08ac32
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 18 additions and 7 deletions

View File

@ -11,7 +11,6 @@ object ClientConfig {
init {
specBuilder.comment("Clientside Config").push("client")
}
var EXOSUIT_INVENTORY_ROWS: Int by specBuilder
@ -22,6 +21,11 @@ object ClientConfig {
.comment("If looking below this angle (actually, looking 'above' as you see in game, but not as you expect it, check with debug screen), Crouch + Jump will trigger jump boost android ability")
.defineInRange("jumpBoostTriggerAngle", 30.0, -180.0, 180.0)
var ENABLE_COLOR_NOISE: Boolean by specBuilder
.comment("Enable color noise effect on android glitches")
.comment("Enabling this may have performance implication")
.define("glitchColorNoise", false)
init {
specBuilder.pop()
spec = specBuilder.build()

View File

@ -17,6 +17,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GameRenderer
import net.minecraft.core.Vec3i
import net.minecraft.world.level.levelgen.XoroshiroRandomSource
import ru.dbotthepony.mc.otm.ClientConfig
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
import ru.dbotthepony.mc.otm.capability.matteryPlayer
import ru.dbotthepony.mc.otm.client.minecraft
@ -334,6 +335,10 @@ object GlitchRenderer {
}
private fun makeColorGlitch() {
if (!ClientConfig.ENABLE_COLOR_NOISE) {
return
}
lastEncodingGlitch = System.nanoTime()
nextEncodingGlitch = random.nextIntBetweenInclusive(10_000_000, 40_000_000).toLong()
colorGlitchWidth = ceil(glitchBuffer.width / GLITCH_BLOCK_SIZE).toInt()
@ -456,7 +461,7 @@ object GlitchRenderer {
makeGlitch()
}
if (System.nanoTime() - lastEncodingGlitch >= nextEncodingGlitch) {
if (ClientConfig.ENABLE_COLOR_NOISE && System.nanoTime() - lastEncodingGlitch >= nextEncodingGlitch) {
makeColorGlitch()
}
@ -493,11 +498,13 @@ object GlitchRenderer {
drawVHSLineGap(((milliTime + glitchBuffer.height / 3) % glitchBuffer.height).toDouble(), glitchBuffer.height * 0.04)
drawVHSLineGap(((-milliTime - glitchBuffer.height / 3) % glitchBuffer.height).toDouble().absoluteValue, glitchBuffer.height * 0.07)
if (ClientConfig.ENABLE_COLOR_NOISE) {
// color encoding errors (encoder/transmission glitch)
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
RenderSystem.setShader(GameRenderer::getPositionTexColorShader)
colorGlitchVertexBuffer.bind()
colorGlitchVertexBuffer.drawWithShader(Matrix4f().also { it.setIdentity() }, Matrix4f().also { it.setIdentity() }, GameRenderer.getPositionTexColorShader()!!)
}
// upload final result to main frame buffer
minecraft.mainRenderTarget.bindWrite(true)