diff --git a/api/OneConfig.api b/api/OneConfig.api index 441e434a4..d540b1136 100644 --- a/api/OneConfig.api +++ b/api/OneConfig.api @@ -1083,6 +1083,8 @@ public class cc/polyfrost/oneconfig/gui/pages/SubModsPage : cc/polyfrost/oneconf public abstract class cc/polyfrost/oneconfig/hud/BasicHud : cc/polyfrost/oneconfig/hud/Hud { protected field background Z protected field bgColor Lcc/polyfrost/oneconfig/config/core/OneColor; + protected field blurAmount F + protected field blurBackground Z protected field border Z protected field borderColor Lcc/polyfrost/oneconfig/config/core/OneColor; protected field borderSize F @@ -1261,6 +1263,8 @@ public class cc/polyfrost/oneconfig/images/OneImage { } public abstract interface class cc/polyfrost/oneconfig/platform/GLPlatform { + public abstract fun drawBlurredRect (FFFFFF)V + public abstract fun drawBlurredRect (FFFFFFFFF)V public abstract fun drawRect (FFFFI)V public abstract fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun drawText (Ljava/lang/String;FFIZ)F diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/BasicHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/BasicHud.java index c36ab45f2..9c5a29127 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/BasicHud.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/BasicHud.java @@ -29,6 +29,7 @@ import cc.polyfrost.oneconfig.config.annotations.Exclude; import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.NanoVGHelper; @@ -36,9 +37,11 @@ public abstract class BasicHud extends Hud { protected boolean background; protected boolean rounded; protected boolean border; + protected boolean blurBackground; protected OneColor bgColor; protected OneColor borderColor; protected float cornerRadius; + protected float blurAmount = 4f; protected float borderSize; protected float defaultPaddingX, paddingX; protected float defaultPaddingY, paddingY; @@ -149,10 +152,12 @@ protected void drawBackground(float x, float y, float width, float height, float NanoVGHelper nanoVGHelper = NanoVGHelper.INSTANCE; nanoVGHelper.setupAndDraw(true, (vg) -> { if (rounded) { + if (blurBackground) Platform.getGLPlatform().drawBlurredRect(x, y, width, height, blurAmount, cornerRadius * scale); nanoVGHelper.drawRoundedRect(vg, x, y, width, height, bgColor.getRGB(), cornerRadius * scale); if (border) nanoVGHelper.drawHollowRoundRect(vg, x - borderSize * scale, y - borderSize * scale, width + borderSize * scale, height + borderSize * scale, borderColor.getRGB(), cornerRadius * scale, borderSize * scale); } else { + if (blurBackground) Platform.getGLPlatform().drawBlurredRect(x, y, width, height, blurAmount, 0f); nanoVGHelper.drawRect(vg, x, y, width, height, bgColor.getRGB()); if (border) nanoVGHelper.drawHollowRoundRect(vg, x - borderSize * scale, y - borderSize * scale, width + borderSize * scale, height + borderSize * scale, borderColor.getRGB(), 0, borderSize * scale); diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java index 60e1f0d39..ac2dd31fd 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/HUDUtils.java @@ -87,6 +87,8 @@ public Object setValue(Object value) { options.add(new ConfigCheckbox(fields.get("background"), hud, "Background", "If the background of the HUD is enabled.", category, subcategory, 1)); options.add(new ConfigCheckbox(fields.get("rounded"), hud, "Rounded corners", "If the background has rounded corners.", category, subcategory, 1)); options.get(options.size() - 1).addDependency("Background or Border", () -> ((BasicHud) hud).background || ((BasicHud) hud).border); + options.add(new ConfigCheckbox(fields.get("blurBackground"), hud, "Blurred", "If the background is blurred.", category, subcategory, 1)); + options.get(options.size() - 1).addDependency("Background", () -> ((BasicHud) hud).background); options.add(new ConfigCheckbox(fields.get("border"), hud, "Outline/border", "If the hud has an outline.", category, subcategory, 1)); options.add(new ConfigColorElement(fields.get("bgColor"), hud, "Background color:", "The color of the background.", category, subcategory, 1, true)); options.get(options.size() - 1).addDependency("Background", () -> ((BasicHud) hud).background); @@ -94,6 +96,8 @@ public Object setValue(Object value) { options.get(options.size() - 1).addDependency("Border", () -> ((BasicHud) hud).border); options.add(new ConfigSlider(fields.get("cornerRadius"), hud, "Corner radius:", "The corner radius of the background.", category, subcategory, 0, 10, 0, false)); options.get(options.size() - 1).addDependency("Rounded", () -> ((BasicHud) hud).rounded); + options.add(new ConfigSlider(fields.get("blurAmount"), hud, "Blur amount:", "The amount of background blur.", category, subcategory, 0.1f, 20f, 0, false)); + options.get(options.size() - 1).addDependency("Blurred", () -> ((BasicHud) hud).blurBackground); options.add(new ConfigSlider(fields.get("borderSize"), hud, "Border thickness:", "The thickness of the outline.", category, subcategory, 0, 10, 0, false)); options.get(options.size() - 1).addDependency("Border", () -> ((BasicHud) hud).border); Field paddingX = fields.get("paddingX"); diff --git a/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java b/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java index d5680a916..a5e49d8ba 100644 --- a/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java +++ b/src/main/java/cc/polyfrost/oneconfig/platform/GLPlatform.java @@ -40,4 +40,8 @@ default float drawText(String text, float x, float y, int color, boolean shadow) float drawText(UMatrixStack matrixStack, String text, float x, float y, int color, boolean shadow); int getStringWidth(String text); + + void drawBlurredRect(float x, float y, float width, float height, float blur, float TLRadius, float TRRadius, float BLRadius, float BRRadius); + + void drawBlurredRect(float x, float y, float width, float height, float blur, float radius); } diff --git a/src/main/resources/assets/shaders/blur.fsh b/src/main/resources/assets/shaders/blur.fsh new file mode 100644 index 000000000..e122815b1 --- /dev/null +++ b/src/main/resources/assets/shaders/blur.fsh @@ -0,0 +1,60 @@ +#version 120 + +uniform sampler2D u_texture; + +uniform vec2 u_texelSize; + +uniform float u_blurRadius; +uniform vec4 u_location; +uniform vec4 u_rectRadius; +uniform float u_pass; + +float gauss(float x, float sigma) { + float pow = x / sigma; + return (1.0 / (abs(sigma) * 2.50662827463) * exp(-0.5 * pow * pow)); +} + +float roundedBoxSDF(vec2 pos, vec2 size, vec4 radius) { + radius.xy = (pos.x > 0.0) ? radius.xy : radius.zw; + radius.x = (pos.y > 0.0) ? radius.x : radius.y; + vec2 q = abs(pos) - size + radius.x; + return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius.x; +} + +vec4 applyBlur(vec2 direction, vec2 texCoord, float blurRadius) { + vec4 color = vec4(0); + vec2 pos = gl_FragCoord.xy - u_location.xy - u_location.zw; + vec2 size = u_location.zw; + + if (direction.x == 1) { + pos.y -= blurRadius; + size.y += blurRadius * 2; + } + + float distance = roundedBoxSDF(pos, size, u_rectRadius); + + if (distance < 0.0) { + for (float f = -u_blurRadius; f <= u_blurRadius; f++) { + color += texture2D(u_texture, texCoord + f * u_texelSize * direction) * gauss(f, u_blurRadius / 2); + } + } + + return color; +} + +void main() { + vec4 color = vec4(0); + vec2 texCoord = gl_TexCoord[0].st; + + if (u_pass == 1) { + color = applyBlur(vec2(1.0, 0.0), texCoord, u_blurRadius); + gl_FragColor = vec4(color.rgb, 1); + } else if (u_pass == 2) { + color = applyBlur(vec2(0.0, 1.0), texCoord, 0); + float distance = roundedBoxSDF(gl_FragCoord.xy - u_location.xy - u_location.zw, u_location.zw, u_rectRadius); + + if (distance < 0.0) { + gl_FragColor = vec4(color.rgb, 1); + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/shaders/blur.vsh b/src/main/resources/assets/shaders/blur.vsh new file mode 100644 index 000000000..1eb5182ed --- /dev/null +++ b/src/main/resources/assets/shaders/blur.vsh @@ -0,0 +1,6 @@ +#version 120 + +void main() { + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; +} \ No newline at end of file diff --git a/versions/1.12.2-fabric/api/1.12.2-fabric.api b/versions/1.12.2-fabric/api/1.12.2-fabric.api index 73d795f59..3f2708a48 100644 --- a/versions/1.12.2-fabric/api/1.12.2-fabric.api +++ b/versions/1.12.2-fabric/api/1.12.2-fabric.api @@ -27,6 +27,8 @@ public class cc/polyfrost/oneconfig/events/event/TimerUpdateEvent { public class cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl : cc/polyfrost/oneconfig/platform/GLPlatform { public fun ()V + public fun drawBlurredRect (FFFFFF)V + public fun drawBlurredRect (FFFFFFFFF)V public fun drawRect (FFFFI)V public fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun enableStencil ()V diff --git a/versions/1.12.2-forge/api/1.12.2-forge.api b/versions/1.12.2-forge/api/1.12.2-forge.api index 5d4c8e16c..b09ece5a7 100644 --- a/versions/1.12.2-forge/api/1.12.2-forge.api +++ b/versions/1.12.2-forge/api/1.12.2-forge.api @@ -27,6 +27,8 @@ public class cc/polyfrost/oneconfig/events/event/TimerUpdateEvent { public class cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl : cc/polyfrost/oneconfig/platform/GLPlatform { public fun ()V + public fun drawBlurredRect (FFFFFF)V + public fun drawBlurredRect (FFFFFFFFF)V public fun drawRect (FFFFI)V public fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun enableStencil ()V diff --git a/versions/1.16.5-fabric/api/1.16.5-fabric.api b/versions/1.16.5-fabric/api/1.16.5-fabric.api index 3279a0c32..6c6bdfe0f 100644 --- a/versions/1.16.5-fabric/api/1.16.5-fabric.api +++ b/versions/1.16.5-fabric/api/1.16.5-fabric.api @@ -27,6 +27,8 @@ public class cc/polyfrost/oneconfig/events/event/TimerUpdateEvent { public class cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl : cc/polyfrost/oneconfig/platform/GLPlatform { public fun ()V + public fun drawBlurredRect (FFFFFF)V + public fun drawBlurredRect (FFFFFFFFF)V public fun drawRect (FFFFI)V public fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun enableStencil ()V diff --git a/versions/1.16.5-forge/api/1.16.5-forge.api b/versions/1.16.5-forge/api/1.16.5-forge.api index 261890d4b..6a31ec20e 100644 --- a/versions/1.16.5-forge/api/1.16.5-forge.api +++ b/versions/1.16.5-forge/api/1.16.5-forge.api @@ -27,6 +27,8 @@ public class cc/polyfrost/oneconfig/events/event/TimerUpdateEvent { public class cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl : cc/polyfrost/oneconfig/platform/GLPlatform { public fun ()V + public fun drawBlurredRect (FFFFFF)V + public fun drawBlurredRect (FFFFFFFFF)V public fun drawRect (FFFFI)V public fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun enableStencil ()V diff --git a/versions/1.8.9-fabric/api/1.8.9-fabric.api b/versions/1.8.9-fabric/api/1.8.9-fabric.api index 72478708c..1ea99b2c7 100644 --- a/versions/1.8.9-fabric/api/1.8.9-fabric.api +++ b/versions/1.8.9-fabric/api/1.8.9-fabric.api @@ -27,6 +27,8 @@ public class cc/polyfrost/oneconfig/events/event/TimerUpdateEvent { public class cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl : cc/polyfrost/oneconfig/platform/GLPlatform { public fun ()V + public fun drawBlurredRect (FFFFFF)V + public fun drawBlurredRect (FFFFFFFFF)V public fun drawRect (FFFFI)V public fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun enableStencil ()V diff --git a/versions/1.8.9-forge/api/1.8.9-forge.api b/versions/1.8.9-forge/api/1.8.9-forge.api index c4dc0a056..fea653864 100644 --- a/versions/1.8.9-forge/api/1.8.9-forge.api +++ b/versions/1.8.9-forge/api/1.8.9-forge.api @@ -27,6 +27,8 @@ public class cc/polyfrost/oneconfig/events/event/TimerUpdateEvent { public class cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl : cc/polyfrost/oneconfig/platform/GLPlatform { public fun ()V + public fun drawBlurredRect (FFFFFF)V + public fun drawBlurredRect (FFFFFFFFF)V public fun drawRect (FFFFI)V public fun drawText (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;Ljava/lang/String;FFIZ)F public fun enableStencil ()V diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java index feede96fe..d97d3d69f 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/MinecraftMixin.java @@ -29,6 +29,7 @@ import cc.polyfrost.oneconfig.events.EventManager; import cc.polyfrost.oneconfig.events.event.*; import cc.polyfrost.oneconfig.internal.OneConfig; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import net.minecraft.client.Minecraft; import net.minecraft.util.Timer; import org.objectweb.asm.Opcodes; @@ -78,6 +79,11 @@ private void onInit(CallbackInfo ci) { OneConfig.INSTANCE.init(); EventManager.INSTANCE.post(new InitializationEvent()); } + + @Inject(method = "updateFramebufferSize", at = @At("HEAD")) + private void updateSize(CallbackInfo ci) { + cc.polyfrost.oneconfig.internal.gui.impl.ShadersKt.getBlurProgram().getBlurBuffer().createBindFramebuffer(UMinecraft.getMinecraft().displayWidth, UMinecraft.getMinecraft().displayHeight); + } //#endif @Inject(method = "runGameLoop", at = @At(value = "INVOKE", target = UPDATE_CAMERA_AND_RENDER)) diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java index 4b1168855..b1c654b31 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/platform/impl/GLPlatformImpl.java @@ -105,4 +105,16 @@ public float drawText(UMatrixStack matrixStack, String text, float x, float y, i public int getStringWidth(String text) { return UMinecraft.getFontRenderer().getStringWidth(text); } + + @Override + public void drawBlurredRect(float x, float y, float width, float height, float blur, float TLRadius, float TRRadius, float BLRadius, float BRRadius) { + //#if FORGE==1 && MC<=11202 + cc.polyfrost.oneconfig.internal.gui.impl.ShadersKt.getBlurProgram().render(x, y, width, height, TLRadius, TRRadius, BLRadius, BRRadius, blur); + //#endif + } + + @Override + public void drawBlurredRect(float x, float y, float width, float height, float blur, float radius) { + drawBlurredRect(x, y, width, height, blur, radius, radius, radius, radius); + } } diff --git a/versions/src/main/kotlin/cc/polyfrost/oneconfig/internal/gui/impl/ShaderProgram.kt b/versions/src/main/kotlin/cc/polyfrost/oneconfig/internal/gui/impl/ShaderProgram.kt new file mode 100644 index 000000000..05981605d --- /dev/null +++ b/versions/src/main/kotlin/cc/polyfrost/oneconfig/internal/gui/impl/ShaderProgram.kt @@ -0,0 +1,148 @@ +/* + * This file is part of OneConfig. + * OneConfig - Next Generation Config Library for Minecraft: Java Edition + * Copyright (C) 2021~2023 Polyfrost. + * + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * OneConfig is licensed under the terms of version 3 of the GNU Lesser + * General Public License as published by the Free Software Foundation, AND + * under the Additional Terms Applicable to OneConfig, as published by Polyfrost, + * either version 1.0 of the Additional Terms, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License. If not, see . You should + * have also received a copy of the Additional Terms Applicable + * to OneConfig, as published by Polyfrost. If not, see + * + */ + +//#if FORGE==1 && MC<=11202 +package cc.polyfrost.oneconfig.internal.gui.impl + +import cc.polyfrost.oneconfig.internal.OneConfig +import org.lwjgl.opengl.GL11 +import org.lwjgl.opengl.GL20.* + +abstract class ShaderProgram( + val program: Int = glCreateProgram(), + val uniforms: MutableList = mutableListOf(), + var active: Boolean = false +) { + abstract fun register() + init { + register() + glLinkProgram(program) + glValidateProgram(program) + } + + open fun begin() { + active = true + glUseProgram(program) + } + open fun applyUniforms() { + uniforms.forEach { it.apply() } + } + open fun end() { + if (!active) return + active = false + glUseProgram(0) + } + + fun registerShader( + location: String, + type: Int + ) { + val source = OneConfig.INSTANCE::class.java.classLoader.getResource(location) ?: throw IllegalStateException("Failed to fetch resource $location") + val shader = initShader( + location.substringAfterLast("/").substringBeforeLast("."), + source.readBytes().toString(Charsets.UTF_8), + type + ) + + glAttachShader(program, shader) + } + private fun initShader(name: String, shaderSource: String, type: Int) : Int { + var shader = 0 + + try { + shader = glCreateShader(type) + glShaderSource(shader, shaderSource) + glCompileShader(shader) + + if (glGetShaderi(shader, GL_COMPILE_STATUS) == GL11.GL_FALSE) + throw Exception( + "Error in creating shader $name :${ + glGetShaderInfoLog(shader, Short.MAX_VALUE.toInt()) + }" + ) + + return shader + } catch (ex: Exception) { + glDeleteShader(shader) + throw ex + } + } + + fun getUniform(name: String) = glGetUniformLocation(program, name) + abstract inner class Uniform( + name: String, + var location: Int = 0 + ) { + init { + location = getUniform(name) + registerUniform() + } + private fun registerUniform() = uniforms.add(this) + internal abstract fun apply() + } + + open inner class Uniform1f( + name: String, + var x: Float = 0f + ) : Uniform(name) { + override fun apply() { + glUniform1f(location, x) + } + } + + open inner class Uniform2f( + name: String, + var x: Float = 0f, + var y: Float = 0f + ) : Uniform(name) { + override fun apply() { + glUniform2f(location, x, y) + } + } + + open inner class Uniform4f( + name: String, + var x: Float = 0f, + var y: Float = 0f, + var z: Float = 0f, + var w: Float = 0f + ) : Uniform(name) { + override fun apply() { + glUniform4f(location, x, y, z, w) + } + } + + open inner class UniformSampler( + name: String, + var textureId: Int = 0 + ): Uniform(name) { + override fun apply() { + glUniform1i(this.location, this.textureId) + } + } + +} +//#endif \ No newline at end of file diff --git a/versions/src/main/kotlin/cc/polyfrost/oneconfig/internal/gui/impl/Shaders.kt b/versions/src/main/kotlin/cc/polyfrost/oneconfig/internal/gui/impl/Shaders.kt new file mode 100644 index 000000000..024a22f22 --- /dev/null +++ b/versions/src/main/kotlin/cc/polyfrost/oneconfig/internal/gui/impl/Shaders.kt @@ -0,0 +1,122 @@ +/* + * This file is part of OneConfig. + * OneConfig - Next Generation Config Library for Minecraft: Java Edition + * Copyright (C) 2021~2023 Polyfrost. + * + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * OneConfig is licensed under the terms of version 3 of the GNU Lesser + * General Public License as published by the Free Software Foundation, AND + * under the Additional Terms Applicable to OneConfig, as published by Polyfrost, + * either version 1.0 of the Additional Terms, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License. If not, see . You should + * have also received a copy of the Additional Terms Applicable + * to OneConfig, as published by Polyfrost. If not, see + * + */ + +//#if FORGE==1 && MC<=11202 +package cc.polyfrost.oneconfig.internal.gui.impl + +import cc.polyfrost.oneconfig.libs.universal.UResolution +import cc.polyfrost.oneconfig.utils.dsl.mc +import net.minecraft.client.shader.Framebuffer +import org.lwjgl.opengl.Display +import org.lwjgl.opengl.GL11.* +import org.lwjgl.opengl.GL20 +import kotlin.math.ceil + +val blurProgram = BlurProgram() + +class BlurProgram: ShaderProgram() { + val texture = UniformSampler("u_texture") + val texelSize = Uniform2f("u_texelSize") + val pass = Uniform1f("u_pass") + val blurRadius = Uniform1f("u_blurRadius") + val rectRadius = Uniform4f("u_rectRadius") + val location = Uniform4f("u_location") + override fun register() { + registerShader("assets/shaders/blur.fsh", GL20.GL_FRAGMENT_SHADER) + registerShader("assets/shaders/blur.vsh", GL20.GL_VERTEX_SHADER) + } + + private fun renderFrameBufferTexture(frameBuffer: Framebuffer) { + val scaledRes = UResolution + val texX = frameBuffer.framebufferWidth.toFloat() / frameBuffer.framebufferTextureWidth.toFloat() + val texY = frameBuffer.framebufferHeight.toFloat() / frameBuffer.framebufferTextureHeight.toFloat() + + glBegin(GL_QUADS) + glTexCoord2f(0f, 0f) + glVertex3f(0f, scaledRes.scaledHeight.toFloat(), 0f) + glTexCoord2f(texX, 0f) + glVertex3f(scaledRes.scaledWidth.toFloat(), scaledRes.scaledHeight.toFloat(), 0f) + glTexCoord2f(texX, texY) + glVertex3f(scaledRes.scaledWidth.toFloat(), 0f, 0f) + glTexCoord2f(0f, texY) + glVertex3f(0f, 0f, 0f) + glEnd() + } + + var blurBuffer = Framebuffer(Display.getWidth(), Display.getHeight(), false) + fun render( + x: Float = 0f, + y: Float = 0f, + width: Float = UResolution.scaledWidth.toFloat(), + height: Float = UResolution.scaledHeight.toFloat(), + topLeftRadius: Float, + topRightRadius: Float, + bottomLeftRadius: Float, + bottomRightRadius: Float, + blurRadius: Float = 18f + ) { + begin() + + blurBuffer.framebufferClear() + + texelSize.x = 1f / Display.getWidth() + texelSize.y = 1f / Display.getHeight() + texture.textureId = 0 + this.blurRadius.x = ceil(2 * blurRadius) + + val sr = UResolution + val scale = sr.scaleFactor.toFloat() + val trueScale = (Display.getWidth().toFloat() / sr.scaledWidth.toFloat()) / 2f + + location.x = x * scale + location.y = Display.getHeight() - (y + height) * scale + location.z = width * trueScale + location.w = height * trueScale + + rectRadius.x = topRightRadius * scale + rectRadius.y = bottomRightRadius * scale + rectRadius.z = topLeftRadius * scale + rectRadius.w = bottomLeftRadius * scale + + pass.x = 1f + applyUniforms() + + blurBuffer.bindFramebuffer(true) + mc.framebuffer.bindFramebufferTexture() + renderFrameBufferTexture(blurBuffer) + + pass.x = 2f + applyUniforms() + + mc.framebuffer.bindFramebuffer(true) + blurBuffer.bindFramebufferTexture() + renderFrameBufferTexture(mc.framebuffer) + + end() + } + +} +//#endif \ No newline at end of file