fix some transparency issues

This commit is contained in:
Bixilon 2021-12-30 18:45:23 +01:00
parent 37f045db27
commit aca57fd5f0
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
8 changed files with 24 additions and 9 deletions

View File

@ -153,7 +153,6 @@ class HUDRenderer(
private fun setup() {
renderWindow.renderSystem.reset(blending = true)
renderWindow.renderSystem.clear(IntegratedBufferTypes.DEPTH_BUFFER)
shader.use()
}

View File

@ -51,7 +51,7 @@ class CrosshairHUDElement(hudRenderer: HUDRenderer) : CustomHUDElement(hudRender
val mesh = mesh ?: return
if (crosshairProfile.complementaryColor) {
renderWindow.renderSystem.reset(blending = true, sourceAlpha = BlendingFunctions.ONE_MINUS_DESTINATION_COLOR, destinationAlpha = BlendingFunctions.ONE_MINUS_SOURCE_COLOR)
renderWindow.renderSystem.reset(blending = true, sourceRGB = BlendingFunctions.ONE_MINUS_DESTINATION_COLOR, destinationRGB = BlendingFunctions.ONE_MINUS_SOURCE_COLOR)
} else {
renderWindow.renderSystem.reset()
}

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.gui.rendering.renderer.Renderer
import de.bixilon.minosoft.gui.rendering.renderer.RendererBuilder
import de.bixilon.minosoft.gui.rendering.system.base.*
import de.bixilon.minosoft.gui.rendering.system.base.buffer.frame.Framebuffer
import de.bixilon.minosoft.gui.rendering.system.base.phases.PostDrawable
import de.bixilon.minosoft.gui.rendering.system.base.phases.PreDrawable
import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture
import de.bixilon.minosoft.gui.rendering.util.mesh.SimpleTextureMesh
import de.bixilon.minosoft.modding.event.events.TimeChangeEvent
@ -37,7 +37,7 @@ import glm_.vec3.Vec3
class SkyRenderer(
private val connection: PlayConnection,
override val renderWindow: RenderWindow,
) : Renderer, PostDrawable {
) : Renderer, PreDrawable {
override val renderSystem: RenderSystem = renderWindow.renderSystem
private val skyboxShader = renderSystem.createShader(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "sky/skybox"))
private val skySunShader = renderSystem.createShader(ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, "sky/sun"))
@ -138,7 +138,7 @@ class SkyRenderer(
skyboxMesh.draw()
}
override fun drawPost() {
override fun drawPre() {
renderWindow.renderSystem.reset(depth = DepthFunctions.LESS_OR_EQUAL)
drawSkybox()
drawSun()

View File

@ -41,12 +41,14 @@ interface RenderSystem {
blending: Boolean = false,
faceCulling: Boolean = true,
depthMask: Boolean = true,
sourceRGB: BlendingFunctions = BlendingFunctions.ONE,
destinationRGB: BlendingFunctions = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA,
sourceAlpha: BlendingFunctions = BlendingFunctions.ONE,
destinationAlpha: BlendingFunctions = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA,
destinationAlpha: BlendingFunctions = BlendingFunctions.ZERO,
depth: DepthFunctions = DepthFunctions.LESS,
clearColor: RGBColor = Colors.TRANSPARENT,
) {
setBlendFunction(sourceAlpha, destinationAlpha, BlendingFunctions.ONE, BlendingFunctions.ZERO)
setBlendFunction(sourceRGB, destinationRGB, sourceAlpha, destinationAlpha)
this[RenderingCapabilities.DEPTH_TEST] = depthTest
this[RenderingCapabilities.BLENDING] = blending
this[RenderingCapabilities.FACE_CULLING] = faceCulling

View File

@ -8,7 +8,13 @@ interface TranslucentDrawable : Renderer {
get() = false
fun setupTranslucent() {
renderSystem.reset(sourceAlpha = BlendingFunctions.SOURCE_ALPHA, destinationAlpha = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA, blending = true)
renderSystem.reset(
blending = true,
sourceRGB = BlendingFunctions.SOURCE_ALPHA,
destinationRGB = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA,
sourceAlpha = BlendingFunctions.ONE,
destinationAlpha = BlendingFunctions.ONE_MINUS_SOURCE_ALPHA,
)
}
fun drawTranslucent()

View File

@ -7,7 +7,7 @@ interface TransparentDrawable : Renderer {
get() = false
fun setupTransparent() {
renderSystem.reset()
renderSystem.reset(blending = true)
}
fun drawTransparent()

View File

@ -36,6 +36,8 @@ void main() {
#ifdef TRANSPARENT
if (foutColor.a < 0.3f){
discard;
} else {
foutColor.a = 1.0f;
}
#endif
return;
@ -53,6 +55,8 @@ void main() {
#ifdef TRANSPARENT
if (foutColor.a < 0.3f){
discard;
} else {
foutColor.a = 1.0f;
}
#endif
}

View File

@ -38,6 +38,8 @@ void work() {
#ifdef TRANSPARENT
if (foutColor.a < 0.3f){
discard;
} else {
foutColor.a = 1.0f;
}
#endif
return;
@ -54,6 +56,8 @@ void work() {
#ifdef TRANSPARENT
if (foutColor.a < 0.3f) {
discard;
} else {
foutColor.a = 1.0f;
}
#endif
}