Skip to content

Commit dfc84bd

Browse files
authored
URenderPipeline: Fix blend state with default/mc shaders on 1.17-1.20.6, properly
The previous workaround for this (5f02456) had incorrectly assumed that all our code running after it would only touch the global GL state but not MC's GlBlendState global state, however `BlendState.activate` (and `UGraphics.Global.blendState`, which forwards to that) does actually set MC's GlBlendState global state as well, rendering the workaround largely ineffective. This commit fixes that by adding an internal method to `BlendState` which bypasses MC's `GlBlendState`, and then using that method from the workaround in `URenderPipeline` as well as `ManagedGlState`. Linear: EM-3509 GitHub: #120
1 parent 1d6c4eb commit dfc84bd

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/main/kotlin/gg/essential/universal/render/ManagedGlState.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ internal class ManagedGlState(
126126
}
127127
if (curr.blendState != blendState) {
128128
curr.blendState = blendState
129-
@Suppress("DEPRECATION")
130-
blendState.activate()
129+
blendState.activateWithoutChangingMcBlendState()
131130
}
132131
if (curr.colorMask != colorMask) {
133132
curr.colorMask = colorMask

src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class URenderPipeline private constructor(
132132
//$$ val prevBlendState = BlendState.active()
133133
//$$ shaderProgram.bind()
134134
//$$ shaderProgram.unbind()
135-
//$$ UGraphics.Globals.blendState(prevBlendState)
135+
//$$ prevBlendState.activateWithoutChangingMcBlendState()
136136
//$$ }
137137
//#endif
138138
}

src/main/kotlin/gg/essential/universal/shader/BlendState.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ data class BlendState(
6060
fun activate() = applyState()
6161
//#endif
6262

63+
internal fun activateWithoutChangingMcBlendState() = applyState()
64+
6365
@Suppress("DEPRECATION")
6466
private fun applyState() {
6567
if (enabled) {

0 commit comments

Comments
 (0)