Jump to content

Recommended Posts

Posted

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:

2bYf9eY.png

 

Here's what I want to happen:

s6EauzR.png

 

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

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.