diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index 4dece1a..3716197 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -83,7 +83,7 @@ public class LiteMainMenu extends SilentScreen } else { this.bannerAnimation.setAnimation(0, 30); } - RenderUtil.drawImage(PromoController.getResponse().getCurrentPanel().getImageLocation(), this.width - 74 + (-this.bannerAnimation.getValue()), this.height - 42 + (-this.bannerAnimation.getValue()), 71, 40, false); + RenderUtil.drawRoundTextured(this.width - 74 + (-this.bannerAnimation.getValue()), this.height - 42 + (-this.bannerAnimation.getValue()), 71, 40, 4, 1, PromoController.getResponse().getCurrentPanel().getImageLocation(), false); } else { PromoController.getResponse().getCurrentPanel().loadImage(); } diff --git a/src/main/java/net/silentclient/client/gui/util/RenderUtil.java b/src/main/java/net/silentclient/client/gui/util/RenderUtil.java index 8bcd615..e252efe 100644 --- a/src/main/java/net/silentclient/client/gui/util/RenderUtil.java +++ b/src/main/java/net/silentclient/client/gui/util/RenderUtil.java @@ -3,6 +3,7 @@ package net.silentclient.client.gui.util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; @@ -13,14 +14,59 @@ import net.silentclient.client.Client; import net.silentclient.client.cosmetics.StaticResourceLocation; import net.silentclient.client.mixin.ducks.TextureManagerExt; import net.silentclient.client.utils.ColorUtils; +import net.silentclient.client.utils.ShaderUtils; import org.lwjgl.opengl.GL11; +import java.awt.*; + import static org.lwjgl.opengl.GL11.*; public class RenderUtil { final static Minecraft mc = Minecraft.getMinecraft(); final static FontRenderer fr = mc.fontRendererObj; + public static ShaderUtils roundedShader = new ShaderUtils("silentclient/shaders/roundedRect.frag"); + public static ShaderUtils roundedOutlineShader = new ShaderUtils("silentclient/shaders/roundRectOutline.frag"); + private static ShaderUtils roundedTexturedShader = new ShaderUtils("silentclient/shaders/roundRectTextured.frag"); + + public static void drawRound(float x, float y, float width, float height, float radius, Color color) { + ColorUtils.resetColor(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + roundedShader.init(); + + setupRoundedRectUniforms(x, y, width, height, radius, roundedShader); + roundedShader.setUniformf("color", color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedShader.unload(); + GlStateManager.disableBlend(); + } + + public static void drawRoundTextured(float x, float y, float width, float height, float radius, float alpha, ResourceLocation image, boolean mipmapped) { + if(mipmapped) { + Client.getInstance().getTextureManager().bindTextureMipmapped(image); + } else { + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + } + ColorUtils.resetColor(); + roundedTexturedShader.init(); + roundedTexturedShader.setUniformi("textureIn", 0); + setupRoundedRectUniforms(x, y, width, height, radius, roundedTexturedShader); + roundedTexturedShader.setUniformf("alpha", alpha); + ShaderUtils.drawQuads(x - 1, y - 1, width + 2, height + 2); + roundedTexturedShader.unload(); + GlStateManager.disableBlend(); + } + + private static void setupRoundedRectUniforms(float x, float y, float width, float height, float radius, ShaderUtils roundedTexturedShader) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + roundedTexturedShader.setUniformf("location", x * sr.getScaleFactor(), + (Minecraft.getMinecraft().displayHeight - (height * sr.getScaleFactor())) - (y * sr.getScaleFactor())); + roundedTexturedShader.setUniformf("rectSize", width * sr.getScaleFactor(), height * sr.getScaleFactor()); + roundedTexturedShader.setUniformf("radius", radius * sr.getScaleFactor()); + } + public static void drawRoundedRect(float x, float y, float x1, float y1, float radius, int color) { x1 = x + x1; y1 = y + y1; @@ -65,7 +111,7 @@ public class RenderUtil { glPopAttrib(); glLineWidth(1); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - } + } public static void drawRoundedOutline(float x, float y, float x1, float y1, float radius,float lineWidth, int color) { x1 = x + x1; y1 = y + y1; @@ -83,13 +129,13 @@ public class RenderUtil { glBegin(GL_LINE_LOOP); int i; for (i = 0; i <= 90; i += 3) - glVertex2d(x + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, y + radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); + glVertex2d(x + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, y + radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); for (i = 90; i <= 180; i += 3) - glVertex2d(x + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, y1 - radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); + glVertex2d(x + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, y1 - radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); for (i = 0; i <= 90; i += 3) - glVertex2d(x1 - radius + Math.sin(i * Math.PI / 180.0D) * radius, y1 - radius + Math.cos(i * Math.PI / 180.0D) * radius); + glVertex2d(x1 - radius + Math.sin(i * Math.PI / 180.0D) * radius, y1 - radius + Math.cos(i * Math.PI / 180.0D) * radius); for (i = 90; i <= 180; i += 3) - glVertex2d(x1 - radius + Math.sin(i * Math.PI / 180.0D) * radius, y + radius + Math.cos(i * Math.PI / 180.0D) * radius); + glVertex2d(x1 - radius + Math.sin(i * Math.PI / 180.0D) * radius, y + radius + Math.cos(i * Math.PI / 180.0D) * radius); glEnd(); glEnable(GL_TEXTURE_2D); glDisable(GL_BLEND); @@ -100,7 +146,7 @@ public class RenderUtil { glPopAttrib(); glLineWidth(1); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - } + } /* * diff --git a/src/main/java/net/silentclient/client/mods/HudMod.java b/src/main/java/net/silentclient/client/mods/HudMod.java index b55d8f5..f5806b5 100644 --- a/src/main/java/net/silentclient/client/mods/HudMod.java +++ b/src/main/java/net/silentclient/client/mods/HudMod.java @@ -35,6 +35,7 @@ public class HudMod extends ModDraggable { this.addBooleanSetting("Brackets", this, false); this.addBooleanSetting("Fancy Font", this, false); this.addBooleanSetting("Rounded Corners", this, false); + this.addSliderSetting("Rounding Strength", this, 3, 1, 6, true); } public String getText() { @@ -110,7 +111,7 @@ public class HudMod extends ModDraggable { preRender(); if(background) { if(roundedCorners) { - RenderUtil.drawRoundedRect(getX(), getY(), this.getRealWidth(), this.getHeight(), 6, backgroundColor.getRGB()); + RenderUtil.drawRound(getX(), getY(), this.getRealWidth(), this.getHeight(), Client.getInstance().getSettingsManager().getSettingByName(this, "Rounding Strength").getValInt(), backgroundColor); } else { RenderUtils.drawRect(getX(), getY(), this.getRealWidth(), this.getHeight(), backgroundColor.getRGB()); } diff --git a/src/main/java/net/silentclient/client/mods/hud/BlockInfoMod.java b/src/main/java/net/silentclient/client/mods/hud/BlockInfoMod.java index 36c57e7..56e0a48 100644 --- a/src/main/java/net/silentclient/client/mods/hud/BlockInfoMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/BlockInfoMod.java @@ -1,7 +1,5 @@ package net.silentclient.client.mods.hud; -import java.awt.Color; - import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -15,13 +13,16 @@ import net.minecraft.potion.Potion; import net.minecraft.util.BlockPos; import net.minecraft.util.MovingObjectPosition.MovingObjectType; import net.silentclient.client.Client; +import net.silentclient.client.gui.hud.ScreenPosition; import net.silentclient.client.gui.lite.clickgui.utils.GlUtils; import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; -import net.silentclient.client.gui.hud.ScreenPosition; +import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.mods.CustomFontRenderer; import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.ModDraggable; +import java.awt.*; + public class BlockInfoMod extends ModDraggable { private BlockPos pos; private IBlockState state; @@ -43,6 +44,8 @@ public class BlockInfoMod extends ModDraggable { this.addColorSetting("Color", this, new Color(255, 255, 255)); this.addBooleanSetting("Font Shadow", this, true); this.addBooleanSetting("Fancy Font", this, false); + this.addBooleanSetting("Rounded Corners", this, false); + this.addSliderSetting("Rounding Strength", this, 3, 1, 6, true); } @Override @@ -70,6 +73,8 @@ public class BlockInfoMod extends ModDraggable { if(block != null && !block.equals(Blocks.portal) && !block.equals(Blocks.end_portal)) { String harvest = ""; boolean background = Client.getInstance().getSettingsManager().getSettingByName(this, "Background").getValBoolean(); + boolean roundedCorners = Client.getInstance().getSettingsManager().getSettingByName(this, "Rounded Corners").getValBoolean(); + Color backgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Background Color").getValColor(); boolean fontShadow = Client.getInstance().getSettingsManager().getSettingByName(this, "Font Shadow").getValBoolean(); Color color = Client.getInstance().getSettingsManager().getSettingByName(this, "Color").getValColor(); @@ -82,11 +87,15 @@ public class BlockInfoMod extends ModDraggable { float infoY = 4.5F; font.setRenderMode(fancyFont ? CustomFontRenderer.RenderMode.CUSTOM : CustomFontRenderer.RenderMode.DEFAULT); - + if(background) { - RenderUtils.drawRect(0, 0, getWidth(), getHeight(), backgroundColor.getRGB()); + if(roundedCorners) { + RenderUtil.drawRound(0, 0, getWidth(), getHeight(), Client.getInstance().getSettingsManager().getSettingByName(this, "Rounding Strength").getValInt(), backgroundColor); + } else { + RenderUtils.drawRect(0, 0, getWidth(), getHeight(), backgroundColor.getRGB()); + } } - + GlUtils.startScale(0, 0, 5, 50, 1.8F); RenderHelper.enableGUIStandardItemLighting(); mc.getRenderItem().renderItemAndEffectIntoGUI(new ItemStack(block), 0 + 5, 0 + (50 / 2) - 8); diff --git a/src/main/java/net/silentclient/client/mods/hud/CoordinatesMod.java b/src/main/java/net/silentclient/client/mods/hud/CoordinatesMod.java index f893f58..63040ce 100644 --- a/src/main/java/net/silentclient/client/mods/hud/CoordinatesMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/CoordinatesMod.java @@ -1,16 +1,17 @@ package net.silentclient.client.mods.hud; -import java.awt.Color; - import net.minecraft.util.BlockPos; import net.minecraft.world.chunk.Chunk; import net.silentclient.client.Client; -import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.gui.hud.ScreenPosition; +import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; +import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.mods.CustomFontRenderer; import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.ModDraggable; +import java.awt.*; + public class CoordinatesMod extends ModDraggable { int maxWidth = 0; @@ -27,6 +28,8 @@ public class CoordinatesMod extends ModDraggable { this.addBooleanSetting("Font Shadow", this, true); this.addBooleanSetting("Brackets", this, false); this.addBooleanSetting("Fancy Font", this, false); + this.addBooleanSetting("Rounded Corners", this, false); + this.addSliderSetting("Rounding Strength", this, 3, 1, 6, true); this.addBooleanSetting("Show Biome", this, true); } @@ -48,6 +51,7 @@ public class CoordinatesMod extends ModDraggable { CustomFontRenderer font = new CustomFontRenderer(); font.setRenderMode(fancyFont ? CustomFontRenderer.RenderMode.CUSTOM : CustomFontRenderer.RenderMode.DEFAULT); + boolean roundedCorners = Client.getInstance().getSettingsManager().getSettingByName(this, "Rounded Corners").getValBoolean(); boolean background = Client.getInstance().getSettingsManager().getSettingByName(this, "Background").getValBoolean(); Color backgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Background Color").getValColor(); boolean fontShadow = Client.getInstance().getSettingsManager().getSettingByName(this, "Font Shadow").getValBoolean(); @@ -67,7 +71,11 @@ public class CoordinatesMod extends ModDraggable { } if(background) { - RenderUtils.drawRect(0, 0, maxWidth, getHeight(), backgroundColor.getRGB()); + if(roundedCorners) { + RenderUtil.drawRound(0, 0, maxWidth, getHeight(), Client.getInstance().getSettingsManager().getSettingByName(this, "Rounding Strength").getValInt(), backgroundColor); + } else { + RenderUtils.drawRect(0, 0, maxWidth, getHeight(), backgroundColor.getRGB()); + } } font.drawString((!brackets ? "" : "[") + "X: " + (int) (mc.thePlayer.posX) + (!brackets ? "" : "]"), (int) (0 + 4.5F), (int) (0 + 4.5F), color.getRGB(), fontShadow); diff --git a/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java b/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java index e27e2f0..3422162 100644 --- a/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java @@ -38,6 +38,7 @@ public class KeystrokesMod extends ModDraggable { this.addBooleanSetting("Fancy Font", this, false); this.addBooleanSetting("Background", this, true); this.addBooleanSetting("Rounded Corners", this, false); + this.addSliderSetting("Rounding Strength", this, 3, 1, 6, true); this.addModeSetting("CPS Mode", this, "Small", cpsModes); this.addColorSetting("Color", this, new Color(255, 255, 255)); this.addColorSetting("Background Color", this, new Color(0, 0, 0), 127); @@ -205,13 +206,13 @@ public class KeystrokesMod extends ModDraggable { setAnimation(key.blue, key.isDown() ? clickedBackgroundColor.getBlue() : backgroundColor.getBlue(), fadeDelay); setAnimation(key.alpha, key.isDown() ? clickedBackgroundColor.getAlpha() : backgroundColor.getAlpha(), fadeDelay); if(roundedCorners) { - RenderUtil.drawRoundedRect( + RenderUtil.drawRound( key.getX(), key.getY(), key.getWidth(), key.getHeight(), - 6, - new Color((int) key.red.getValue(), (int) key.green.getValue(), (int) key.blue.getValue(), (int) key.alpha.getValue()).getRGB() + Client.getInstance().getSettingsManager().getSettingByName(this, "Rounding Strength").getValInt(), + new Color((int) key.red.getValue(), (int) key.green.getValue(), (int) key.blue.getValue(), (int) key.alpha.getValue()) ); } else { RenderUtils.drawRect( @@ -308,13 +309,13 @@ public class KeystrokesMod extends ModDraggable { setAnimation(Space.blue, Space.isDown() ? clickedBackgroundColor.getBlue() : backgroundColor.getBlue(), fadeDelay); setAnimation(Space.alpha, Space.isDown() ? clickedBackgroundColor.getAlpha() : backgroundColor.getAlpha(), fadeDelay); if(roundedCorners) { - RenderUtil.drawRoundedRect( + RenderUtil.drawRound( 0, 0 + mode.getHeight() + 2, mode.getWidth(), 10, - 6, - new Color((int) Space.red.getValue(), (int) Space.green.getValue(), (int) Space.blue.getValue(), (int) Space.alpha.getValue()).getRGB() + Client.getInstance().getSettingsManager().getSettingByName(this, "Rounding Strength").getValInt(), + new Color((int) Space.red.getValue(), (int) Space.green.getValue(), (int) Space.blue.getValue(), (int) Space.alpha.getValue()) ); } else { RenderUtils.drawRect( diff --git a/src/main/java/net/silentclient/client/utils/ShaderUtils.java b/src/main/java/net/silentclient/client/utils/ShaderUtils.java new file mode 100644 index 0000000..9bbed51 --- /dev/null +++ b/src/main/java/net/silentclient/client/utils/ShaderUtils.java @@ -0,0 +1,123 @@ +package net.silentclient.client.utils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.util.ResourceLocation; + +import java.io.IOException; +import java.io.InputStream; + +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL20.*; + +public class ShaderUtils { + + private static Minecraft mc = Minecraft.getMinecraft(); + private final int programID; + + public ShaderUtils(String fragmentShaderLoc, String vertexShaderLoc) { + int program = glCreateProgram(); + try { + int fragmentShaderID = createShader(mc.getResourceManager().getResource(new ResourceLocation(fragmentShaderLoc)).getInputStream(), GL_FRAGMENT_SHADER);; + glAttachShader(program, fragmentShaderID); + + int vertexShaderID = createShader(mc.getResourceManager().getResource(new ResourceLocation(vertexShaderLoc)).getInputStream(), GL_VERTEX_SHADER); + glAttachShader(program, vertexShaderID); + } catch (IOException e) { + e.printStackTrace(); + } + + glLinkProgram(program); + int status = glGetProgrami(program, GL_LINK_STATUS); + + if (status == 0) { + throw new IllegalStateException("Shader failed to link!"); + } + this.programID = program; + } + + public ShaderUtils(String fragmentShaderLoc) { + this(fragmentShaderLoc, "silentclient/shaders/vertex.vsh"); + } + + + public void init() { + glUseProgram(programID); + } + + public void unload() { + glUseProgram(0); + } + + public int getUniform(String name) { + return glGetUniformLocation(programID, name); + } + + + public void setUniformf(String name, float... args) { + int loc = glGetUniformLocation(programID, name); + switch (args.length) { + case 1: + glUniform1f(loc, args[0]); + break; + case 2: + glUniform2f(loc, args[0], args[1]); + break; + case 3: + glUniform3f(loc, args[0], args[1], args[2]); + break; + case 4: + glUniform4f(loc, args[0], args[1], args[2], args[3]); + break; + } + } + + public void setUniformi(String name, int... args) { + int loc = glGetUniformLocation(programID, name); + if (args.length > 1) glUniform2i(loc, args[0], args[1]); + else glUniform1i(loc, args[0]); + } + + public static void drawQuads(float x, float y, float width, float height) { + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(x, y); + glTexCoord2f(0, 1); + glVertex2f(x, y + height); + glTexCoord2f(1, 1); + glVertex2f(x + width, y + height); + glTexCoord2f(1, 0); + glVertex2f(x + width, y); + glEnd(); + } + + public static void drawQuads() { + ScaledResolution sr = new ScaledResolution(mc); + float width = (float) sr.getScaledWidth_double(); + float height = (float) sr.getScaledHeight_double(); + glBegin(GL_QUADS); + glTexCoord2f(0, 1); + glVertex2f(0, 0); + glTexCoord2f(0, 0); + glVertex2f(0, height); + glTexCoord2f(1, 0); + glVertex2f(width, height); + glTexCoord2f(1, 1); + glVertex2f(width, 0); + glEnd(); + } + + private int createShader(InputStream inputStream, int shaderType) { + int shader = glCreateShader(shaderType); + glShaderSource(shader, FileUtils.readInputStream(inputStream)); + glCompileShader(shader); + + + if (glGetShaderi(shader, GL_COMPILE_STATUS) == 0) { + System.out.println(glGetShaderInfoLog(shader, 4096)); + throw new IllegalStateException(String.format("Shader failed to compile!", shaderType)); + } + + return shader; + } +} diff --git a/src/main/resources/assets/minecraft/silentclient/shaders/roundRectOutline.frag b/src/main/resources/assets/minecraft/silentclient/shaders/roundRectOutline.frag new file mode 100644 index 0000000..0481bbe --- /dev/null +++ b/src/main/resources/assets/minecraft/silentclient/shaders/roundRectOutline.frag @@ -0,0 +1,19 @@ +#version 120 + +uniform vec2 location, rectSize; +uniform vec4 color, outlineColor; +uniform float radius, outlineThickness; + +float roundedSDF(vec2 centerPos, vec2 size, float radius) { + return length(max(abs(centerPos) - size + radius, 0.0)) - radius; +} + +void main() { + float distance = roundedSDF(gl_FragCoord.xy - location - (rectSize * .5), (rectSize * .5) + (outlineThickness *.5) - 1.0, radius); + + float blendAmount = smoothstep(0., 2., abs(distance) - (outlineThickness * .5)); + + vec4 insideColor = (distance < 0.) ? color : vec4(outlineColor.rgb, 0.0); + gl_FragColor = mix(outlineColor, insideColor, blendAmount); + +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/silentclient/shaders/roundRectTextured.frag b/src/main/resources/assets/minecraft/silentclient/shaders/roundRectTextured.frag new file mode 100644 index 0000000..fc89337 --- /dev/null +++ b/src/main/resources/assets/minecraft/silentclient/shaders/roundRectTextured.frag @@ -0,0 +1,16 @@ +#version 120 + +uniform vec2 location, rectSize; +uniform sampler2D textureIn; +uniform float radius, alpha; + +float roundedBoxSDF(vec2 centerPos, vec2 size, float radius) { + return length(max(abs(centerPos) -size, 0.)) - radius; +} + + +void main() { + float distance = roundedBoxSDF((rectSize * .5) - (gl_TexCoord[0].st * rectSize), (rectSize * .5) - radius - 1., radius); + float smoothedAlpha = (1.0-smoothstep(0.0, 2.0, distance)) * alpha; + gl_FragColor = vec4(texture2D(textureIn, gl_TexCoord[0].st).rgb, smoothedAlpha); +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/silentclient/shaders/roundTextured.frag b/src/main/resources/assets/minecraft/silentclient/shaders/roundTextured.frag new file mode 100644 index 0000000..e21b58f --- /dev/null +++ b/src/main/resources/assets/minecraft/silentclient/shaders/roundTextured.frag @@ -0,0 +1,15 @@ +#version 120 + +uniform vec2 rectSize; +uniform sampler2D textureIn; +uniform float radius, alpha; + +float roundedBoxSDF(vec2 centerPos, vec2 size, float radius) { + return length(max(abs(centerPos) -size, 0.)) - radius; +} + +void main() { + float distance = roundedBoxSDF((rectSize * .5) - (gl_TexCoord[0].st * rectSize), (rectSize * .5) - radius - 1., radius); + float smoothedAlpha = (1.0-smoothstep(0.0, 2.0, distance)) * alpha; + gl_FragColor = vec4(texture2D(textureIn, gl_TexCoord[0].st).rgb, smoothedAlpha); +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/silentclient/shaders/roundedRect.frag b/src/main/resources/assets/minecraft/silentclient/shaders/roundedRect.frag new file mode 100644 index 0000000..45c7029 --- /dev/null +++ b/src/main/resources/assets/minecraft/silentclient/shaders/roundedRect.frag @@ -0,0 +1,17 @@ +#version 120 + +uniform vec2 location, rectSize; +uniform vec4 color; +uniform float radius; +uniform bool blur; + +float roundSDF(vec2 p, vec2 b, float r) { + return length(max(abs(p) - b, 0.0)) - r; +} + +void main() { + vec2 rectHalf = rectSize * .5; + float smoothedAlpha = (1.0-smoothstep(0.0, 1.0, roundSDF(rectHalf - (gl_TexCoord[0].st * rectSize), rectHalf - radius - 1., radius))) * color.a; + + gl_FragColor = vec4(color.rgb, smoothedAlpha); +} \ No newline at end of file