Jump to content

[1.12.2] Minecraft textures alpha borders?


Asmodesu

Recommended Posts

So what I'm trying to do now is to render my custom health bar which is constructed of several layers rendered one after another. One of those layers is a semi-transparent texture with it's alpha levels in the 51-103 gaps. Suddenly I found out that Minecraft refuses to accept these alpha levels and it completely drops alpha levels to 0. As result one layer completely disappears.

Here's a code piece for rendering the health bar.

			GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.05f);
            float oneUnit = (int) (bar_width / mc.player.getMaxHealth());
            int currentWidth = (int) (oneUnit * mc.player.getHealth());
            drawTexturedModalRect(0, 0, 0, 0, tex_width, tex_height);
            drawTexturedModalRect(8,0, 8, tex_height, currentWidth, tex_height);
            drawTexturedModalRect(8, 0, 8, tex_height * 2, tex_width, tex_height);
            drawTexturedModalRect(0, 0, 0, tex_height * 3, tex_width, tex_height);
            drawCenteredString(mc.fontRenderer, (int) mc.player.getHealth() + "/" + (int) mc.player.getMaxHealth(), 250, 0 , color);
            GL11.glDisable(GL11.GL_BLEND);

How should I implement my semi-transparent gui?

Link to comment
Share on other sites

Yes, Minecraft ignores alpha values below about 0.15 iirc. Its not very good with the rest of the spectrum either.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

Yes, Minecraft ignores alpha values below about 0.15 iirc. Its not very good with the rest of the spectrum either.

I've experimented with some values and it appears that Minecraft ignores pixels with alpha below 50%. Nevertheless, will it render pixels over 50% alpha as semi-transparent or will just turn them to full opacity?
 

Link to comment
Share on other sites

I haven't fiddled around with in in a UI for a long time.

I think that in a UI it does clipping: anything below half is 0, anything above half is 1.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, Asmodesu said:

GL11

Don't ever call GL functions directly. Use GlStateManager.

 

50 minutes ago, Asmodesu said:

Probably is there anyway to tinker with it?

 

You can see how vanilla does that at GuiIngame:L526 but the relevant state manipulations occur at GuiIngameForge:L131||L261.

53 minutes ago, Draco18s said:

I think that in a UI it does clipping: anything below half is 0, anything above half is 1.

This is fully controlled by the alpha function, if I recall correcly MC uses GREATER 0.1 meaning that anything with less than 10% alpha is discarded. If ALPHA_TEST isn't enabled at all then no fragments are discarded and alpha is simply ignored. OpenGL doesn't do any clipping as far as I am aware.

Link to comment
Share on other sites

38 minutes ago, V0idWa1k3r said:

This is fully controlled by the alpha function, if I recall correcly MC uses GREATER 0.1 meaning that anything with less than 10% alpha is discarded. If ALPHA_TEST isn't enabled at all then no fragments are discarded and alpha is simply ignored. OpenGL doesn't do any clipping as far as I am aware.

Then for some unknown reasons mc keeps ignoring translucent pixels.

Link to comment
Share on other sites

I can't replicate the issue with a test setup. Could you provide more of your code? Providing the texture itself would also be helpful. I have my suspicion on parameters like this:

2 hours ago, Asmodesu said:

tex_height * 2

but I can't confirm them since I do not know their values/the way the method you are using is using them.

Link to comment
Share on other sites

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.