Posted September 1, 20187 yr 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?
September 1, 20187 yr 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.
September 1, 20187 yr Author 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?
September 1, 20187 yr 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.
September 1, 20187 yr Author Yes, it is so. Yet somehow these guys below support translucency. Probably is there anyway to tinker with it?
September 1, 20187 yr 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.
September 1, 20187 yr Author 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.
September 1, 20187 yr 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.
September 4, 20187 yr Author Problem's solved. That was wrong image saving options to cause a problem. Topic can be closed.
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.