Posted December 21, 201410 yr Hello, I'm having a little trouble with alpha blending on one of my GUIs. I'm rendering an opaque background first, rendering other opaque stuff, and then the translucent foreground. The problem is, the fade/gradient from the foreground is intrusive and can be easily seen. Here's a picture of it: Here's what I want to happen: Finally, here's the code: @Override protected void drawGuiContainerBackgroundLayer(float p1, int p2, int p3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(RES_BG); this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); this.mc.getTextureManager().bindTexture(RES); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); GL11.glDisable(GL11.GL_BLEND); } Kain
December 21, 201410 yr Hi At a guess, your alpha test cutoff is set too high. The darkness decreases smoothly to the cutoff, then suddenly goes fully transparent where the alpha test kicks in at the cutoff value. Depending on what vanilla was previously doing, the cutoff might be 0.5, 0.1, or 0.003. I'd suggest you change it manually (just before your fade/gradient render) to GL11.glAlphaFunc(GL_GREATER, 0.002); or even disable the alpha test entirely GL11.glDisable(GL_ALPHA_TEST); -TGG
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.