Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.