mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
fix buggy fog after shader reloading
This commit is contained in:
parent
d9063b6f4b
commit
1ceb345adf
@ -24,6 +24,7 @@ import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.shader.types.FogShader
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.NativeShader
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
|
||||
class FogManager(
|
||||
@ -143,21 +144,29 @@ class FogManager(
|
||||
if (shader !is FogShader || shader.fog != this) {
|
||||
continue
|
||||
}
|
||||
shader.use()
|
||||
|
||||
shader.native["uFogStart"] = start
|
||||
shader.native["uFogEnd"] = end
|
||||
shader.native["uFogDistance"] = distance
|
||||
if (color == null) {
|
||||
shader.native[USE_FOG_COLOR] = false
|
||||
} else {
|
||||
shader.native[FOG_COLOR] = color
|
||||
shader.native[USE_FOG_COLOR] = true
|
||||
}
|
||||
use(shader.native, start, end, color, distance)
|
||||
}
|
||||
this.shaderRevision = revision
|
||||
}
|
||||
|
||||
fun use(shader: NativeShader) {
|
||||
use(shader, interpolatedFogStart * interpolatedFogStart, interpolatedFogEnd * interpolatedFogEnd, interpolatedFogColor)
|
||||
}
|
||||
|
||||
fun use(shader: NativeShader, start: Float, end: Float, color: RGBColor?, distance: Float = end - start) {
|
||||
shader.use()
|
||||
|
||||
shader["uFogStart"] = start
|
||||
shader["uFogEnd"] = end
|
||||
shader["uFogDistance"] = distance
|
||||
if (color == null) {
|
||||
shader[USE_FOG_COLOR] = false
|
||||
} else {
|
||||
shader[FOG_COLOR] = color
|
||||
shader[USE_FOG_COLOR] = true
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LAVA_FOG_COLOR = RGBColor(0.6f, 0.1f, 0.0f)
|
||||
private const val FOG_INTERPOLATION_TIME = 300
|
||||
|
@ -21,6 +21,6 @@ interface FogShader : AbstractShader, CameraPositionShader {
|
||||
var fog: FogManager
|
||||
|
||||
fun fog(default: FogManager = native.renderWindow.camera.fogManager): ShaderUniform<FogManager> {
|
||||
return uniform("fog", default) { _, _, _ -> }
|
||||
return uniform("fog", default) { native, _, value -> value.use(native) }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user